Jump to content

Perform action based on window content...


Recommended Posts

So, I've started using AutoIt and am completely amazed at what you can accomplish with this tool...it's nothing short of incredible! Anyway, I've created a script that will launch an installer, then click through all the appropriate buttons, through all the differring windows that appear, through to the end of the installation process. Here's where I'm running into an issue...on rare occassions, I'm running into an issue where the second window in can differ in text content and button placement, but not always. What I need to figure out is how to perform an action based on the title and content of a window. I know how to use the WinWaitActive to wait for the appropriate window to appear, but is there a way I can use that (or another function) to do something based on the window? Perhaps an if/then or something similar? Thanx.

Link to comment
Share on other sites

The possibilities are endless, but your requirements are not totally clear. You can certain make logic choices (if...then...etc) and there are various functions that may provide the information you are looking for. Can you give more detail as to the desired result?

Link to comment
Share on other sites

So, here's the "more detail" portion about what I want to do. The stuff within the curved brackets are what I can't figure out...

Run("app_srvrapp_pathsetup.exe")
If {specific_window_#1_appears} Then
   WinWaitActive("Setup", "There is another process already running...")
   ControlClick("Setup", "OK", "[ID:2]")
   {exit}
ElseIf {specific_window_#2_appears} Then
   WinWaitActive("Driver Installer", "Welcome to the driver installer...")
   ControlClick("Driver Installer", "&Next >", "[ID:1]")
   WinWaitActive("Driver Installer", "Click next to continue...")
   ControlClick("Driver Installer", "&Next >", "[ID:1]")
   WinWaitActive("Driver Installer", "Click finish to complete...")
   ControlClick("Driver Installer", "&Finish", "[ID:6]")
EndIf

Thanx.

Link to comment
Share on other sites

WinGetTitle can be used to accomplish the "specific_window..." task.

If WinGetTitle("desired window title") Then

There is no need to exit from an if statement in AutoIt, unless you desire to end a function, in which case you could use return and the desired return value....but I assume in your case you don't need to so just ignore it.

Link to comment
Share on other sites

  • Moderators

Hi, StMaSi. What is the driver you're trying to install? Many standard drivers come with built-in switches for silent installs. This may take away the headache of trying click through the windows to the end of the install.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Unfortunately, no silent install for this proprietary driver.

For whatever reason, the script doesn't progress past the first window...it just appears to hang. The window is present and active, so I can't understand why this isn't working. Am I missing something?

$var1 = RegRead("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstallS3 USB Installer v1.96.0", "DisplayName")
Run("  app_srvr  app_dir  test  S3  s3_usb_04.01.011  setup_v1_10.exe")  ;<- {spaces for readability}
If $var1 = "S3 USB Installer v1.96.0" Then
     WinWaitActive("S3 USB Installer Setup", "Click Finish to close this wizard.")
     ControlClick("S3 USB Installer Setup", "&Finish", "[ID:1]")
Else
     If WinGetTitle("Setup", "The installation/uninstallation of 'S3 USB Installer' is already running!") Then
         WinWaitActive("Setup", "The installation/uninstallation of 'S3 USB Installer' is already running!")
         ControlClick("Setup", "OK", "[ID:2]")
     ElseIf WinGetTitle("S3 USB Installer Setup", "Please close all open hardware installation wizards before you continue!") Then
         WinWaitActive("S3 USB Installer Setup", "Please close all open hardware installation wizards before you continue!")
         ControlClick("S3 USB Installer Setup", "&Next >", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Setup was completed successfully.")
         ControlClick("S3 USB Installer Setup", "&Next >", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Please disconnect and reconnect the device you want to install and turn it on.")
         ControlClick("S3 USB Installer Setup", "&Finish", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Do you want to exit this wizard now and connect the device later?")
         ControlClick("S3 USB Installer Setup", "&Yes", "[ID:6]")
     ElseIf WinGetTitle("S3 USB Installer Setup", "This wizard will guide you through the installation of S3 USB Installer v1.96.0.") Then
         WinWaitActive("S3 USB Installer Setup", "This wizard will guide you through the installation of S3 USB Installer v1.96.0.")
         ControlClick("S3 USB Installer Setup", "&Next >", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Setup will install S3 USB Installer v1.96.0 in the following folder.")
         ControlClick("S3 USB Installer Setup", "&Install", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Setup was completed successfully.")
         ControlClick("S3 USB Installer Setup", "&Next >", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Please disconnect and reconnect the device you want to install and turn it on.")
         ControlClick("S3 USB Installer Setup", "&Finish", "[ID:1]")
         WinWaitActive("S3 USB Installer Setup", "Do you want to exit this wizard now and connect the device later?")
         ControlClick("S3 USB Installer Setup", "&Yes", "[ID:6]")
     EndIf
EndIf
Edited by StMaSi
Link to comment
Share on other sites

  • Moderators

StMaSi,

Please do not bump your own threads within 24 hours. :naughty:

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Or if not, tough! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

StMaSi,

No problem. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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