de Roode Posted May 3, 2006 Share Posted May 3, 2006 I am creating a small script as a frontend for a program. It will ask for a username (GuiCtrlCreateInput), and has a OK and a Cancel button. If OK is pressed it will start the program with the username as parameter, if Cancel is pressed it will just exit.Now what i want: If the program is active i want the Enter key to behave like i pressed the OK button. And the ESC key to behave like i pressed Cancel;The ESC-Cancel part works just by itself (somehow, i don't know why)If i use HotKeySet( "{enter}","Action"), it will direct all enter keypresses to my program. However, I want Enter to work only when my program has focus.How do i do that?Marcel de Roode Link to comment Share on other sites More sharing options...
jvanegmond Posted May 3, 2006 Share Posted May 3, 2006 Hotkeyset(ok, Enter) While 1 Wend Func ok() Check if window is active If active Press ok if not active Send {enter} EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
de Roode Posted May 3, 2006 Author Share Posted May 3, 2006 Func ok() Check if window is active If active Press ok if not active Send {enter}EndFuncThis loops until "max recursion level is reached"I modified it slightly:Func ok() if not WinActive("MyApp") Then HotKeySet( "{enter}") Send("{enter}") HotKeySet( "{enter}","Action") Check if window is active else press ok(somehow) endif EndFuncThanks anyway. B.t.w. Why does the Cancel button work? (seems to generate Exit event) Link to comment Share on other sites More sharing options...
Bert Posted May 3, 2006 Share Posted May 3, 2006 take a look here: http://www.autoitscript.com/forum/index.php?showtopic=23586This will explain how to make buttons active only when a window is active. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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