Sign in to follow this  
Followers 0
scaleman

Window doesn't accept any AutoIt commands

21 posts in this topic

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for the reply - but changing the script in the way you suggested made no difference.

Like I say, the script works well in XP, it's only failed to work since moving to Windows 7.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It completes the script and exits normally

Share this post


Link to post
Share on other sites

Also, just to test that it is seeing the window, I used the return of the WinActivate (the window handle) and displayed it using a splash text window - it was the correct handle.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

These are the results:

Share this post


Link to post
Share on other sites

Sorry, I don't think the screenshots worked - if you can't see them, I'll send them another way

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Just in case you didn't get the test results, I've attached them in an image file.

post-65429-0-90639400-1326464520_thumb.p

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The correct entry would be 7 - so no, it's not the correct index!

I'll have a look at the thread anyway and let you know if it's any help.

Share this post


Link to post
Share on other sites

I've checked the thread you suggested but I'm afraid it wasn't any help.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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)?

Share this post


Link to post
Share on other sites

Hi - sorry about the delay in responding.

That's one of the first things I trried - no joy I'm afraid!

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

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

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