I have a software where certain functions can only be triggered by mouse click AND the window is randomly positioned. Right now the 'find window' macro doesn't have an option to set the mouse pointer to the upper left corner, or any reference position for that matter. Nor does the macro for positioning the mouse allow to do this. Did I miss anything?
This would be a useful option but I am not enough of a Python coder to add it myself, unfortunately. Is there perhaps a way to pull this information out of eg, and set the mouse position in a Python macro? I have seen an example in this forum by Pako where such a script was used to send the last found window into the background, so I am thinking this should also be possible.
Thanks for an awesome application!
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Move mouse pointer to window
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Move mouse pointer to window
You can use this script:Pako
Code: Select all
from win32gui import GetWindowPlacement
hwnd = eg.lastFoundWindows[0]
wp = GetWindowPlacement(hwnd)
eg.plugins.Mouse.MoveAbsolute(wp[4][0], wp[4][1])-
helloworld.c
- Posts: 3
- Joined: Sat Sep 04, 2010 8:53 pm
Re: Move mouse pointer to window
Thanks, but no workie. The mouse is always set to (3,127) here, no matter where the window is positioned. The window is found correctly before, otherwise it would timeout, and I can do other operations to it. I am wondering whether GetWindowPlacement() works. System is Windows 7 Pro.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Move mouse pointer to window
I'm sorry, but to me works well. My system is Windows 7 Pro.
Which EventGhost version you have? I have 0.3.7.r1462.
Try two things:
1) The same script with some other window (with some other applications)
2) Modify the script as follows and in the log check window position.Pako
Which EventGhost version you have? I have 0.3.7.r1462.
Try two things:
1) The same script with some other window (with some other applications)
2) Modify the script as follows and in the log check window position.
Code: Select all
from win32gui import GetWindowPlacement
hwnd = eg.lastFoundWindows[0]
wp = GetWindowPlacement(hwnd)
print "Position = (%i, %i)" % (wp[4][0], wp[4][1])
eg.plugins.Mouse.MoveAbsolute(wp[4][0], wp[4][1])-
helloworld.c
- Posts: 3
- Joined: Sat Sep 04, 2010 8:53 pm
Re: Move mouse pointer to window
Tried it with another window and it worked! The reason it didn't work with the other window was I was finding a sub-window not the top-level one. With top-level, it works also. Thanks for your help!