diveblock1 Posted June 30, 2019 Share Posted June 30, 2019 Hi, I'm hoping you can help me. Goal Use an alternative to HotKeySet() to pass flags between scripts. HotKeySet() limits full functionality of the Keyboard which is undesirable. What I have been doing I've been using HotKeySet() to successfully pass flags between scripts. In the script below hotkeys, h, k, suspend the loop. expandcollapse popup#include <Misc.au3> Local $hDLL = DllOpen ("user32.dll") ;Declare Variables Global $Paused = 0 Local $i = 0 Local $k = 0 Local $j = 0 Local $v = 0 ;Define HotKeys HotKeySet("{h}", "FSuspend") HotKeySet("{k}", "ASuspend") HotKeySet("{m}", "TogglePause") While 1 ;Always running, 10 ms loops While $j = 0 and $v = 0 ;Run loop if not suspended $h = RedCheck(1403, 1331) ;Get RGB values of pixelb $x = Number($h[3]) $q = Number($h[2]) $e = Number($h[1]) If ($x >= $q) Then ;See if more red than green $i = 1 Endif If ($x >= $e) Then ;See if more red than blue $k = 1 Endif If $i + $k < 2 Then ;If less red than blue or green, wait a bit and send number 4 $i = 1 ;Set interim varibles to 1 because pixel has now changed to red dominant because of sending number 4 $k = 1 Sleep(50) Send ("{4}") While ($i + $k = 2) And $v = 0 ;While pixel has more red than either blue or green, and FSuspend isnt active, run 40 ms loops, delaying further action $h = RedCheck(1042, 1308) ;Get RGB value of pixel every 40ms $x = Number($h[3]) $q = Number($h[2]) $e = Number($h[1]) If ($q >= $x) Then ;See if more green than red $i = 0 Endif If ($e >= $x) Then ;See if more blue than red $k = 0 Endif Sleep (40) Wend Endif Sleep (20) $i = 0 ;Reset interim variables $k = 0 Wend Sleep (10) Wend ;Function to find numerical values of R,G,B Func RedCheck($x, $y) $hex = Hex(PixelGetColor($x, $y), 6) $r = Dec(StringRight($hex, 2)) & "|" $g = Dec(StringMid($hex, 3,2)) & "|" $b = Dec(StringLeft($hex, 2)) Return StringSplit($r & $g & $b, "|") EndFunc ;Suspend loop method 1 Func FSuspend() If $v = 0 Then $v = 1 Else $v = 0 Endif EndFunc ;Suspend loop method 2 Func ASuspend() If $j = 0 Then $j = 1 Else $j = 0 Endif EndFunc ;Pause Script Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc I use another separate script to: Look for an event If event starts send("{h}") Check if the event is ongoing If event ends send("{h}") As a result, the script posted is effectively suspended for the duration of the event. What I have tried I've tried using HotKeySet() with F13-F24 as to not use any mapped keys but HotKeySet() doesn't seem to work with these virtual keys. I can successfully send virtual keys, but not have them register with HotKeySet(). All of the below hasn't worked: HotKeySet("{F13}", "GenericFunction") HotKeySet("{ASC 0x7C}", "GenericFunction") HotKeySet("{ASC 124}", "GenericFunction") HotKeySet(Asc(124), "GenericFunction") Does anyone have any alternatives? Thank you in advance. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 30, 2019 Developers Share Posted June 30, 2019 There are several option to communicate between scripts. Just search for Mailslot or Named pipes or $WM_COPYDATA which all could be used to exchange information between scripts. 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...
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