Click on window while user use mouse
Click on window while user use mouse
Hi all
How can you click on a window without using the main mouse? Like My program.exe clicks on Internet Explorer while the user is using the mouse to do some work? So make the program click on a window without effecting the main mouse?
Thanks in advance
How can you click on a window without using the main mouse? Like My program.exe clicks on Internet Explorer while the user is using the mouse to do some work? So make the program click on a window without effecting the main mouse?
Thanks in advance
Re: Click on window while user use mouse
Use FindWindow_() or some such to retrieve the window handle and then send a #WM_NCLBUTTONDOWN message (with suitable parameters) to the window in question.
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
So like this?
Code: Select all
xPos = 545
yPos = 300
SendMessage_(FindWindow_(0, "PureBasic 4.50 (x64)"), #WM_NCLBUTTONDOWN, xPos, yPos)
Re: Click on window while user use mouse
No. You are misuing the message parameters.
Here's one where we simulate a double-click to maxmimize notepad etc. Just check the window title of the notepad window before running.
If the code cannot find the notepad window then you will to kill the program through the debugger menu.
Here's one where we simulate a double-click to maxmimize notepad etc. Just check the window title of the notepad window before running.
Code: Select all
RunProgram("notepad.exe")
Repeat
hWnd = FindWindow_(0, "Untitled - Notepad")
Until hWnd
SendMessage_(hWnd, #WM_NCLBUTTONDBLCLK, #HTCAPTION, 0)
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
Ok that's working, thank you. But how do you specify position?
Re: Click on window while user use mouse
Code: Select all
SendMessage_(hWnd, #WM_NCLBUTTONDBLCLK, #HTCAPTION, x + y<<16)
If you are sending such messages then, depending on exactly what you are trying to achieve, the actual coordinates may not be important anyhow. That is you can just pass a zero value.
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
Can not get it to work.
I want to left click on the window "Untitled - Notepad" in position x = 5, y = 29 from window's left-top corner?
I want to left click on the window "Untitled - Notepad" in position x = 5, y = 29 from window's left-top corner?
Re: Click on window while user use mouse
Hi
Code: Select all
RunProgram("notepad.exe")
Repeat
hWnd = FindWindow_(0, "Untitled - Notepad")
Until hWnd
ShowWindow_(hWnd, #SW_SHOWMAXIMIZED)
GetCursorPos_(cp.POINT)
SetCursorPos_(5,29)
mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
SetCursorPos_(cp\x,cp\y)
Egypt my love
Re: Click on window while user use mouse
You still using the main mouse?
Re: Click on window while user use mouse
Client co-ordinates or window co-ordinates?oftit wrote:Can not get it to work.
I want to left click on the window "Untitled - Notepad" in position x = 5, y = 29 from window's left-top corner?
If you wish to click within the client-area then use #WM_LBUTTONDOWN.
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
Like this?:
Or like this?:
Can't get both to work?
Thanks for not getting irritated by me asking
Code: Select all
x = 24
y = 77
Repeat
hWnd = FindWindow_(0, "PureBasic 4.50 (x64)")
Until hWnd
SendMessage_(hWnd, #WM_LBUTTONDOWN, #HTCAPTION, x + y)
SendMessage_(hWnd, #WM_LBUTTONUP, #HTCAPTION, x + y)
Code: Select all
x = 24
y = 77
Repeat
hWnd = FindWindow_(0, "PureBasic 4.50 (x64)")
Until hWnd
SendMessage_(hWnd, #WM_LBUTTONDOWN, #HTCLIENT, x + y)
SendMessage_(hWnd, #WM_LBUTTONUP, #HTCLIENT, x + y)
Thanks for not getting irritated by me asking

Re: Click on window while user use mouse
You need to refer to MSDN rather than start guessing about api message parameters. You also haven't taken my cue in how to create the points structure... you need to place the y-coordinate in the upper word of the lParam parameter and the x-coordinate in the lower word. Use x + y<<16.
More importantly, you haven't actually said what it is you are trying to achieve? Do you require a non-client mouse click or a client area click? Are you wishing to instigate the click of a toolbar button for example?
I cannot help without knowing exactly what it is you are trying to achieve because, as it is, I am having to guess.
More importantly, you haven't actually said what it is you are trying to achieve? Do you require a non-client mouse click or a client area click? Are you wishing to instigate the click of a toolbar button for example?
I cannot help without knowing exactly what it is you are trying to achieve because, as it is, I am having to guess.
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
I did try on MSDN and they said something about Get_X_LParam() and Get_Y_LParam. And that the x has to be in lower word and y has to be in upper word?? Which I didn't understand.
My son likes to play a game while he is on MSN. So when he plays this game on OneMoreLevel.com it is very tuff, so he wants the program to click instead while he is watching the program completing the game. I know it is a weird purpose but you know children
So I guess I want to click on the client area?
Or like when you reading on wikipedia and listening to music on youtube, the program will replay the song?
Thank you
My son likes to play a game while he is on MSN. So when he plays this game on OneMoreLevel.com it is very tuff, so he wants the program to click instead while he is watching the program completing the game. I know it is a weird purpose but you know children

Or like when you reading on wikipedia and listening to music on youtube, the program will replay the song?
Thank you
Re: Click on window while user use mouse
Well, is there a particular point in the client-area you wish to click? Is there a button in there that you wish to click?
I may look like a mule, but I'm not a complete ass.
Re: Click on window while user use mouse
No a java app?
So you can't click on a specified position?
So you can't click on a specified position?