Jump to content

Active Install window does not response any "Send" or ControlClick command


Recommended Posts

I'm writing an AutoIt script to install an Intel Threading Blocks software. Although the displayed install window is active, the window does not respond to the "send" command which imitates keyborad action ( or ControlClick command). I did debug it for days and still can not get it to resolve. Can you help me?

Below is my script:

Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"

FileChangeDir("C:VcsourceAutoIT_installsw_install")

Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe" )

Sleep(2000)

sleep(2000)

If WinExists('Intel® Threading Building Blocks 4.0 Update 4 for Windows*') Then

If WinActive("Intel® Threading Building Blocks 4.0 Update 4 for Windows*") Then

Local $title = WinGetTitle("Intel® Threading Building Blocks 4.0 Update 4 for Windows*", "")

WinWaitActive($title)

;ControlClick($title, "", "[CLASS:Button;INSTANCE:4]")

;ControlFocus($title,"Extract", "[CLASS:Button;INSTANCE:4]")

send("{TAP}")

MsgBox(0, "Full title reade was:", $title)

;ControlClick("Intel® Threading Building Blocks 4.0 Update 4 for Windows", "", "[CLASS:Button;INSTANCE:4]")

;MsgBox(0, "New2", "TBB active")

EndIf

EndIf

Edited by newcome
Link to comment
Share on other sites

Two questions:

  • Is the "*" part of the window title "Intel® Threading Building Blocks 4.0 Update 4 for Windows*"? Or is it just a wildcard?
  • send("{TAP}") must be a typo. You want to send "{TAB}"?
Edited by water

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

Maybe force the window to be active, also, else you might skip over the bulk of your code (winactivate)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I would wait for the window to exist, activate it and then click on the button. Use substring matching so you can eliminate the ® character.

Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe")
AutoItSetOption("WinTitleMatchMode", 2) ; Match any substring in the title
WinWait("Threading Building Blocks")
WinActivate("Threading Building Blocks")
ControlClick("Threading Building Blocks", "", "[CLASS:Button;INSTANCE:4]")

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

Thank you very much for all the responses.

