Jump to content

passing hotkeys BACK to windows


Traddles
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

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...