scaleman Posted January 13, 2012 Share Posted January 13, 2012 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 Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 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. Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 It completes the script and exits normally Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 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. Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 These are the results: Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 Sorry, I don't think the screenshots worked - if you can't see them, I'll send them another way Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 Just in case you didn't get the test results, I've attached them in an image file. Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 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. Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 I've checked the thread you suggested but I'm afraid it wasn't any help. Link to comment Share on other sites More sharing options...
water Posted January 13, 2012 Share Posted January 13, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
scaleman Posted January 13, 2012 Author Share Posted January 13, 2012 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 More sharing options...
LarsJ Posted January 13, 2012 Share Posted January 13, 2012 If you know that 7 is the correct index have you tried to replace _GUICtrlComboBoxEx_SetCurSel($hndl, $listIndex) with _GUICtrlComboBoxEx_SetCurSel($hndl, 7)? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
scaleman Posted January 15, 2012 Author Share Posted January 15, 2012 Hi - sorry about the delay in responding. That's one of the first things I trried - no joy I'm afraid! Link to comment Share on other sites More sharing options...
KaFu Posted January 15, 2012 Share Posted January 15, 2012 (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 January 15, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now