Jump to content
Sign in to follow this  
vbfg

ControlClick, Down and Up

Recommended Posts

vbfg

Hello, I'm having trouble finding a method that will send a mouse down and mouse up events to a window by handle or by title, in a manner like ControlClick does. I think there is no such default method in AutoIt, but maybe it's just called something unusual and can't be easily found.

Anyway, how do I send a mouse down and mouse up events to a minimized window at specific coordinates like ControlClick does?

(because I can't just do MouseDown() and MouseUp() since target window is minimized, and should never steal focus from any windows on its own)

Edited by vbfg

Share this post


Link to post
Share on other sites
vbfg

Sorry, I should've made it more clear. I can't achieve what I want by using ControlClick (since it doesn't support Down and Up modes, just clicking), but I also can't use MouseDown or MouseUp, because the target window must stay minimized, or at least not active.

Share this post


Link to post
Share on other sites
Bowmore

You could try sending windows messages directly

#include <SendMessage.au3>
#include <WindowsConstants.au3>

_SendMessage($hWndControl, $WM_LBUTTONDOWN)
_SendMessage($hWndControl, $WM_LBUTTONUP)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
vbfg

But I also need them to be at specified coordinates, is it possible to send such message? Maybe send a mouse move message prior to up/down?

Share this post


Link to post
Share on other sites
Bowmore

Yes you can include coordinates and other information, such keys Ctrl Shift etc. held down.

If you want to learn the details check out this link.

http://msdn.microsoft.com/en-us/library/ms645607(v=vs.85).aspx

#include <SendMessage.au3>
#include <WindowsConstants.au3>

Local $hWndControl = 0 ; Set to handel of the control
Local $x = 50 ; X coord for Mouse click
Local $y = 20 ; Y coord for Mouse click
Local $wParam = 0
Local $lParam = BitRotate($x,16,"D")
$lParam = BitXOR($lParam,$y)
_SendMessage($hWndControl, $WM_LBUTTONDOWN,$wParam,$lParam)
_SendMessage($hWndControl, $WM_LBUTTONUP,$wParam,$lParam)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
vbfg

Great, this works! Thanks everyone!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×