Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2005, 03:48
lilmeanman
 
Posts: n/a
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.
Reply With Quote
  #2  
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
  #3  
Old 02-16-2005, 00:29
JuneMouse
 
Posts: n/a
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
works flawlessly for a button that handled ony 0bd11h message

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.
Reply With Quote
  #4  
Old 02-16-2005, 01:10
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
Quote:
Originally Posted by JuneMouse
where did you dig it out from
I googled for WM_CLICK and only 141 hits came out, some of them with the equate. I don't know who discovered it (I browsed all the hits without success), and I'm surprised that that message has not yet been documented by Microsoft!

Quote:
Originally Posted by JuneMouse
Doesnt SendMessage Create problems like not getting closed till the original exe returns ???
I didn't find the problem you are reporting... Maybe BCBuilder sub-classes the standard button class???

Regards, bilbo
Reply With Quote
  #5  
Old 02-16-2005, 01:46
Jackal
 
Posts: n/a
You probably didn't get many hits because it's BM_CLICK not WM_CLICK See Satyric0n's post above.
Reply With Quote
  #6  
Old 02-16-2005, 03:24
JMI JMI is offline
Leader
 
Join Date: Jan 2002
Posts: 1,627
Rept. Given: 5
Rept. Rcvd 199 Times in 99 Posts
Thanks Given: 0
Thanks Rcvd at 98 Times in 96 Posts
JMI Reputation: 100-199 JMI Reputation: 100-199
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
Reply With Quote
  #7  
Old 02-16-2005, 16:35
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
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
and in windows.inc (for MASM32) as
Code:
BM_CLICK                             equ 0F5h
Regards, bilbo

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.
Reply With Quote
Reply

Thread Tools
Display Modes

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 23:28.


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