Jump to content

ControlClick, Down and Up


vbfg
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 6 years later...

how to use this? from hold left button from x y and up on x y+300

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

Opt("MouseCoordMode",  1)

global $y, $x, $x2, $y2


$sText = "Swintusz"
$handle = WinGetHandle($sText)

Sleep(200)
dragAr()

Func dragAr()

    Local $search = _ImageSearch('ar.bmp', 0, $x, $y, 32)
    If $search = 1 Then

        Local $hWndControl = $handle ; Set to handel of the control
        Local $wParam = 0
        Local $lParam = BitRotate($x,16,"D")
        $lParam = BitXOR($lParam,$y)
        _SendMessage($hWndControl, $WM_LBUTTONDOWN,$wParam,$lParam)

        Sleep(1000)

        $y=$y+330

        Local $wParam = 0
        Local $lParam = BitRotate($x,16,"D")
        $lParam = BitXOR($lParam,$y)
        _SendMessage($hWndControl, $WM_LBUTTONDOWN,$wParam,$lParam)

    EndIf

EndFunc

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...