Jump to content

Can one hotkey use for two scripts?


Recommended Posts

Hi ,

 

I have 2 scripts, test1.au3 and test2.au3,

;; test1.au3

HotKeySet("{F8}", "keypressf8")

while(1)
wend
Func keypressf8()
    MsgBox(0,"", "AAAAAAAAAAAAA")

EndFunc

 

;; test2.au3

HotKeySet("{F8}", "keypressf8")

while(1)
wend
Func keypressf8()
    MsgBox(0,"", "BBBBBBBBBB")

EndFunc

 

I executed the two scripts at once, when I pressed F8, there is only one Msgbox "AAAAAAAAAA" ,  

anyone knows how to let key F8 works for the two scripts at once?

 

Thanks.

Link to comment
Share on other sites

If two AutoIt scripts set the same hotkeys, you should avoid running those scripts simultaneously as the second script cannot capture the hotkey unless the first script terminates or unregisters the key prior to the second script setting the hotkey. If the scripts use GUIs, then consider using GUISetAccelerators as these keys are only active when the parent GUI is active.
(help file)

Link to comment
Share on other sites

you can use _IsPressed(Hex_key) in that case , here is an example : -

First Script

#include <Misc.au3>

$scriptname="test1.au3"

while 1
$key=_IsPressed(77) ;f8 key 
if $key then
    keypressf8()
EndIf
Sleep(1)
wend

func keypressf8()
    MsgBox(0,"","AAAAAAAAAAAAAA")
EndFunc

Second Script

#include <Misc.au3>

$scriptname="test2.au3"

while 1
$key=_IsPressed(77) ;f8 key 
if $key then
    keypressf8()
EndIf
Sleep(1)
wend

func keypressf8()
    MsgBox(0,"","BBBBBBBBBBBB")
EndFunc

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...