asym Posted June 3, 2010 Share Posted June 3, 2010 Ok my idea is to make a script that searches for 1 color in the screen and if it finds that color it will kill/close one process, the code I have made is below but for some reason its not working and When I run it, it immediatly closes HotKeySet("{F9}", "StartScript") $script = False ToolTip("F9 = Start/Stop Script", 0, 0) Func StartScript() If $script = False Then $script = True Else $script = False ToolTip("F9 = Start/Stop Script", 0, 0) EndIf EndFunc ;==>StartScript While $script = True Dim $cordinates = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFFF200) If Not @error Then If ProcessExists("rPE.exe") Then ProcessClose("rPE.exe") EndIf EndIf WEnd If anyone could help me it would be great Link to comment Share on other sites More sharing options...
Shakala Posted June 3, 2010 Share Posted June 3, 2010 (edited) Well, i didnt look at all your code but with a quick glance, you have nothing to keep the bot running. Just add While 1 Sleep(100) wend after your tooltip line ~Shakala Edited June 3, 2010 by Shakala Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 3, 2010 Share Posted June 3, 2010 Hi and Welcome to the forums! Did you really think that through? First you declare @script as False, and then you have a loop that asks it to be True. Thus the loop never runs, and what do you have after it? Nothing. So nothing happens (it exits). I think what you want is closer to: HotKeySet("{F9}", "StartScript") $script = False ToolTip("F9 = Start/Stop Script", 0, 0) Sleep(2000) ;So we have time to read it ToolTip("") ;Remove the ToolTip While 1 Sleep(10) ;We don't want to use up the whole cpu do we? While $script = True Dim $cordinates = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFFF200) If Not @error Then If ProcessExists("rPE.exe") Then ProcessClose("rPE.exe") EndIf EndIf WEnd WEnd Func StartScript() ;functions are normally placed last, make it easier to browse the code If $script = False Then $script = True Else $script = False ToolTip("F9 = Start/Stop Script", 0, 0) Sleep(2000) ToolTip("") EndIf EndFunc ;==>StartScript .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
asym Posted June 3, 2010 Author Share Posted June 3, 2010 The least I can do is thank you for your kindness and for helping me... Im sorry I seem a bit newbie its like my 3rd script in autoit and I couldnt make it work... Yet, I wasnt able to get what was wrong with the code... Could you give me a little tip? And sorry probably the best way to start in these forums would be to introduce myself in other section, ill do that right away 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