Jump to content

MouseClickMinimized and MouseMoveMinimized


Recommended Posts

How can I make this work? can someone give an example? I'm trying to send click and mouse movement to an inactive window with out disrupting my mouse, so that i can work on other stuff. I hope someone could give me a working sample of the script. 

 

Spoiler

;===============================================================================
;
; Function Name:  _MouseClickMinimized()
; Version added:  0.1
; Description:    Sends a click to window, not entirely accurate, but works
;                 minimized.
; Parameter(s):   $Window     =  Title of the window to send click to
;                 $Button     =  "left" or "right" mouse button
;                 $X          =  X coordinate
;                 $Y          =  Y coordinate
;                 $Clicks     =  Number of clicks to send
; Remarks:        You MUST be in "MouseCoordMode" 0 (cpf: or 2???) to use this without bugs.
; Author(s):      Insolence <insolence_9@yahoo.com>
;
;===============================================================================
Func _MouseClickMinimized($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1, $handle = 0)
    Local $MK_LBUTTON = 0x0001
    Local $WM_LBUTTONDOWN = 0x0201
    Local $WM_LBUTTONUP = 0x0202
    Local $MK_RBUTTON = 0x0002
    Local $WM_RBUTTONDOWN = 0x0204
    Local $WM_RBUTTONUP = 0x0205
    Local $WM_MOUSEMOVE = 0x0200
    Local $i = 0
    if $handle = 1 Then
        Local $winhandle = $Window
    Elseif $handle = 0 Then
        Local $winhandle = WinGetHandle($Window)
    EndIf
    Select
        Case $Button = "right"
            $Button = $MK_RBUTTON
            $ButtonDown = $WM_RBUTTONDOWN
            $ButtonUp = $WM_RBUTTONUP
        Case $Button = "left"
            $Button = $MK_LBUTTON
            $ButtonDown = $WM_LBUTTONDOWN
            $ButtonUp = $WM_LBUTTONUP
        Case Else  ;; CPF
            ;; illegal number of parameters?
;~             MsgBox(32, "KCH: Problem", "_MouseClickPlus() called with bad number of params?")
            Return
    EndSelect
    ;; makes no sense to send click to minimized window with current mouse coordinates
    If $X = "" Or $Y = "" Then
        ;; illegal number of parameters?
;~         MsgBox(32, "KCH: Problem", "_MouseClickPlus() called with bad number of params?")
        Return
    EndIf
    For $i = 1 To $Clicks
        DllCall("user32.dll", "int", "SendMessage", _
                "hwnd", $winhandle, _
                "int", $WM_MOUSEMOVE, _
                "int", 0, _
                "long", _MakeLong($X, $Y))
        DllCall("user32.dll", "int", "SendMessage", _
                "hwnd", $winhandle, _
                "int", $ButtonDown, _
                "int", $Button, _
                "long", _MakeLong($X, $Y)) 
        Sleep(10)
        DllCall("user32.dll", "int", "SendMessage", _
                "hwnd", $winhandle, _
                "int", $ButtonUp, _
                "int", $Button, _
                "long", _MakeLong($X, $Y)) 
    Next
EndFunc   ;==>_MouseClickMinimized

;===============================================================================
;
; Function Name:  _MouseMoveMinimized()
; Version added:  0.1
; Description:    Sends a move message to window, works minimized.
; Parameter(s):   $Window     =  Title of the window to send click to
;                 $X          =  X coordinate
;                 $Y          =  Y coordinate
; Remarks:        You MUST be in "MouseCoordMode" 0 (cpf: or 2???) to use this without bugs.
; Author(s):      Cris Fuhrman (based on code by Insolence <insolence_9@yahoo.com>)
;
;===============================================================================
Func _MouseMoveMinimized($Window, $X = "", $Y = "", $handle = 0)
    Local $WM_MOUSEMOVE = 0x0200
    Local $i = 0
    if $handle = 1 Then
        Local $winhandle = $Window
    Elseif $handle = 0 Then
        Local $winhandle = WinGetHandle($Window)
    EndIf
    
    If $X = "" Or $Y = "" Then
;~         MsgBox(32, "KCH: Problem", "_MouseMovePlus() called with bad number of params?")
        Return
    EndIf
    
    DllCall("user32.dll", "int", "SendMessage", _
            "hwnd", $winhandle, _
            "int", $WM_MOUSEMOVE, _
            "int", 0, _
            "long", _MakeLong($X, $Y)) 
EndFunc   ;==>_MouseMoveMinimized

Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc   ;==>_MakeLong

 

Link to comment
Share on other sites

i dont know if is possible , but  you can do some test , i suggest  send  code ,(and use tag)  , but  before (send code) you must read the help file  look this command

winwait  also wingethandle , controlclick

try to do somthin the  comunity will be  happy to reaply , good luck

 

Edited by faustf
Link to comment
Share on other sites

  • Developers

Why are you changing the font of that first lecture sentence? (Though we went over this before?)
Just use the standard font and only highlight what needs highlighting please.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...