Jump to content

What if another window takes focus?


 Share

Recommended Posts

Hi,

I am new to AutoIT and I still have lots to learn.

While doing some tutorials, I have come to an issue where another window popped up and the script didn't know what to do. Is there a way to prevent this?

The problem with WinSetOnTop is that the window that is on top is not necessarily active, it just doesn't get graphically overwritten by the window that is active.

If other processes might take focus away, and for more reliable functionality anyway, use the Control* functions, like ControlSend() vice Send(), and ControlClick(), because they specify the window to act on.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks for your quick replies. So, I would be safest to use the "Control" functions in order to avoid other windows stealing focus?

If it wouldn't be a big problem, could someone post some installation script that uses such conrols?

BTW, is there some place that hosts installation scripts for most common applications? I checked out the Script section on this forum but couldn't find much.

Link to comment
Share on other sites

well....It is easier said than done. Have you tried using the macro recorder?

Is this some extra plugin for AutoIT? I didn't see any info on this in the tutorial. Where would I find it?

Send("#r")
WinWait("Run")
Sleep(200)
Run("mspaint")
ToolTip("Wait for it")
Sleep(3000)
ToolTip("")
ControlSetText("Run","","Edit1","")
ControlSend("Run","","Edit1","calc")
ControlClick("Run","","OK")

Cool. Even if another window has focus, your script still works.

Link to comment
Share on other sites

  • Moderators

Is this some extra plugin for AutoIT? I didn't see any info on this in the tutorial. Where would I find it?

Cool. Even if another window has focus, your script still works.

Control* functions generally will work on any windows "controls" in whatever state (Minimized however sometimes won't work).

They are listed under Control* Functions in your index of the help file.

To find the controls, you can use the AutoInfo.exe tool, as you move your mouse over a control, and have the control tab open in the info.exe tool, you'll see the Control ID, ClassNameNN and Instance.

You can use the Control ID itself (sometimes they change though), or the ClassNameNN + Instance in autoit to achieve control manipulation.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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