Splitz Posted May 8, 2012 Share Posted May 8, 2012 Hello! Is there anyway to make it so that these two scripts can be joined into one and have the functionality of both when i press Ctrl + K ? Example: I press Ctrl+K and it will Pixelsearch the coordinates in Script1 & Script2, upon finding the red color at "398, 937" it will send "1", or if it finds the red color at "441, 940" it will send "2" and then make the beep noise to say its now off. Both scripts work fine on their own, but i need to make a seperate hotkey for the second one, i'd really like it if i can have them both on one hotkey. Thanks! expandcollapse popup;Script1 Global $on=0 HotKeySet("^k", "Alert") While 1 Sleep(100) WEnd Func Alert() if $on=0 Then SoundPlay("E:\Program Files (x86)\Feed\Data\sounds\Alert.wav"); On $on=1 Else Beep(5500, 500) ; Off $on=0 EndIf While $on=1 Sleep(100) PixelSearch(398, 937, 399, 938, 10883584, 1) If Not @error Then ControlSend("May Notes", "", "", "1") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf WEnd EndFunc ;Script2 Global $on=0 HotKeySet("^k", "Alert2") While 1 Sleep(100) WEnd Func Alert2() if $on=0 Then SoundPlay("E:\Program Files (x86)\Feed\Data\sounds\Alert.wav"); On $on=1 Else Beep(5500, 500) ; Off $on=0 EndIf While $on=1 Sleep(100) PixelSearch(441, 940, 442, 941, 11272467, 1) If Not @error Then ControlSend("May Notes", "", "", "2") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
hannes08 Posted May 8, 2012 Share Posted May 8, 2012 HotKeySet("^k", "Alert1and2") HotKeySet("^l", "Alert1") HotKeySet("^m", "Alert2") While 1 Sleep(100) WEnd Func Alert1() ;Do what you need! EndFunc Func Alert2() ;Do what you need! EndFunc Func Alert1and2() Alert1() Alert2() EndFunc Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Blinky Posted May 8, 2012 Share Posted May 8, 2012 put the second pixelsearch and the if error in the loop of the first function Link to comment Share on other sites More sharing options...
Splitz Posted May 8, 2012 Author Share Posted May 8, 2012 Here's what i have so far, but it seems to not be working as planned. Lots of Errors, The individual functions work, but Ctrl+k when pressed, will only scan Alert1's Coordinates first, and THEN Coordinate 2's. Anyway to make Ctrl+K Scan them both, and send "1" Once a change happens at Alert1, and send a "2" once a change happens at Alert2's Coordinates? expandcollapse popupGlobal $on=0 HotKeySet("^k", "Alert1and2") HotKeySet("^l", "Alert1") HotKeySet("^m", "Alert2") While 1 Sleep(100) WEnd Func Alert1() if $on=0 Then SoundPlay("E:\Program Files (x86)\Feed\Data\sounds\Alert.wav"); On $on=1 Else Beep(5500, 500) ; Off $on=0 EndIf While $on=1 Sleep(100) PixelSearch(398, 937, 399, 938, 10883584, 1) If Not @error Then ControlSend("May Notes", "", "", "1") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf WEnd EndFunc Func Alert2() if $on=0 Then SoundPlay("E:\Program Files (x86)\Feed\Data\sounds\Alert.wav"); On $on=1 Else Beep(5500, 500) ; Off $on=0 EndIf While $on=1 Sleep(100) PixelSearch(441, 940, 442, 941, 11272467, 1) If Not @error Then ControlSend("May Notes", "", "", "2") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf WEnd EndFunc Func Alert1and2() Alert1() Alert2() EndFunc Link to comment Share on other sites More sharing options...
Blinky Posted May 8, 2012 Share Posted May 8, 2012 (edited) Global $on=0 HotKeySet("^k", "Alert") While 1 Sleep(100) WEnd Func Alert() if $on=0 Then SoundPlay("E:Program Files (x86)FeedDatasoundsAlert.wav"); On $on=1 Else Beep(5500, 500) ; Off $on=0 EndIf While $on=1 Sleep(100) PixelSearch(398, 937, 399, 938, 10883584, 1) If Not @error Then ControlSend("May Notes", "", "", "1") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf PixelSearch(441, 940, 442, 941, 11272467, 1) If Not @error Then ControlSend("May Notes", "", "", "2") Sleep(100) Beep(5500, 500) ; Off same sound $on=0 EndIf WEnd EndFunc edit: if it finds the first collor it will go off if u whant the script not to stop after it finds a collor just remove the $on=0 from inside the if statement Edited May 8, 2012 by Blinky 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