Yes. The "*" is part of the Title. "TAP" is a typo and it should be Send("{TAB}".

I followed Water's advice and made the changes to the script (see below). But it still does not work. Do you have any other suggestion?

Opt("wintitlematchmode", 2)

Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"

FileChangeDir("C:VcsourceAutoIT_installsw_install")

Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe" )

Sleep(2000)

WinWait("Threading Building Blocks")

WinActive("Threading Building Blocks")

ControlClick("Threading Building Blocks", "", "[CLASS:Button;INSTANCE:4]")

Send ("{TAB}")

Edited by newcome
Link to comment
Share on other sites

Jdelaney, thank you.

I changed it to: WinActivate("Threading Building Blocks")

It still does not resolve the problem.

When I clicked the button with the mouse or pushed the "Tab" key, the displayed install window responded, but when I used "ControlClick("Threading Building Blocks", "", "[CLASS:Button;INSTANCE:4]")"

or Send("{TAB}") functions, the window did not respond at all.

Is it possible, some window install program just does not respond to any "Send" /ControlClick command?

Edited by newcome
Link to comment
Share on other sites

There are some windows security features...such as, if a windows message apperas stating the app will run as admin. You can turn that off though...also try incluing this at the top of your file:

#RequireAdmin

Also, try running the script through a CMD with Admin rights.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

also, add more debugging, so you know at what step you are failing...do this instead:

$shwndInstall = WinGetHandle("Threading Building Blocks")

If Not ishwnd ( $shwndInstall ) then consolewrite ( "Unable to find the Install window" & @CRLF )

(also, now you have the window handle defined, use that in the functions following)

do the same kind of thing for each step

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Hi Jdelaney,

I tried your suggestions to add debug code (see code below). The window handle exists, but the window just does not respond to any AutoIt keyboard functions or mouse click actions. Do you have any other suggestion?

;#RequireAdmin

Opt("wintitlematchmode", 2)

Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"

FileChangeDir("C:VcsourceAutoIT_installsw_install")

Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe" )

Sleep(2000)

Local $shwndInstall = WinWait("Threading Building Blocks")

If ishwnd ( $shwndInstall ) then

WinActivate("Threading Building Blocks")

$shwndInstall = WinGetHandle("Threading Building Blocks")

If ishwnd ( $shwndInstall ) then

ControlClick($shwndInstall, "", "[CLASS:Button;INSTANCE:4]")

Send ("{TAB}")

Send ("{TAB}")

Else

consolewrite ( "1 Unable to find the Install window" & @CRLF )

EndIf

Else

consolewrite ( "2 Unable to find the Install window " & @CRLF )

EndIf

autoIt_problem.pdf

Edited by newcome
Link to comment
Share on other sites

Please try this code and post the results:

;#RequireAdmin
Opt("wintitlematchmode", 2)
Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"
FileChangeDir("C:VcsourceAutoIT_installsw_install")
Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe")
Sleep(2000)
Local $shwndInstall = WinWait("Threading Building Blocks")
ConsoleWrite("WinWait: " & @error)
If IsHWnd($shwndInstall) Then
    WinActivate("Threading Building Blocks")
    ConsoleWrite("WinActivate: " & @error)
    ControlClick($shwndInstall, "", "[CLASS:Button;INSTANCE:4]")
    ConsoleWrite("ControlClick: " & @error)
    Send("{TAB}")
    Send("{TAB}")
Else
    ConsoleWrite("2 Unable to find the Install window " & @CRLF)
EndIf

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

try this out, for fun

#RequireAdmin
Opt("wintitlematchmode", 2)
Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"
FileChangeDir("C:VcsourceAutoIT_installsw_install")
Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe")
Sleep(2000)
Local $shwndInstall = WinWait("Threading Building Blocks")
$shwndInstall = WinGetHandle("Threading Building Blocks")
If IsHWnd($shwndInstall) Then
 WinActivate($shwndInstall)
 $shwndButton = ControlGetHandle ( $shwndInstall, "", "[CLASS:Button;INSTANCE:4]" )
 
 If IsHWnd ( $shwndButton ) Then
  If ControlClick ( $shwndInstall, "", $shwndButton ) Then
   ConsoleWrite("Able to click button" & @CRLF)
  Else
   ConsoleWrite("NOT able to click button" & @CRLF)
  EndIf
 Else
  ConsoleWrite("Unable to find handle for the button" & @CRLF)
 EndIf
Else
 ConsoleWrite("Unable to find handle for the Install window " & @CRLF)
EndIf
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

How many windows have the same title when the "Extract the product package to folder:" window pops up?

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

Hi Water and Jdelaney,

I tried both of your sugesstions (run your code) and also added a couple of debug lines in it.

It looks like the AutoIt "ControlClick" function returned "1" to successfully excute the command, but the install window did not respond to the "ControlClick" action.

below is the output and code:

Output: +>11:51:26 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3

+>11:51:26 AU3Check ended.rc:0

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "V:Installssetup_installtt.au3"

ControlClidk handle =1

Enable ControlClick on Install window

Enable to find the TAB Install window

+>11:52:19 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 52.648

Code:

;#RequireAdmin

Opt("wintitlematchmode", 2)

Global $cmd = "C:VcsourceAutoIT_installsw_installw_tbb_4.0.4.325.exe"

FileChangeDir("C:VcsourceAutoIT_installsw_install")

Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe" )

Sleep(2000)

Local $shwndInstall = WinWait("Threading Building Blocks")

Send("{TAB}")

Sleep(2000)

;Send("{TAB}")

If ishwnd ( $shwndInstall ) then

WinActivate("Threading Building Blocks")

$shwndInstall = WinGetHandle("Threading Building Blocks")

If ishwnd ( $shwndInstall ) then

Local $clickhwnd = ControlClick($shwndInstall, "", "[CLASS:Button;INSTANCE:4]")

ConsoleWrite ("ControlClidk handle =" &$clickhwnd & @CRLF )

If $clickhwnd <> 0 Then

consolewrite ( "Enable ControlClick on Install window" & @CRLF )

Else

consolewrite ( "Enable ControlClick on Install window Failed" & @CRLF )

EndIf

Send ("{TAB}")

consolewrite ( "Enable to find the TAB Install window" & @CRLF )

Send ("{TAB}")

Else

consolewrite ( "1 Unable to find the Install window" & @CRLF )

EndIf

Else

consolewrite ( "2 Unable to find the Install window " & @CRLF )

EndIf

Edited by newcome
Link to comment
Share on other sites

There is only one window popup with the title of "Intel® Threading Building Blocks 4.0 Update 4 for windows*".

I will deactivate user AccountControl when the install script is done and it will run on deactivated user AccountControl machine.

Link to comment
Share on other sites

Jdelaney,

When I ran the script you suggested, the window did not react with ControlClick action. The output log showed "Able to click button". The log is as follows:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "V:Installssetup_installt3.au3" /UserParams

+>13:52:34 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3

+>13:52:34 AU3Check ended.rc:0

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "V:Installssetup_installt3.au3"

Able to click button

+>13:53:11 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 37.263

Edited by newcome
Link to comment
Share on other sites

Sometimes, for whatever reason, control click & send do not function properly, or may even send the output to the wrong window. Here are some things that you can try that will help you to find out what's going on....

First of all, in the very beginning of the script, call:

Local $hWin = WinGetHandle("Bla bla bla", "")
ConsoleWrite("--> Got the window handle, it is: " & $hWin & " :: @error is: " & @error & @LF)
; Not sure if the syntax of that is correct, but it should be. Anyway, moving on...

THEN

ConsoleWrite("--> ProcessID: " & WinGetProcess($hWin) & @LF)
ConsoleWrite("--> WinTitle: " & WinGetTitle($hWin) & @LF)

Work from there and verify that the window you've got from running that code is the window you're looking for. (Open up task manager, then view, then "Select Columns" and then check "PID")

Compare notes on the title and the PID and see if what the script is grabbing from that title is what you want.

NOW! If all that works and leads you to a solution, great. Otherwise, then you know your problem BEGINS with not working with the right window.

If that doesn't work, then replace:

WinGetTitle("bla bla blah")

With

Sleep(10000) ; 10 secs
; During this period of time, you're going to need to go and open up the program you're trying to interact with and make sure that it is active.
Local $hWin = WinGetHandle("[ACTIVE]")
Local $winSetStateResult = WinSetState($hWin, "", @SW_HIDE)
; It should disappear after calling this... so you'll get some additional feedback that you're working with the window you think you're working with.

By the end of this, you should get some idea of WHY it isn't working correctly. Then you can use the control functions to play with the controls. My favorite control function to use when I'm testing a script is "ControlDisable()"

; Do whatever you need to do to make sure the window is active here. . .
Local $hWin = WinGetHandle("[ACTIVE]") ; or whatever this parameter should be.
; Then
$result = ControlDisable($hWin, "", "[CLASS:Button;Instance:4]") ; or whatever the last parameter should be

ConsoleWrite the results of everything you do, and make sure you can understand the output. Let us know the results...

Edited by elektron
Link to comment
Share on other sites

There is only one window popup with the title of "Intel® Threading Building Blocks 4.0 Update 4 for windows*".

I ask because I tested the script you posted in running Notepad and using WinWait and WinGetHandle and wrote the handle to the console. I got two different values. Then I noticed that I had two instances of Notepad running, therefore two handles.

So maybe you have a "startup" window and a "popup" window with the same title. In this case you might send your keys to the wrong window.

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

Could you please give this example a try and post the displayed array?

;#RequireAdmin
#include <array.au3>
Opt("wintitlematchmode", 2)
Global $cmd = "C:\Vcsource\AutoIT_install\sw_install\w_tbb_4.0.4.325.exe"
FileChangeDir("C:\Vcsource\AutoIT_install\sw_install\")
Run(@ComSpec & ' /c' & "w_tbb_4.0.4.325.exe")
Sleep(2000)
Local $shwndInstall = WinWait("Threading Building Blocks")
ConsoleWrite("WinWait: " & @error)
If IsHWnd($shwndInstall) Then
    Local $aWinList = WinList("Threading Building Blocks")
    _ArrayDisplay($aWinList)
    WinActivate("Threading Building Blocks")
    ConsoleWrite("WinActivate: " & @error)
    ControlClick($shwndInstall, "", "[CLASS:Button;INSTANCE:4]")
    ConsoleWrite("ControlClick: " & @error)
    Send("{TAB}")
    Send("{TAB}")
Else
    ConsoleWrite("2 Unable to find the Install window " & @CRLF)
EndIf

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

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