FrequentUser Posted July 19, 2013 Share Posted July 19, 2013 While True $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) If $color = 16711680 Or $color = 16646144 Then MouseClick ("middle") Sleep(10) EndIf Wend This is my current script, however I'd like to make it where if I press the number "4" It'll activate the script (have it active) and if I press "5" it'll deactivate it. I don't want a temporary pause of some sort, I want it to physically have a start/stop function. I've tried looking at the hotkeypress examples of pausing the script however it does not work. I'm using this script on a full screen application hence I need it to disable/enable via those hotkeys, 4/5 Could someone help me out with this code ;/ kinda new to all this. Thanks. Link to comment Share on other sites More sharing options...
FrequentUser Posted July 19, 2013 Author Share Posted July 19, 2013 bump Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 19, 2013 Moderators Share Posted July 19, 2013 FrequentUser,Welcome to the AutoIt forum. But please do not bump your own threads within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. So be patient. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
czardas Posted July 19, 2013 Share Posted July 19, 2013 Is this for a game? operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
0xdefea7 Posted July 19, 2013 Share Posted July 19, 2013 This should do it: HotKeySet("{5}", "_Exit") HotKeySet("{4}", "_Start") Global $iBreak = 0 Func _Start() While 1 If $iBreak = 1 Then $iBreak = 0 ExitLoop EndIf Sleep(3000) ConsoleWrite("Loop" & @CRLF) WEnd EndFunc ;==>_Start Func _Exit() $iBreak = 1 ConsoleWrite("Break" & @CRLF) EndFunc ;==>_Exit While 1 Sleep(1000) WEnd Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 19, 2013 Share Posted July 19, 2013 (edited) Is this for a game?It probably is. I think it so because of the mention of 'fullscreen', and the use of the pixelgetcolor function. But, for the benefit of a doubt, I'll offer this: HotKeySet("4", "_statechange") ;disable HotKeySet("5", "_statechange") ;enable HotKeySet("{ESC}", "_terminate") $variable = 1 While 1 If $variable Then MsgBox(0, "", "enabled", 1) Else MsgBox(0, "", "disabled", 1) EndIf Sleep(500) Wend Func _statechange() Switch @HotKeyPressed Case "4" ;disable $variable = 0 Case "5" ;enable $variable = 1 EndSwitch EndFunc Func _terminate() Exit EndFuncedit: I just noticed that I got the enable and disable HotKey's reversed. Not really a problem though.. Edited July 19, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
FrequentUser Posted July 20, 2013 Author Share Posted July 20, 2013 I need some help somdcomputerguy, The disable function is not really working out for me, due to the fact that I dont think I'm placing the code in correctly This is what I god atm HotKeySet("5", "_statechange") ;disable HotKeySet("4", "_statechange") ;enable $variable = 1 While 1 If $variable Then $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) If $color = 16711680 Or $color = 16646144 Then MouseClick ("middle") Sleep(10) Endif Else (Dont Really know what to do here. Sorry got a little Lost.) Wend Func _statechange() Switch @HotKeyPressed Case "5" ;disable $variable = 0 Case "4" ;enable $variable = 1 EndSwitch EndFunc Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 20, 2013 Share Posted July 20, 2013 (edited) I corrected the code somewhat, I also deleted the Else part, as it's not really needed in this case I think. Try this out and see if it works for you. Remember, if only one thing is executed in an If loop, you can do that right after the Then, and you don't need an EndIf.HotKeySet("5", "_statechange") ;disable HotKeySet("4", "_statechange") ;enable $variable = 1 While 1 If $variable Then $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) If $color = 16711680 Or $color = 16646144 Then MouseClick ("middle") EndIf Sleep(10) Wend Func _statechange() Switch @HotKeyPressed Case "5" ;disable $variable = 0 Case "4" ;enable $variable = 1 EndSwitch EndFunc Edited July 20, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
FrequentUser Posted July 20, 2013 Author Share Posted July 20, 2013 Still didnt work :/, it's just not disabling the function $color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) If $color = 16711680 Or $color = 16646144 Then MouseClick ("middle") EndIf Sleep(10) And it keeps triggering it. Note that I am pressing other buttons after pressing 5. Kinda stumped in figuring this out Link to comment Share on other sites More sharing options...
Developers Jos Posted July 20, 2013 Developers Share Posted July 20, 2013 (edited) Does it work when you just run the script without opening up your full screen app? If so, then it is likely the your full screen app "eats" all keyboard actions. Edited July 20, 2013 by Jos 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...
somdcomputerguy Posted July 20, 2013 Share Posted July 20, 2013 (edited) Does it work when you just run the script without opening up your full screen app?If so, then it is likely the your full screen app "eats" all keyboard actions.True. See, this works as expected:HotKeySet("5", "_statechange") ;disable HotKeySet("4", "_statechange") ;enable $variable = 1 While 1 If $variable Then ;$color = PixelGetColor(@DesktopWidth / 2, @DesktopHeight / 2) ;If $color = 16711680 Or $color = 16646144 Then MouseClick ("middle") MsgBox(0, "", "enabled", 1) EndIf Sleep(10) Wend Func _statechange() Switch @HotKeyPressed Case "5" ;disable $variable = 0 Case "4" ;enable $variable = 1 EndSwitch EndFunc Edited July 20, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
FrequentUser Posted July 20, 2013 Author Share Posted July 20, 2013 Doubt there is a function in game that blocks keyboard functions due to the fact that I have used a similar script with "AC Tool". However AC tool is detected as a "Advantageous Program" hence blocked. Hence the alternation to AutoIt. There must be a way. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 20, 2013 Share Posted July 20, 2013 This is for a game? You've just made several people very pissed I'm sure. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
FrequentUser Posted July 21, 2013 Author Share Posted July 21, 2013 Lol yes it is BrewMan Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 21, 2013 Share Posted July 21, 2013 I highly figured it was for a game, but.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 21, 2013 Moderators Share Posted July 21, 2013 FrequentUser,Please read the Forum rules (there is also a link at bottom right of each page)before you post again. Take particular note of the bit about not discussing game automation - then you will understand why you will get no more help and this thread will now be locked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts