Page 1 of 1
Send mouseclick without activating window?
Posted: Sun Aug 24, 2008 9:03 am
by Mistrel
Is it possible to send a mouseclick to a window without activating it?
Posted: Sun Aug 24, 2008 9:22 am
by Marco2007
Maybe if the window is disabled with DisableWindow().
But I don`t know, what you want to do...
Posted: Sun Aug 24, 2008 9:32 am
by Mistrel
It can probably be done with a SendMessage but it's not working to the control's hwnd. I remember there being some special message that needed to be used for the message to reach the control. Does anyone know what this is?
Posted: Sun Aug 24, 2008 11:26 am
by eddy
Did you try PostMessage_() ?
Posted: Sun Aug 24, 2008 5:10 pm
by Sparkie
I've had success using PostMessage_() and or SendMessage() with any one of the following:
#WM_LBUTTONDOWN
#WM_LBUTTONUP
#WM_COMMAND/#BN_CLICK
#BM_CLICK
As for the not activating part of it... well so far I can only manage to get that to work after the initial click.
***Edit*** Now that I take a closer look, ignore my last sentence. The window does not activate when I send the button click.
Posted: Sun Aug 24, 2008 9:14 pm
by Rook Zimbabwe
But the mouseclick can still activate a process in your main program... provided you created both windows from the same program.
Posted: Sun Aug 24, 2008 9:29 pm
by Mistrel
The button turns out to be part of a custom button-image or something. That's why it wasn't working. I still can't get it to click but it's not important anymore. I found a much simpler solution to my problem. Thank you for you help.

Posted: Sun Aug 24, 2008 11:39 pm
by gildev
I found a much simpler solution to my problem
What is your solution please?
Posted: Tue Aug 26, 2008 9:05 am
by Mistrel
The program runs in a loop expecting a certain message to intercept instead of activating it.
Posted: Tue Aug 26, 2008 1:22 pm
by Sparkie
Mistrel wrote:I still can't get it to click but it's not important anymore.
Where's your sense of adventure...your curiosity...how can you ignore that challenge...you gonna let that whimpy little button get the best of you
Send it over here and I'll show it what these 8 fingers and 2 opposable thumbs can do
jk...
Glad to see you found a workaround for this Mistrel.

Posted: Wed Aug 27, 2008 8:11 am
by Mistrel
Ok, Sparkie I'll give it to you.
Download
AC Tool and use this script:
Your objective is to figure out how to send a mouseclick to the "Start" button control. And no cheating by hard-coding an off-set from the bottom-right corner of the screen.
I couldn't figure out how to send a message to this control to simulate a mouse button. The "Start" button doesn't appear to be a real button. You can confirm this with a tool like Winspector.
The correct way to do it is to have the script loop as quickly as you want and check for keyboard events that way. So, start the script once and loop it instead of each time you want it to do something.
Don't fail me in this mission, snake!
Posted: Wed Aug 27, 2008 1:30 pm
by Sparkie
Code: Select all
Macro MakeLong(low, high)
low | high <<16
EndMacro
hParent = FindWindow_("TfrmMain", 0)
If hParent
hChild1 = FindWindowEx_(hParent, 0, "TPageControl", 0)
If hChild1
hChild2 = FindWindowEx_(hChild1, 0, "TTabSheet", "Commands and Macros")
If hChild2
hChild3 = FindWindowEx_(hChild2, 0, "TPanel", 0)
If hChild3
hChild4 = FindWindowEx_(hChild3, 0, "TPanel", 0)
If hChild4
hChild5 = FindWindowEx_(hChild4, 0, "TPanel", 0)
If hChild5
pause = 1000
For bell = 1 To 5
SendMessage_(hChild5, #WM_LBUTTONDOWN, 0, MakeLong(10, 60))
Delay(100)
SendMessage_(hChild5, #WM_LBUTTONUP, 0, MakeLong(10, 60))
Delay(pause)
Next
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
Posted: Wed Aug 27, 2008 9:35 pm
by Mistrel
I'm always impressed, Sparkie. You make it look so easy.
Thank you for this great example of navigating child controls with FindWindowEx. I hadn't thought of ever using it in such a dynamic way.
Posted: Wed Aug 27, 2008 9:48 pm
by Sparkie
Thanks for the challenge Mistrel

Posted: Wed Aug 27, 2008 9:52 pm
by Sparkie
By the way, I noticed a slight bug with my Delay() so I edited the code to fix it.