Jump to content

Clone mouse


Recommended Posts

Hi all,

i'm trying to clone mouse click on 2 windows of different size.

it works but it's quiet slow any idea how to have it faster ?

write in the dll maybe ?

Thanks

Moughor

ps : or is there a way to send as a "key" the click mouse without move it ?

#include <Misc.au3>

$dll = DllOpen("user32.dll")

$win1 = WinGetHandle ("[TITLE:win; INSTANCE:1]", "")
$win2 = WinGetHandle ("[TITLE:win; INSTANCE:2]", "")

$winP2 = WinGetPos( $win1 )
$winP1 = WinGetPos ( $win2 )

MsgBox(0, "Active window stats (x,y,width,height):", $winP1[0] & " " & $winP1[1] & " " & $winP1[2] & " " & $winP1[3])
MsgBox(0, "Active window stats (x,y,width,height):", $winP2[0] & " " & $winP2[1] & " " & $winP2[2] & " " & $winP2[3])

$ratioX = $winP2[2] / $winP1[2]
$ratioY = $winP2[3] / $winP1[3]

 While 1
    Sleep ( 1 )
    If _IsPressed("04", $dll) Then
        
        $posMouse = MouseGetPos()
        sleep(200)
        MouseClick("middle",(($posMouse[0]/$ratioX)+$winP1[0]) ,(($posMouse[1]/$ratioY)+$winP1[1]) )
        MouseMove($posMouse[0],$posMouse[1])
        
    EndIf
WEnd
DllClose("user32.dll")
Edited by Moughor
Link to comment
Share on other sites

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Use something like:

MouseClick("middle",(($posMouse[0]/$ratioX)+$winP1[0]) ,(($posMouse[1]/$ratioY)+$winP1[1]), 1, 1 )
MouseMove($posMouse[0],$posMouse[1], 1)

Rawox

Edited by Rawox
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...