Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 02-15-2005, 21:30
bilbo bilbo is offline
Friend
 
Join Date: Jul 2004
Posts: 103
Rept. Given: 36
Rept. Rcvd 15 Times in 12 Posts
Thanks Given: 15
Thanks Rcvd at 17 Times in 11 Posts
bilbo Reputation: 15
Hi, lilmeanman / FEARHQ,

here is a C program which will do the job...
Compile from DOS prompt with command "cl click.c"
Run the resulting CLICK.EXE from DOS prompt attaching the button name (e.g. "ok") as command parameter.

Code:
// CLICK.C -- written by bilbo -- 15feb05

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32")

#define WM_CLICK 0xF5

BOOL CALLBACK
EnumWindowsProc(HWND hwnd, LPARAM caption)
{
	char name[128];

	if (GetClassName(hwnd, name, 127) && !strcmp(name, "Button")) {
		GetWindowText(hwnd, name, 127);
		if (!stricmp(name, (LPSTR)caption)) {
			printf("Found Button with handle %x\n", hwnd);
			SendMessage(hwnd, WM_CLICK, 0, 0);
			return FALSE;  // done
			}
		}

	EnumChildWindows(hwnd, EnumWindowsProc, (WPARAM)caption);
	return TRUE;
}

void
main(int argc, char **argv)
{
	if (argc != 2) {
		printf("usage: %s button_caption\n", argv[0]);
		return;
		}

	EnumWindows(EnumWindowsProc, (LPARAM)argv[1]);
}
Strangely enough the message WM_CLICK is not defined in Microsoft includes!!!
So I have defined it at start of the program.

To test the program, you can run Calculator: in that app, each key is a different button... You can press calc keys remotely (e.g. "click 1" "click +")...

Regards, bilbo
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the answered button? Dreamer General Discussion 0 05-07-2015 18:22
Does simulating click affect GetMessagePos()? BlackWhite General Discussion 10 02-14-2015 02:54


All times are GMT +8. The time now is 21:48.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )