Jump to content
Sign in to follow this  
Abs777

Need help gaining focus on a window

Recommended Posts

Abs777

I will have a window that I need to gain focus if it doesn't have it and then shut down using a 'ALT+E' keystroke.

What code would I use for this? My window that I want to gain focus has a title bar name "APEX"

Would this work

If WinExists("APEX") then

WinWait("APEX")

WinActivate("APEX")

If WinActive("APEX") then

Send("!E")

Sleep(10000)

Thanks,

ABS

Share this post


Link to post
Share on other sites
FitzChivalry

I will have a window that I need to gain focus if it doesn't have it and then shut down using a 'ALT+E' keystroke.

What code would I use for this? My window that I want to gain focus has a title bar name "APEX"

Would this work

If WinExists("APEX") then

WinWait("APEX")

WinActivate("APEX")

If WinActive("APEX") then

Send("!E")

Sleep(10000)

Thanks,

ABS

Is it giving you any error or anything when you try this? One thing you need to do is make sure to put endif's in your code. Try something like this:

if WinExists("APEX") Then
    WinActivate("APEX")
    sleep(500)
    send("!e")
EndIf

I have it sleep for half a second after activating the window just because sometimes it goes to fast and sends the alt-e before the window actually gets a chance to activate. try it out and see if that works, and let us know if you get any error messages or anything. Good luck!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.