darkxraver Posted May 28, 2011 Share Posted May 28, 2011 hey, i have a pretty simple script expandcollapse popupGlobal $UnPaused HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") While 1 Sleep(100) ToolTip("Script PAUSED [PAGE DN] To Start",415,695) WEnd Func TogglePause() AdlibRegister("chk_return") $UnPaused = NOT $UnPaused While $UnPaused ToolTip("1",515,595) Sleep(3000) ToolTip("2",515,595) Sleep(3000) ToolTip("3",515,595) Sleep(3000) ToolTip("4",515,595) Sleep(3000) ToolTip("5",515,595) Sleep(3000) WEnd AdlibUnRegister() While 1 Sleep(100) ToolTip("Script PAUSED [PAGE DN] To Start",415,695) WEnd EndFunc Func chk_return() Do $var = PixelGetColor( 1883, 788 ) If $var = 0x000000 Then ExitLoop EndIf ToolTip("Pixel Found - Paused Script",415,695) Until $var = 0x000000 EndFunc Func Terminate() Exit 0 EndFunc what is does is.. it starts to count up from 1 to 5 via tooltip then loops and starts from 1 again. While it does that it checks for a black and white pixel. If the pixel is black, it loops and loops, but if the pixel now gets white, it will pause the script until it finds the black pixel again. Everything how i want it except the pausing part. Right now what it does is for example if it counts to 3 and it finds the white pixel it stops at 3 if it then finds the black pixel it starts from where it left off (3) and counts to 5, restarts at 1 and loops it. What i would like it to do is - Count up to example 4 when it finds the white pixel it should pause the script (like it does) then when it finds the black pixel again it should restart the script at 1 and NOT continue from where it left off (in this case 4). It probably is just 1 simple code but i cant figure it out and i cant find anything about it on the forums and dont know what to look for :/ i already tried for hours to get the loop part to work and i dont want to spend another few hours on it just because of 1 simple code. I would really appreciate it if someone could help me out! Ty Link to comment Share on other sites More sharing options...
martin Posted May 28, 2011 Share Posted May 28, 2011 hey, i have a pretty simple script expandcollapse popupGlobal $UnPaused HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") While 1 Sleep(100) ToolTip("Script PAUSED [PAGE DN] To Start",415,695) WEnd Func TogglePause() AdlibRegister("chk_return") $UnPaused = NOT $UnPaused While $UnPaused ToolTip("1",515,595) Sleep(3000) ToolTip("2",515,595) Sleep(3000) ToolTip("3",515,595) Sleep(3000) ToolTip("4",515,595) Sleep(3000) ToolTip("5",515,595) Sleep(3000) WEnd AdlibUnRegister() While 1 Sleep(100) ToolTip("Script PAUSED [PAGE DN] To Start",415,695) WEnd EndFunc Func chk_return() Do $var = PixelGetColor( 1883, 788 ) If $var = 0x000000 Then ExitLoop EndIf ToolTip("Pixel Found - Paused Script",415,695) Until $var = 0x000000 EndFunc Func Terminate() Exit 0 EndFunc what is does is.. it starts to count up from 1 to 5 via tooltip then loops and starts from 1 again. While it does that it checks for a black and white pixel. If the pixel is black, it loops and loops, but if the pixel now gets white, it will pause the script until it finds the black pixel again. Everything how i want it except the pausing part. Right now what it does is for example if it counts to 3 and it finds the white pixel it stops at 3 if it then finds the black pixel it starts from where it left off (3) and counts to 5, restarts at 1 and loops it. What i would like it to do is - Count up to example 4 when it finds the white pixel it should pause the script (like it does) then when it finds the black pixel again it should restart the script at 1 and NOT continue from where it left off (in this case 4). It probably is just 1 simple code but i cant figure it out and i cant find anything about it on the forums and dont know what to look for :/ i already tried for hours to get the loop part to work and i dont want to spend another few hours on it just because of 1 simple code. I would really appreciate it if someone could help me out! Ty I think it's better to simplify things so that th edifferent requirements are separated out into different functions. Having a function called by an Adlib gets too tricky when that function switches on another Adlib. Also, just a personnal preferance, I get easily confused by double negatives, so instead of know ing that something is not unpaused I prefer to think of it as paused. Anyway, this is the way I would approach it and I hope I understood what you wanted. expandcollapse popupGlobal $Paused = False HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") $Tip = 5 AdlibRegister("chk_return") AdlibRegister("SetTip", 300) $FoundTipped = False While 1 Sleep(100) If $Paused And Not $FoundTipped Then ToolTip("Pixel Found - Paused Script", 415, 695) Sleep(2000) ToolTip("Script PAUSED [PAGE DN] To Start", 415, 695) $FoundTipped = True EndIf WEnd Func SetTip() If $Paused Then Return $Tip += 1 If $Tip > 5 Then $Tip = 1 ToolTip($Tip, 515, 595) EndFunc ;==>SetTip Func TogglePause() $Paused = Not $Paused EndFunc ;==>TogglePause Func chk_return() if $paused then return $var = PixelGetColor(1883, 788) If $var = 0xFFFFFF Then $Paused = True $FoundTipped = false $Tip = 5;so that it will start at 1 next time EndIf EndFunc ;==>chk_return Func Terminate() Exit 0 EndFunc ;==>Terminate Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
darkxraver Posted May 28, 2011 Author Share Posted May 28, 2011 (edited) I think it's better to simplify things so that th edifferent requirements are separated out into different functions. Having a function called by an Adlib gets too tricky when that function switches on another Adlib. Also, just a personnal preferance, I get easily confused by double negatives, so instead of know ing that something is not unpaused I prefer to think of it as paused. Anyway, this is the way I would approach it and I hope I understood what you wanted. expandcollapse popupGlobal $Paused = False HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") $Tip = 5 AdlibRegister("chk_return") AdlibRegister("SetTip", 300) $FoundTipped = False While 1 Sleep(100) If $Paused And Not $FoundTipped Then ToolTip("Pixel Found - Paused Script", 415, 695) Sleep(2000) ToolTip("Script PAUSED [PAGE DN] To Start", 415, 695) $FoundTipped = True EndIf WEnd Func SetTip() If $Paused Then Return $Tip += 1 If $Tip > 5 Then $Tip = 1 ToolTip($Tip, 515, 595) EndFunc ;==>SetTip Func TogglePause() $Paused = Not $Paused EndFunc ;==>TogglePause Func chk_return() if $paused then return $var = PixelGetColor(1883, 788) If $var = 0xFFFFFF Then $Paused = True $FoundTipped = false $Tip = 5;so that it will start at 1 next time EndIf EndFunc ;==>chk_return Func Terminate() Exit 0 EndFunc ;==>Terminate Thanks for the fast answer and tips. The script of yours is not quite how i wanted it but its pretty close. After it finds the white pixel it pauses like it should then when it finds the black pixel again it does reset/restart from 1 but i have to press the "page down" button again to start the script - which i dont want. Would like it to restart/reset automatic when it finds the black pixel. Hope you understand what i mean Ty Edit: Nervermind i just had to remove $Pause = True at the Func chk_return() its now working like i wanted thanks alot Edited May 28, 2011 by darkxraver Link to comment Share on other sites More sharing options...
martin Posted May 28, 2011 Share Posted May 28, 2011 Thanks for the fast answer and tips. The script of yours is not quite how i wanted it but its pretty close. After it finds the white pixel it pauses like it should then when it finds the black pixel again it does reset/restart from 1 but i have to press the "page down" button again to start the script - which i dont want. Would like it to restart/reset automatic when it finds the black pixel. Hope you understand what i mean Ty Not sure. So it searches for the white and when it finds it it sets the tooltip to "Paused". Even though it's paused it continues checking and when it finds a black pixel it sets the tooltip to a number from 1 to 5 changing every 300mS. So what's the PgDn for? And what does paused mean? Here's an attempt expandcollapse popupGlobal $Paused = False HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") $Tip = 5 AdlibRegister("chk_return") AdlibRegister("SetTip", 300) $FoundTipped = False $SearchFor = 0;or whatever colour it should look for While 1 Sleep(100) If $Paused And Not $FoundTipped Then ToolTip("Pixel Found - Paused Script", 415, 695) Sleep(2000) ToolTip("Script PAUSED [PAGE DN] To Start", 415, 695) $FoundTipped = True EndIf WEnd Func SetTip() If $Paused Then Return $Tip += 1 If $Tip > 5 Then $Tip = 1 ToolTip($Tip, 515, 595) EndFunc ;==>SetTip Func TogglePause() $Paused = Not $Paused EndFunc ;==>TogglePause Func chk_return() ;if $paused then return $var = PixelGetColor(1883, 788) If $var = $SearchFor Then $Paused = ($searchfor = 0xFFFFFF) $Searchfor = 0xFFFFFF - $searchfor ;toggle between 0 and 0xffffff if $paused then $FoundTipped = false $Tip = 5;so that it will start at 1 next time EndIf EndFunc ;==>chk_return Func Terminate() Exit 0 EndFunc ;==>Terminate Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
darkxraver Posted May 28, 2011 Author Share Posted May 28, 2011 Not sure. So it searches for the white and when it finds it it sets the tooltip to "Paused". Even though it's paused it continues checking and when it finds a black pixel it sets the tooltip to a number from 1 to 5 changing every 300mS. So what's the PgDn for? And what does paused mean? Here's an attempt expandcollapse popupGlobal $Paused = False HotKeySet("{PGDN}", "TogglePause") HotKeySet("{END}", "Terminate") $Tip = 5 AdlibRegister("chk_return") AdlibRegister("SetTip", 300) $FoundTipped = False $SearchFor = 0;or whatever colour it should look for While 1 Sleep(100) If $Paused And Not $FoundTipped Then ToolTip("Pixel Found - Paused Script", 415, 695) Sleep(2000) ToolTip("Script PAUSED [PAGE DN] To Start", 415, 695) $FoundTipped = True EndIf WEnd Func SetTip() If $Paused Then Return $Tip += 1 If $Tip > 5 Then $Tip = 1 ToolTip($Tip, 515, 595) EndFunc ;==>SetTip Func TogglePause() $Paused = Not $Paused EndFunc ;==>TogglePause Func chk_return() ;if $paused then return $var = PixelGetColor(1883, 788) If $var = $SearchFor Then $Paused = ($searchfor = 0xFFFFFF) $Searchfor = 0xFFFFFF - $searchfor ;toggle between 0 and 0xffffff if $paused then $FoundTipped = false $Tip = 5;so that it will start at 1 next time EndIf EndFunc ;==>chk_return Func Terminate() Exit 0 EndFunc ;==>Terminate This is pretty much it except that it seems like the tooltip is flickering when going from paused to reset or vice versa. Dont know if you saw my edit but on your first script i just had to remove the $Pause = True at the Func chk_return() Doing it this way the tooltip wont flicker. But this is actually just a test script for me to understand and test it out. I was going to copy the code that resets the script to 1 into my actual script but now i dont know what and where x: The real script i wanted to use the reset on is this one.. btw i got this one of a forum so there might be some mistakes expandcollapse popupOpt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Global $boatbot HotKeySet("{HOME}", "start") HotKeySet("{END}", "stop") While 1 sleep ( 1 ) WEnd ; -------- Functions ------------------- Func start() $boatbot = Not $boatbot While $boatbot _WinWaitActivate("Vindictus","") ; Clicks START to launch mission MouseClick("left",103,942,1) ; Clicks START to launch mission sleep(500) ; Makes game 3x faster // host_timescale 3 Send("{NUMPAD6}") ; Loading Screen // Boat -> 1st Level Sleep(13000) ; Default 13000 ; Change Level Send("{NUMPADSUB}") ; Loading Screen // 1st Level -> Boss Sleep(7000) ; Default: 7000 ; Set Subweapon to 999 Sticky Bombs Send("{0}") ; Makes game 3x faster // host_timescale 3 Send("{NUMPAD6}") ; Transform to Dark Knight / Paladin send("{F6}") ; F6 = DK // F7 = Pala sleep(500) ; Move forward for 5 seconds to trigger cutscene Send("{w down}") Sleep(5000) Send("{w up}") ; Freeze Mobs // ai_reaction_delay_idle 99999 / ai_reaction_delay_alert 99999 send("{NUMPAD0}") ; Boss Cutscene Sleep(4500) ; Default 4500 // 4500-5000 ; Get out Sticky Bomb Send("f") Sleep(300) ; Throw Sticky Bomb Send("E") ; Wait Time till next Action Sleep(1000) ; default 1000 // 500-1500 ; Set Subweapon to 999 Fine Bomb Send("{7}") Sleep(500) ; Get out first Fine Bomb Send("f") Sleep(1200) ; default 1200 ; Throw first Fine Bomb Send("E") Sleep(1000) ; default 1000 ; Get out second Fine Bomb Send("f") Sleep(1200) ; default 1000 ; Throw second Fine Bomb Send("E") ; Time until Mission Successful Menu shows up Sleep(71000) ; Default 71000 // 71000-80000 ; First try - Clicks REPLAY on Mission Successful Menu MouseClick("left",198,709,1) sleep(3000) ; Second try - Clicks REPLAY on Mission Successful Menu MouseClick("left",198,709,1) ; Time to port back to boat and repeat script Sleep(9000) ; Default 12000 // 12000-20000 WEnd EndFunc Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Func stop() Exit EndFunc ;==>stop Basically what this does is start a boat for a game and auto kills the boss, returns back to the boat starts it again and so on. I was going to add a pixelcheck in case it throws me out of the boat because of lag/bug. A pixelcheck so that it knows if im still on the boat or not and if not then pause the script until im in the boat again and if im in again reset the script and start from the beginning by clicking start mission (if im not in the boat the script should just stay paused till i get back on the pc). I dont know if you understand what my real goal is if not then its ok. The only thing what im looking for here is a command that i can put after it gets the pixel to reset/restart the script from the beginning and not from the middle or end. Something like if pixel = white (not in boat) then pause script until im at my pc or pixel = black then reset script and start from beginning may sound confusing but is actually pretty simple if you know whats going on Link to comment Share on other sites More sharing options...
martin Posted May 28, 2011 Share Posted May 28, 2011 Maybe you should read the forum rules. [link]http://www.autoitscript.com/forum/forum-2/announcement-13-forum-rules/[/link] Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts