Firstone Posted August 21, 2009 Posted August 21, 2009 Hi, I'm trying to run 2 identical scripts, both have the same pause hotkey function "Pause". I made a main script which runs these 2 scripts, also with the same hotkey function. Is there a way to make it so all the scripts pause when pause is pressed? I tried using the control send feature, which will send it straight to the script, but i can't find the title or handle of the other 2 scripts. Or if anyone knows another way to get my other scripts paused with one button? Thanks
jvanegmond Posted August 21, 2009 Posted August 21, 2009 Simple solution: Script 1 Hotkey: PAUSE When hotkey pause is pressed, send keys ctrl + pause Script 2 Hotkey: CTRL + PAUSE github.com/jvanegmond
Firstone Posted August 21, 2009 Author Posted August 21, 2009 Yeah I thought about that, but the problem was if I added more identical scripts (Which I intend to do later), I will be using alot of different keys for the pause button, and that will affect other things I do on my PC. Since it wouldn't be using controlsend.
jvanegmond Posted August 21, 2009 Posted August 21, 2009 Then it is important that you find a solution to make the scripts communicate. I believe there are no (or no proper) libraries to do this. Some recommendations: - Use file or registry writing in a fixed location. All other scripts monitor this file or reg value. - Use TCP connections, make scripts connect to eachother. In either case: - Make one script the "boss" (script that is started first) which controls the other scripts. github.com/jvanegmond
Firstone Posted August 21, 2009 Author Posted August 21, 2009 Ahh ok. That stuff is too advance for me. I'll prob just find some keys I won't be using to set as the pause hotkey. Thanks
Jeff West Posted August 21, 2009 Posted August 21, 2009 Wouldn't this work? HotKeySet("{Pause}", "PauseFunc") While 1 ; Program here WEnd Func PauseFunc() HotKeySet("{Pause}") ;Deassign Pause Key Send("{Pause}") ;Send Pause so other programs will be able to respond HotKeySet("{Pause}", "PauseFunc") ;Do your toggle stuff here EndFunc ;==>PauseFunc
omikron48 Posted August 21, 2009 Posted August 21, 2009 Wouldn't that cause a deadlock at some point? Or is the polling delay long enough to let all scripts be able to get the hotkey?
Firstone Posted August 21, 2009 Author Posted August 21, 2009 Not sure if that would work in my case. But anyway my problems been solved now =D Did a wider search and found this topic. http://www.autoitscript.com/forum/index.php?showtopic=85460&st=0&p=612928&hl=hotkey%20for%202%20functions&fromsearch=1&#entry612928 martin suggested to use _IsPressed, and it works nicely for me. I just had to include a adlib function in each of the other scripts.
jvanegmond Posted August 21, 2009 Posted August 21, 2009 Clever thaught Jeff West. However, the problem is that you can't register the hotkeys all at once.I didn't mention the _IsPressed technique because it is not fail-safe. But, it's your call. github.com/jvanegmond
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