Jump to content
Sign in to follow this  
Traddles

passing hotkeys BACK to windows

Recommended Posts

Traddles

Hi, I have a program which sets a hotkey... well let me just show you an example of what I want to do:

HotKeySet("^!r", "MyFunction")

while (true)

sleep(100) ; do nothing

wend

func MyFunction()

if (WinActive("Notepad") then

; do some nifty stuff

else

; can I just pass on the "^!r" to whatever window DOES have focus?

endif

endFunc

I've tried just putting "Send("^!r")" in the else statement but that does NOT work. it just sets up a recursive loop that drives my cpu up to 100% very quickly. So, do you guys know of anyway to pass on a hotkey if I change my mind about captureing it like this?

Share this post


Link to post
Share on other sites
FiNAlzFiNAle

I think what you want is this :

CODE
While 1

If WinActive ("Notepad") Then

HotKeySet ("^!r", "NotepadFunction") ; set the HotKey for NotepadFunction

Else

HotKeySet ("^!r") ; release the HotKey

EndIf

WEnd

Func NotepadFunction()

; do your nifty stuff here

EndFunc

Share this post


Link to post
Share on other sites
Shevilie

This should do the trick.. You have to unset the hotkey before Send or else it will launch the function again in an endless loop :whistle:

HotKeySet("^!r", "MyFunction")

while (true)
    sleep(100) ; do nothing
wend

func MyFunction()
    if (WinActive("Notepad") then
        ; do some nifty stuff
    else
        HotKeySet("^!r")
        Send("^!r")
        HotKeySet("^!r", "MyFunction")
    endif
endFunc
Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
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
Sign in to follow this  

×