spudw2k Posted July 9, 2014 Share Posted July 9, 2014 (edited) If I twere to do it I might have a loop that check for a condition with say a Switch...Case... statement, have each HotKey combo set the variable being to checked to a value and have a loop to perform each desired action. This is simpler, try this on for size. expandcollapse popupGlobal $action = 0 Global $timer = 0 HotKeySet("^1","_RunAction1") ;Ctrl + 1 HotKeySet("^2","_RunAction2") ;Ctrl + 2 HotKeySet("{esc}","_Exit") While 1 $timer = 0 sleep(100) WEnd Func _RunAction1() $action = 1 While 1 ToolTip("Running Action number 1") $timer = TimerInit() Do sleep(100) If $action <> 1 Then Return 0 Until TimerDiff($timer) >= 2000 $timer = TimerInit() ToolTip("Stopping Action number 1") Do sleep(100) If $action <> 1 Then Return 0 Until TimerDiff($timer) >= 2000 WEnd EndFunc Func _RunAction2() $action = 2 While 1 $timer = TimerInit() ToolTip("And here is Action number 2") Do sleep(100) If $action <> 2 Then Return 0 Until TimerDiff($timer) >= 3000 $timer = TimerInit() ToolTip("Now stopping Action number 2") Do sleep(100) If $action <> 2 Then Return 0 Until TimerDiff($timer) >= 3000 WEnd EndFunc Func _Exit() Exit EndFunc Edited July 9, 2014 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Jfish Posted July 9, 2014 Share Posted July 9, 2014 I tried to explain how Exit's code works. Let me try again with some more detail that may be helpful. He has created a couple of hotkeys that both call the same function. That function has a switch. You should look up switch in the help file if you are not familiar with them. It conditionally runs statements but instead of using "IF" it uses "Case". The cases it is testing for in this example are which hotkey was pressed (this is done with the macro @HotKeyPressed). Depending on which key is pressed it will either send the "y" key for 5 seconds (you can change this to 20 if that is your requirement) or it will exit. CTRL+Y will start the timer and the while loop that will run while the difference in time is less than 5 seconds (i.e. it will run for 5 seconds). He uses Notepad simply to demonstrate the whole thing working (you should run it if you have not already done so to see it working). The "ControlSend lines are just sending text to notepad as part of the example. They use the handle returned from when he opened notepad to write back to it. At this point I see two solutions now offered that accomplish your objective. You said you "raped Google" in your OP to try and figure this out. I would suggest applying that same effort to trying to understand the examples provided. If you don't understand a certain line or function start with the help file and then ask some specific questions if you can't figure it out. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
YouDontKnowMe Posted January 4, 2019 Share Posted January 4, 2019 No, it didn't matter what he wanted to use it for.. it was simple autoit mechanic he was asking... damn try hards Link to comment Share on other sites More sharing options...
Developers Jos Posted January 4, 2019 Developers Share Posted January 4, 2019 @YouDontKnowMe, Great first post to get attention. Earthshine and FrancescoDiMuro 1 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...
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