![]() |
|
|
|
#1
|
|||
|
|||
|
Sorry im such a newbie at all of this, but would I put the WM code at the end of the program?
And then jump to it when the program is at a safe place? I'm not very good at ASM and most of the tutorials out there suck, so im sorry for being such a newb. |
|
#2
|
|||
|
|||
|
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]);
}
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 |
|
#3
|
|||
|
|||
|
hehe thanks bilbo
for that equ i had to wade through WM_USER+ the messages in the range of 0xb00 if the project was build with bcbuilder to find the message that simulates a click on buttons this equate makes the work easy where did you dig it out from coz sending two concurrent WM_LBUTTONDOWN AND WM_LBUTTONDOWN OR WM_COMMAND to buttons failed many times and i could never see this WM_CLICK anywhere so i was forced to dig into many apps to find the exact message that handles like 0xbd11 blah blah and send that message ![]() i just transformed one of my masm template Code:
.const WM_CLICK equ 0f5h invoke PostMessage,NagButtonHandle,WM_CLICK,NULL,NULL ![]() btw Doesnt SendMessage Create problems like not getting closed till the original exe returns ??? i had problems with it and i converted my self to PostMessage Last edited by JuneMouse; 02-16-2005 at 00:33. |
|
#4
|
|||
|
|||
|
Quote:
Quote:
Regards, bilbo |
|
#5
|
|||
|
|||
|
You probably didn't get many hits because it's BM_CLICK not WM_CLICK
See Satyric0n's post above.
|
|
#6
|
|||
|
|||
|
He would have found only 281 hits for "BM_CLICK."
This one might be of interest: http://www.minigui.com/api_ref/group__ctrl__button__msgs.html and the part where it states: Define Documentation #define BM_CLICK 0xF0F5 Simulates the user clicking a button. An application sends a BM_CLICK message to simulate the user clicking a button. BM_CLICK wParam = 0; lParam = 0; Definition at line 822 of file control.h. That seems to make the "definition" of BM_CLICK and WM_CLICK seem somewhat similar. At least in this case. Regards,
__________________
JMI |
|
#7
|
|||
|
|||
|
Thanks, Jackal / JMI,
that was another gross failure of my memory! I would have known that, since a CLICK is a message specific to Buttons, it must not be searched under WM_xxx (generic Windows messages), but under BM_xxx (Button messages). And that is in fact the place where it is documented by M$, in their SDK, along with other: Button Control Messages (BCM_GETIDEALSIZE, BCM_GETIMAGELIST, BCM_GETTEXTMARGIN,BCM_SETIMAGELIST, BCM_SETTEXTMARGIN) Button Control Notifications (BCN_HOTITEMCHANGE) Button Messages (BM_CLICK, BM_GETCHECK, BM_GETIMAGE, BM_GETSTATE,BM_SETCHECK, BM_SETIMAGE,BM_SETSTATE, BM_SETSTYLE) Button Notifications (BN_CLICKED,BN_DBLCLK, BN_DOUBLECLICKED, BN_KILLFOCUS,BN_SETFOCUS, BN_DISABLE, BN_HILITE, BN_PAINT,BN_PUSHED,BN_UNHILITE,BN_UNPUSHED) BM_CLICK is defined in winuser.h (for MSVC) as Code:
#define BM_CLICK 0x00F5 Code:
BM_CLICK equ 0F5h By the way, the site you dug out is very interesting, JMI! They (our chinese colleagues) are offering a full GUI (with some sources) multi-platform and not depending on GDI32/WIN32K... [EDIT JMI: Master bilbo: Slightly adjusted your post so that it didn't run outside the normal window view and all shows without the scroll sideways.] [EDIT bilbo: Thanks, JMI, I do not how could it happen!] Last edited by bilbo; 02-17-2005 at 16:21. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |