Jump to content

Window doesn't accept any AutoIt commands


 Share

Recommended Posts

Hi folks,

Firstly, I have to tell you that I'm far from an expert with AutoIt, even though I've been using it on and off for a couple of years - so you might want to treat me as a relative beginner.

The problem:

I wrote an auto installer for an application and this worked perfectly under XP. I now have to get it to work with Windows 7 and I've hit a brick wall with one particular window. This window appears once the actual install process starts - and so I reckon that it must be a child window. No matter what I try, I can't get this window to respond to any AutoIT commands.

I've attached a screenshot of the parent/child window (it's the topmost window I'm trying to control).

AutoIt Window Info can see the window and the controls and gives me all the information that I need to work with - but it just doesn't respond. Below is a snippet of the code that I'm using.

Func SiteOptionsWindowHandler()
Local $hndl
Local $windowText = "Select the appropriate settings for your site"
Local $listIndex

;wait for the Site Options window
WinWaitActive($LicenceFileWindowName, $windowText)
  WinActivate($LicenceFileWindowName, $windowText)

  ;get the handle of the country combo box
  $hndl = ControlGetHandle($LicenceFileWindowName, $windowText, "[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]")

  ;get index for Western Europe
  $listIndex = _GUICtrlComboBoxEx_FindStringExact($hndl, "Western Europe")

  ;select Western Europe from the combo box
  _GUICtrlComboBoxEx_SetCurSel($hndl, $listIndex)
EndFunc

I hope someone can help, cos I'm pulling my hair out and there's not much left!

Mike

post-65429-0-48977200-1326458404_thumb.p

Link to comment
Share on other sites

I think your problem is related to this two statements:

;wait for the Site Options window
WinWaitActive($LicenceFileWindowName, $windowText)
  WinActivate($LicenceFileWindowName, $windowText)

You wait until the Window is active (WinWaitActive) and then activate this window (WinActivate) - that doesn't make sense. What I see from your screenshot is that the options window isn't active - and therefore WinWaitActive waits forever.

Change this two lines to

;wait for the Site Options window
WinWait($LicenceFileWindowName, $windowText)
  WinActivate($LicenceFileWindowName, $windowText)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Does your script hang (means: it waits forever for a window) or does it finish without doing what you want?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Then you need to do some error checking.

Func SiteOptionsWindowHandler()
    Local $hndl
    Local $windowText = "Select the appropriate settings for your site"
    Local $listIndex, $iResult
    ;wait for the Site Options window
    WinWaitActive($LicenceFileWindowName, $windowText)
    WinActivate($LicenceFileWindowName, $windowText)
    ;get the handle of the country combo box
    $hndl = ControlGetHandle($LicenceFileWindowName, $windowText, "[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]")
    If @error <> 0 Then MsgBox(16, @ScriptName, "ControlGetHandle: @error = " & @error)
    ;get index for Western Europe
    $listIndex = _GUICtrlComboBoxEx_FindStringExact($hndl, "Western Europe")
    MsgBox(16, @ScriptName, "_GUICtrlComboBoxEx_FindStringExact result: " & $listIndex)
    ;select Western Europe from the combo box
    $iResult = _GUICtrlComboBoxEx_SetCurSel($hndl, $listIndex)
    MsgBox(16, @ScriptName, "_GUICtrlComboBoxEx_SetCurSel result: " & $iResult)
EndFunc   ;==>SiteOptionsWindowHandler

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Can't see the screenshot. Save the screenshot to disk and then attach the file to your post.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This means _GUICtrlComboBoxEx_FindStringExact didn't encounter an error. 0 is the zero based index of the matching item.

0 means the first entry in the combo - is this true for your example?

_GUICtrlComboBoxEx_SetCurSel was not successful.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This describes a solution by using _GUICtrlComboBox_SelectString. Maybe this helps.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Just noticed that the GUI you try to automate is "CLASS:WindowsForms10".

AutoIt has some problems automating Windows forms.

Please have a look at this This is just an example as you will find more threads when searching the forum for "WindowsForms10".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I've done a lot of searching on the forum and can still find nothing that helps me. It seems that there's a flaw in AutoIt that needs sorting out (working with .NET forms!). It looks like I'm going to have to look for an alternative to AutoIt, much as I would hate this.

Link to comment
Share on other sites

If you know that 7 is the correct index have you tried to replace _GUICtrlComboBoxEx_SetCurSel($hndl, $listIndex) with _GUICtrlComboBoxEx_SetCurSel($hndl, 7)?

Link to comment
Share on other sites

From the screenshot I would say it's an installer (yeah, I'm a smart guy :))... which on Win7 is most likely been running with Admin privileges.

"A lower privilege process cannot:

[*]SendMessage or PostMessage to higher privilege application windows."

Add #RequireAdmin to the to of your script or if you're using SciTe and are compiling the script add this line to the top of it:

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

Edit:

Upsa, thought your sending the messages (might still be the case in the underlying UDF). Maybe it's also related to the architecture? Is the installer 32bit or 64bit? Try to run the script in line with that.

Edited by KaFu
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...