Milkyourcow2 Posted August 23, 2014 Share Posted August 23, 2014 So basically, I need to click on a coordinate after two keys are pressed in order, not at the same time. For example, If I press F4 and then click somewhere a second later, click again at a specific coordiate. I would also like it to choose one of two random coordinates (for my purposes, left and right.) So far this is what I have: #include<misc.au3> sleep("3000") ; time to switch to relevant window While 1 == 1 If _isPressed ("73") then ; If F4 is pressed Do Sleep(10) Until _IsPressed("01") ; Until Mouse is clicked EndIf If Random(0, 1, 1) Then ; Return an integer between 0 and 1. $MousePos = MouseGetPos() MouseClick ("primary", 840,480,0) MouseMove ("$MousePos", 0) Else $MousePos = MouseGetPos() MouseClick ("primary", 770,470,0) MouseMove ("$MousePos", 0) EndIf Wend Right now it's flinging my cursor to the top left and keeping it there, so I have to end the program with task manager using my keyboard. Without "While 1 == 1/WEnd", it just moves my mouse without waiting for the buttons to be pressed. Can anyone enlighten me as to how to finish this up? Link to comment Share on other sites More sharing options...
Danyfirex Posted August 23, 2014 Share Posted August 23, 2014 mousegetpos+mouseclick. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
CoolBreeze Posted August 23, 2014 Share Posted August 23, 2014 (edited) Maybe this can help you, expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: CoolBreeze Year: 2014 #ce ---------------------------------------------------------------------------- #include <misc.au3> Local $mousePos, $mousePos_memo[2], $save_coords[2] ; Hotkeys HotKeySet("{F4}", "_coordSave") HotKeySet("{DEL}", "_clear") HotKeySet("{ESC}", "_exit") ToolTip("Press [F4] - to save position", 10, 10) While 1 If _IsPressed ("01") Then ;Left mouse button If $save_coords[0] <> "" And $save_coords[1] <> "" Then Sleep(100) ;to prevent mousedown effect during move! tested in ms paint MouseClick("left", $save_coords[0], $save_coords[1], 1) EndIf EndIf $mousePos = MouseGetPos() If $mousePos[0] <> $mousePos_memo[0] OR $mousePos[1] <> $mousePos_memo[1] Then ToolTip("Mouse position: " & $mousePos[0] & " x " & $mousePos[1]) ConsoleWrite( $mousePos[0] & "," & $mousePos[1] & @CR) EndIf $mousePos_memo = $mousePos Sleep(10) ; tooltip flicker fix WEnd Func _coordSave() $mousePos = MouseGetPos() $save_coords = $mousePos ToolTip("Position is saved at: " & $save_coords[0] & " x " & $save_coords[1]) EndFunc Func _clear() $save_coords[0] = "" $save_coords[1] = "" ToolTip("Cleared!") EndFunc Func _exit() Exit EndFunc Boris Edited August 23, 2014 by CoolBreeze Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 24, 2014 Moderators Share Posted August 24, 2014 @Milkyourcow2, can you please explain in detail what you are trying to automate? 99% of the time there is a much easier way to accomplish what you're after without having to resort to MouseMoves and MouseClicks. 232showtime 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
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