Zohar Posted April 7, 2009 Share Posted April 7, 2009 (edited) HelloI would like to to this:I would like to make a small script, that Captures F1(for example) when I am in Application 1, and handle it somehow,but in all other applications, the script will ignore it and pass it to whatever application that I am working on.Opt("MustDeclareVars",1) HotKeySet("{F1}" ,"Handler") Func Handler() If WinGetTitle("")="SOME APPLICATION" Then MsgBox(0,"","F1 was Handled.") Else ControlSend("","","",@HotKeyPressed) EndIf EndFunc While 1 Sleep(100) WEndnow,my problem is in the "Passing the Key to other applications" part.I used ControlSend("","","",@HotKeyPressed), but I am not sure it works very well.for example, open Paint.exe and try itthe script tries to pass it to current application(paint), but the help window is not opened.If you stop the script and then press F1 in paint, the help window will open, as should.what should I do?any other line instead of ControlSend("","","",@HotKeyPressed)?or maybe there's even a better way,for example, instead of capturing and then passing it, maybe another way that doesn't capture it in the "other" applications?Thank you Edited April 7, 2009 by Zohar Link to comment Share on other sites More sharing options...
LiveOnTheFly Posted April 7, 2009 Share Posted April 7, 2009 lookup WinActive and _IsPressed in the helpfile Link to comment Share on other sites More sharing options...
Zohar Posted April 7, 2009 Author Share Posted April 7, 2009 Thank you anyone has other options? Link to comment Share on other sites More sharing options...
Authenticity Posted April 7, 2009 Share Posted April 7, 2009 Opt("MustDeclareVars",1) HotKeySet("{F1}" ,"Handler") Func Handler() If WinGetTitle("[ACTIVE]") = "SOME APPLICATION" Then MsgBox(0,"","F1 was Handled.") Else HotKeySet("{F1}") Send("{F1}") HotKeySet("{F1}" ,"Handler") EndIf EndFunc While 1 Sleep(100) WEnd Link to comment Share on other sites More sharing options...
Bert Posted April 7, 2009 Share Posted April 7, 2009 (edited) Try this in managing when a window is active or not. This is what I use to handle hotsetkeys on certain windows only. : HotKeySet("{F2}", "HotKeyFunc") HotKeySet("{ESC}", "HotKeyFunc") While 1 Sleep(100) ;idle around ; Script part WEnd Func HotKeyFunc() If WinActive("") Then; Set the window Switch @HotKeyPressed Case "{F2}" ;;; Case "{ESC}" Exit EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf EndFunc Edited April 7, 2009 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Zohar Posted April 7, 2009 Author Share Posted April 7, 2009 (edited) Au10TCT and Volly:Thank you very much, it helped!UsingHotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc")Solved the problem.I wish the ControlSend("","","",@HotKeyPressed) one had worked too,since it does not require releasing the HotKey and then reassigning it again.. Edited April 7, 2009 by Zohar 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