35#define APP_NAME "wclickat"
36#define DEFAULT_DELAY 500
37#define DEFAULT_REPEAT 1000
39#define ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0]))
49#define RC_INVALID_ARGUMENTS 1
86#define __PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
88#define __PRINTF_ATTR(fmt,args)
118 fprintf(
stderr,
"----------------------------------------------\n");
124 fprintf(
stderr,
" find Find the specified window or control\n");
125 fprintf(
stderr,
" button<n> Send a click with the given X button number\n");
126 fprintf(
stderr,
" click|lclick Synonym for button1 (left click)\n");
127 fprintf(
stderr,
" mclick Synonym for button2 (middle click)\n");
128 fprintf(
stderr,
" rclick Synonym for button3 (right click)\n");
132 fprintf(
stderr,
" --winclass class Class name of the top-level window of interest\n");
133 fprintf(
stderr,
" --wintitle title Title of the top-level window of interest\n");
134 fprintf(
stderr,
" --ctrlclass name Class name of the control of interest, if any\n");
135 fprintf(
stderr,
" --ctrlcaption cap A substring of the control's caption\n");
137 fprintf(
stderr,
" --position XxY Coordinates for the click, relative to the window / control\n");
138 fprintf(
stderr,
" --dragto If given, then position specifies start click, and\n");
140 fprintf(
stderr,
" --allow-disabled Match the window or control even hidden or disabled\n");
142 fprintf(
stderr,
" --untildeath Wait until the window disappears\n");
148 fprintf(
stderr,
" CXTEST_TIME_MULTIPLE Specifies a floating multiplier applied to any\n");
266 window_info.
cbSize=
sizeof(window_info);
289 long step_per_x, step_per_y;
290 long dragto_x, dragto_y;
293 if (dragto_x<window_info.rcWindow.left || dragto_x>=window_info.
rcWindow.
right)
298 if (dragto_y<window_info.rcWindow.top || dragto_y>=window_info.
rcWindow.
bottom)
306 for (
i = 0;
i < 4;
i++) {
333 cxlog(
"The window has disappeared!\n");
343 cxlog(
"Sending left click\n");
347 cxlog(
"Sending middle click\n");
351 cxlog(
"Sending right click\n");
367 cxlog(
"Setting up a timer for --repeat\n");
380 cxlog(
"Found the window\n");
383 cxlog(
"Waiting for a bit\n");
484 if (
r!=1 && (
r!=2 ||
extra!=
'\0'))
490 else if (button<1 || button>3)
519 else if (
strcmp(
arg,
"--ctrlclass") == 0)
527 else if (
strcmp(
arg,
"--ctrlcaption") == 0)
546 if (
r!=2 && (
r!=3 ||
extra!=
'\0'))
570 if (
r!=2 && (
r!=3 ||
extra!=
'\0'))
579 else if (
strcmp(
arg,
"--allow-disabled") == 0)
595 else if (
strcmp(
arg,
"--untildeath") == 0)
626 fprintf(
stderr,
"error: you must specify a --winclass parameter\n");
631 fprintf(
stderr,
"error: you must specify a --wintitle parameter\n");
638 fprintf(
stderr,
"error: you must specify either the control id or its caption\n");
646 p =
getenv(
"CXTEST_TIME_MULTIPLE");
649 float g_multiple =
atof(
p);
int strcmp(const char *String1, const char *String2)
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
#define MultiByteToWideChar
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLdouble GLdouble GLdouble r
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
static IHTMLWindow2 * window
static const char haystack[]
unsigned __int3264 UINT_PTR
TW_UINT32 TW_UINT16 TW_UINT16 MSG
static int arg_get_utf8(const char ***argv, const char *name, WCHAR **value)
static void CALLBACK ClickProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
static void cxlog(const char *format,...) __PRINTF_ATTR(1
static void CALLBACK DelayProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
static HWND find_window()
static int arg_get_long(const char ***argv, const char *name, long *value)
static WCHAR * g_window_title
static void CALLBACK FindWindowProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
#define ARRAY_LENGTH(array)
static const WCHAR * my_strstriW(const WCHAR *haystack, const WCHAR *needle)
static action_type g_action
#define __PRINTF_ATTR(fmt, args)
static void do_click(HWND window, DWORD down, DWORD up)
static BOOL CALLBACK find_top_window(HWND hwnd, LPARAM lParam)
static WCHAR * g_window_class
static WCHAR * g_control_class
static WCHAR * g_control_caption
static void CALLBACK TimeoutProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
static int parse_arguments(int argc, const char **argv)
static BOOL CALLBACK find_control(HWND hwnd, LPARAM lParam)
static const WCHAR STATIC_CLASS[]
#define RC_INVALID_ARGUMENTS
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
#define GetWindowStyle(hwnd)
#define MOUSEEVENTF_ABSOLUTE
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define MOUSEEVENTF_LEFTUP
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define MOUSEEVENTF_RIGHTUP
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define MOUSEEVENTF_MIDDLEUP
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define MOUSEEVENTF_LEFTDOWN
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
HWND WINAPI GetParent(_In_ HWND)
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define MOUSEEVENTF_RIGHTDOWN
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MOUSEEVENTF_MIDDLEDOWN
int WINAPI GetSystemMetrics(_In_ int)