Sign in to follow this  
Followers 0
de Roode

Gui Control From Keyboard

4 posts in this topic

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

Share this post


Link to post
Share on other sites



Hotkeyset(ok, Enter)

While 1

Wend

Func ok()

Check if window is active

If active Press ok

if not active Send {enter}

EndFunc

Share this post


Link to post
Share on other sites

Func ok()

Check if window is active

If active Press ok

if not active Send {enter}

EndFunc

This 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

EndFunc

Thanks anyway.

B.t.w. Why does the Cancel button work? (seems to generate Exit event)

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  
Followers 0