krpandrei Posted September 17, 2009 Posted September 17, 2009 Hello @allI'm wondering that this event can be done in AutoIt:To clone the mouse movements from an app./tool window let's say instance_1 with content_1 to the same app. but this time window instance_2 with content_2.Just for the porpoise to compare two verions of one map (in my case) in the same time side by side using same app./toolTHX!
Bert Posted September 17, 2009 Posted September 17, 2009 why do I think this is for a game bot.... The Vollatran project My blog: http://www.vollysinterestingshit.com/
jvanegmond Posted September 17, 2009 Posted September 17, 2009 You only have one mouse cursor, and it can only be in one place at a time. You can repeat previously done mouse movements, or you can switch the mouse between 2 locations very fast.. But it's nowhere near having 2 mouse cursors, one following the other. Find another way to do what you want. github.com/jvanegmond
krpandrei Posted September 17, 2009 Author Posted September 17, 2009 (edited) why do I think this is for a game bot....no way ... because i'm just a maps tester training to make my work yeaseproof Edited September 17, 2009 by krpandrei
jvanegmond Posted September 17, 2009 Posted September 17, 2009 Who cares if it's for a game bot or not. I certainly don't, so let's focus on solving your problem. github.com/jvanegmond
krpandrei Posted September 21, 2009 Author Posted September 21, 2009 Who cares if it's for a game bot or not. I certainly don't, so let's focus on solving your problem. expandcollapse popup; Script function: DOUBLE CLICKS ; Version: 0.0 alpha ; Features: ; Esc to terminate script, Pause/Break to "pause" Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client ; Change into the WinTitleMatchMode that supports classnames and handles AutoItSetOption("WinTitleMatchMode", 4) ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "AutoIt Script", "Run?") ; Check the user's answer to the prompt ; If "No" was clicked (7) then exit the script If $answer = 7 Then Terminate() EndIf ;HANDLE WINDOWS $DesktopWidth=1280 $DesktopHeight=1024-25 ;Minimizes all windows WinMinimizeAll() ; Get the handle of a notepad window 1 and resize & move to left Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle1 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle1, "", 0, 0, $DesktopWidth/2, $DesktopHeight) EndIf ; Get the handle of a notepad window 2 and resize & move to right Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle2 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:2]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle2, "", $DesktopWidth/2, 0, $DesktopWidth/2, $DesktopHeight) EndIf Mouse() Func Mouse() $x = MouseGetPos(0) $y = MouseGetPos(1) ;~ ;decide in what window the click was made ;~ If wuindow 1 ;~ ;select window 2 ;~ ;execute function clicksendL2R ;~ Else ;~ If wuindow 2 ;~ ;select window 1 ;~ ;execute function clicksendR2L While 1 ;infinite loop If WinActive($handle1) Or MouseDown("primary")=1 Then ;If $x < $DesktopWidth/2 Then WinActivate($handle2, "") ;MouseClick ( "primary", $x, $y) Sleep(500) ElseIf WinActive($handle2) Or MouseDown("primary")=1 Then WinActivate($handle1, "") ;MouseClick ( "primary", $x, $y) Sleep(500) EndIf WEnd EndFunc ;==>Mouse Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() MsgBox(0, "Stop", "OK. Bye!") Exit 0 EndFunc ;==>Terminate I used Notepad windows just for example until the whole script will work This is what I done so far but I have some problems with my noobe code: How can I distinguish better between two Notepad windows using &handle or something else because my Mouse function gets stuck on selection between windows ?
jvanegmond Posted September 21, 2009 Posted September 21, 2009 (edited) MouseCoordMode 0 means relative coords to the active window. In other words, you have to activate the window first, and then do the mouse move.Some bad code in your script. And here's an example:expandcollapse popup; Script function: DOUBLE CLICKS ; Version: 0.0 alpha ; Features: ; Esc to terminate script, Pause/Break to "pause" Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client ; Change into the WinTitleMatchMode that supports classnames and handles ; AutoItSetOption("WinTitleMatchMode", 4) ; DECREPATED!! ; Press Esc to terminate script, Pause/Break to "pause" Local $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") #region Useless ; Prompt the user to run the script - use a Yes/No prompt ;$answer = MsgBox(4, "AutoIt Script", "Run?") ; Check the user's answer to the prompt ; If "No" was clicked (7) then exit the script ;If $answer = 7 Then ;Terminate() ;EndIf #endregion ;HANDLE WINDOWS $DesktopWidth= @DesktopWidth $DesktopHeight= @DesktopHeight ;Minimizes all windows WinMinimizeAll() ; Get the handle of a notepad window 1 and resize & move to left Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle1 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle1, "", 0, 0, $DesktopWidth/2, $DesktopHeight) EndIf ; Get the handle of a notepad window 2 and resize & move to right Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle2 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:2]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle2, "", $DesktopWidth/2, 0, $DesktopWidth/2, $DesktopHeight) EndIf _ClickBoth("Left", 30, 35) Exit Func _MoveBoth($x, $y, $speed) _WinActivateWait($handle1) MouseMove($x, $y, $speed) Sleep(200) _WinActivateWait($handle2) MouseMove($x, $y, $speed) Sleep(200) EndFunc Func _ClickBoth($mousebutton, $x, $y, $clicks = 1, $speed = 0) _WinActivateWait($handle1) MouseClick($mousebutton, $x, $y, $clicks, $speed) Sleep(200) _WinActivateWait($handle2) MouseClick($mousebutton, $x, $y, $clicks, $speed) Sleep(200) EndFunc Func _WinActivateWait($handle) WinActivate($handle) WinWaitActive($handle) EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() MsgBox(0, "Stop", "OK. Bye!") Exit 0 EndFunc ;==>Terminate Edited September 21, 2009 by Manadar github.com/jvanegmond
krpandrei Posted September 21, 2009 Author Posted September 21, 2009 Thank you for the your answer , the problem is that I try to make a loop that only when I click in the first window the click will be send also to the second window and vice versa
jvanegmond Posted September 21, 2009 Posted September 21, 2009 Then why not ask in the first place? Check out the help file for _IsPressed. MouseDown is a function that puts the mouse button down, and it doesn't detect whether it's down... lol. github.com/jvanegmond
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now