Gyun Posted April 26, 2020 Share Posted April 26, 2020 Hey all! Periodic user (over the past decade+ with basic use/skills) first time poster. I have been working the past too many hours on something (probably very simple) but WAY OUT OF MY DEPTH. I've been researching, help menu-ing, copy/pasting, tweaking, Googling for a way to do the following: Execute a script that: Stays on in the background (on a loop I guess) A hotkey to cancel it like ESC When Key is pressed, say like number 1, then it activates So, when 1 is pressed it triggers the following commands Sleep 10 Mouse move to an X,Y position Mouse Click left Sleep 10 Mouse move to an X,Y position Mouse Click left Sleep 10 Key Press F1 Then it waits for 1 to be pressed again. So I cannot figure out how to do this - tried whens, ifs, thens - and not sure (obviously) how to put multiple commands into a function - like mouse move and click. I have scoured looking for examples, to no avail. Can a wizard in here sprinkle some magic (and basically write this for me), please? Thanks! What more information do you need from me? Much Love, 😍 G Link to comment Share on other sites More sharing options...
argumentum Posted April 26, 2020 Share Posted April 26, 2020 9 minutes ago, Gyun said: Periodic user (over the past decade+ with basic use/skills) ...so, you can code this. Welcome to the forum GG Gyun 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 26, 2020 Developers Share Posted April 26, 2020 12 minutes ago, Gyun said: Can a wizard in here sprinkle some magic (and basically write this for me), please? Thanks! You rang??? What you share some exact information what it is you need to automate and show us what you have that isn't working? Jos Gyun 1 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 More sharing options...
Gyun Posted April 26, 2020 Author Share Posted April 26, 2020 I have been working on two different paths to see what works - sometimes my When does not end, sometimes I have a Wend out of place. Here are 3 junk examples that maybe show what I going for. Be gentle. 😲 1) First Attempt expandcollapse popupGlobal $Paused, $Runner HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F9}", "ShowMe") Func _Start () While _IsPressed("8") If _IsPressed("8") Then MouseClick ( "left" [, 271, 163 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) MouseClick ( "left" [, 442, 287 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) Send ( "F11" [, flag = 0] ) Sleep ( 10 ) EndIf WEnd EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMe() $Runner = NOT $Runner While $Runner sleep(100) ToolTip('Script is "Running"',0,0) WEnd ToolTip("Script is Stopped", 0, 0) EndFunc 2) Second Try ; Loop While 8 HotKeySet("{ESC}", "On_Exit") ; Pressing ESCAPE exits the script HotKeySet("8", "HALP") ; Pressing "8" moves the mouse WEnd ; infinite loop to keep the script alive While 1 Sleep(10) WEnd Func HALP() Sleep ( 10 ) MouseMove ( 271, 163 [, speed = 10] ) ;move mouse MouseClick("Left") ;click left Sleep ( 10 ) MouseMove ( 442, 287 [, speed = 10] ) ;move mouse MouseClick("Left") ;click left Sleep ( 10 ) Send ( "f11" ) Sleep ( 10 ) EndFunc 3) I tried less is more... ; Main Loop HotKeySet("{ESC}", "_ExitScript") ; Pressing ESCAPE exits the script While 8 If _IsPressed ("08") Then Sleep ( 10 ) MouseClick ( "left" [, 271, 163 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) MouseClick ( "left" [, 442, 287 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) Send ( "F11" [, flag = 0] ) Sleep ( 10 ) WEnd Func _ExitScript() ;Exit Main Loop Exit EndFunc ---- All fail, but I have been trying and I have no shame so you can see what I am trying to do. I am not a coder and previously just used AutoIt to show like mouse coords or move and click one time.🤪 Link to comment Share on other sites More sharing options...
Developers Jos Posted April 26, 2020 Developers Share Posted April 26, 2020 ....and these are solutions to which problem exactly? Gyun 1 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 More sharing options...
Aelc Posted April 26, 2020 Share Posted April 26, 2020 (edited) Welcome to the forum 33 minutes ago, Gyun said: I have been working on two different paths to see what works - sometimes my When does not end, sometimes I have a Wend out of place. Here are 3 junk examples that maybe show what I going for. Be gentle. 😲 1) First Attempt expandcollapse popupGlobal $Paused, $Runner HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F9}", "ShowMe") Func _Start () While _IsPressed("8") If _IsPressed("8") Then MouseClick ( "left" [, 271, 163 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) MouseClick ( "left" [, 442, 287 [, clicks = 1 [, speed = 10]]] ) Sleep ( 10 ) Send ( "F11" [, flag = 0] ) Sleep ( 10 ) EndIf WEnd EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit EndFunc Func ShowMe() $Runner = NOT $Runner While $Runner sleep(100) ToolTip('Script is "Running"',0,0) WEnd ToolTip("Script is Stopped", 0, 0) EndFunc In your first try you never called the function that have been written and you didn't set a hotkey on that function... so you can't call it! you need a loop to don't exit after set the hotkeys. also you just copied the mouseclicks out of the helpfile... Mouseclick ( 271, 163 [, speed = 10] ) The parameter which are inside [] are optional! that means you don't need to write them if you won't change them so it should be Mouseclick ( 271, 163 ) or Mouseclick ( 271, 163 , 10 ) also for the send() For using _ispressed() you will need to add #include <misc.au3> on the top of your script as you can see in the helpfile your ShowMe() func contains a loop so you won't be able to do something after you pressed F9 ( like your pause ) by the way try the helpfile examples next time first Good luck Edited April 26, 2020 by Aelc Gyun 1 why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Gyun Posted April 26, 2020 Author Share Posted April 26, 2020 23 minutes ago, Jos said: ....and these are solutions to which problem exactly? Basically, I am trying to automate some communication clicks in a flight sim so I can keep hands-on joystick. So by one joystick click, it would move the mouse and click, etc, to hail a target. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 26, 2020 Moderators Share Posted April 26, 2020 Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team Gyun 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