Jump to content

Script freezing - not recognizing window


 Share

Recommended Posts

Hi,

first attempt at script to install software. i can get past the 1st window ok but no matter what option i use, be it mouseclick, controlclick, send function, nothing progresses past the second window.

I have tried various forms of trying to recognise the window but have been unable to progress. I dont know if it because of brackets in the title but trying to select active window, or doing partial title doesnt resolve

Run(@ScriptDir & 'APP13001-154-corporate.exe')
AutoItSetOption('WinTitleMatchMode', 1)
AutoItSetOption('MouseCoordMode', 0)
 
 
WinWait('Open File - Security Warning')
ControlClick('Open File - Security Warning', '', 'Button1')
sleep(300)
WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
 

 

 

>>>> Window <<<<
Title: Asta Powerproject 13.0.01 Corporate (build 154)
Class: #32770
Position: 696, 324
Size: 527, 392
Style: 0x94CA08C4
ExStyle: 0x00010101
Handle: 0x0000000000261AFC
 
>>>> Control <<<<
Class: Button
Instance: 2
ClassnameNN: Button2
Name:
Advanced (Class): [CLASS:Button; INSTANCE:2]
ID: 1
Text: Install
Position: 317, 336
Size: 90, 23
ControlClick Coords: 18, 17
Style: 0x50010000
ExStyle: 0x00000004
Handle: 0x00000000001C1E06
 
>>>> Mouse <<<<
Position: 338, 378
Cursor ID: 0
Color: 0xD2D2D2
 
>>>> StatusBar <<<<
 
>>>> ToolsBar <<<<
 
>>>> Visible Text <<<<
&Destination folder
C:APPInstallFiles
C:APPInstallFiles
Bro&wse...
Installation progress
Install
Cancel
 
 
>>>> Hidden Text <<<<
 
Link to comment
Share on other sites

Have you tried Class, ClassNN, or ID by chance?

EDIT: Welcome to the AutoIt forum jh212! :D

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Thanks for the reply and welcome, Have tried

WinActivate('[CLASS: #32770]', '')
Send ('{ENTER}')
-------------------------------------------------------------------------------------------------------------------
WinWait('[CLASS: #32770]', '')
ControlClick('[CLASS: #32770]', '', '[CLASS:Button; INSTANCE:2]')

-----------------------------------------------------------------------------------------------------------------------

Local $hWND = WinWait('[CLASS: #32770]', '')
WinActive($hWnd, '')
ControlClick($hWnd, '', '[CLASS:Button; INSTANCE:2]')
------------------------------------------------------------------------------------------------------------------
WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
ControlClick('[CLASS:Button; INSTANCE:2]', '', 'Button2')

-----------------------------------------------------------------------------------------------------------------------

WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
 
It's hard to know whether it is not recognising the window or if it is failing at clicking the button
Link to comment
Share on other sites

If it is the failing to recognize the window, then the Win functions would be returning a 0, which you can check by checking the return values on your functions with MsgBox or ConsoleWrite.

If it is the button click that isn't recognized, then the Control functions would return a 0.

Like so:

Local $act1, $act2, $wait1, $wait2, $wait3, $wait4, $cclick1, $cclick2, $cclick3, $cclick4

$act1 = WinActivate('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Found the window?" & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
Send('{ENTER}')
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait1 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
$cclick1 = ControlClick('[CLASS: #32770]', '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no" & @CRLF & $cclick1)
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait2 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait2)
$act2 = WinActive($wait2, '')
MsgBox(0, "ACT", "Waited till the window is active." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act2)
$cclick2 = ControlClick($hWnd, '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no (2nd)" & @CRLF & $cclick2)
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait3 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait3)
$cclick3 = ControlClick('[CLASS:Button; INSTANCE:2]', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (3rd)" & @CRLF & $cclick3)
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait4 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait4)
$cclick4 = ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (4th)" & @CRLF & $cclick4) 

EDIT: Also, you can use the code syntax highlighting like I have above using the blue A on the toolbar. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Thanks, doesnt show any message box, added #requireadmin. Full script below

Global $sAdminUser = "************"
Global $sAdminPassword = "*************"
Global $sDomain = "***********"
Global $iLogOnFlag = 0
Global $sParameters = ""
 
;Elevate with the Admin account.
If @UserName <> $sAdminUser And Not IsAdmin() Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = ' "' & @ScriptFullPath & '"'
    EndIf
 
    If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")
    EndIf
EndIf
 
;Run with Admin Token in Windows Vista and Higher.
If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = '"' & @ScriptFullPath & '"'
    EndIf
 
    If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")
   EndIf
EndIf
 
; MsgBox(16, "Test", IsAdmin()) ;Example
#RequireAdmin
Run(@ScriptDir & 'APP13001-154-corporate.exe')
AutoItSetOption('MouseCoordMode', 0)
 
Local $act1, $act2, $wait1, $wait2, $wait3, $wait4, $cclick1, $cclick2, $cclick3, $cclick4
 
WinWait('Open File - Security Warning')
ControlClick('Open File - Security Warning', '', 'Button1')
sleep(300)
;WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
;ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
 
 
$act1 = WinActivate('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Found the window?" & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
Send('{ENTER}')
Link to comment
Share on other sites

Add more debugging like I coded for you. I see you only added 1 message box and all the variables, but have not used them.

EDIT: Also, please use code tags to give your code syntax highlighting. either by [ autoit ] ; code here [ /autoit ] (remove the spaces) or the blue A on the toolbar.

Like so:

Local $test = "test" ; test
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Apologies, amended as below but still no message box. Also tried with another installer for another program but no action after first security window

Global $sAdminUser = "********"
Global $sAdminPassword = "**************"
Global $sDomain = "**********"
Global $iLogOnFlag = 0
Global $sParameters = ""

;Elevate with the Admin account.
If @UserName <> $sAdminUser And Not IsAdmin() Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = ' "' & @ScriptFullPath & '"'
    EndIf

    If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")
    EndIf
EndIf

;Run with Admin Token in Windows Vista and Higher.
If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = '"' & @ScriptFullPath & '"'
    EndIf

    If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")
   EndIf
EndIf

; MsgBox(16, "Test", IsAdmin()) ;Example
#RequireAdmin
Run(@ScriptDir & '\APP13001-154-corporate.exe')
AutoItSetOption('MouseCoordMode', 0)

Local $act1, $act2, $wait1, $wait2, $wait3, $wait4, $cclick1, $cclick2, $cclick3, $cclick4

WinWait('Open File - Security Warning')
ControlClick('Open File - Security Warning', '', 'Button1')
sleep(300)
;WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
;ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')


$act1 = WinActivate('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Found the window?" & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
Send('{ENTER}')
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait1 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
$cclick1 = ControlClick('[CLASS: #32770]', '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no" & @CRLF & $cclick1)
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait2 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait2)
$act2 = WinActive($wait2, '')
MsgBox(0, "ACT", "Waited till the window is active." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act2)
$cclick2 = ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no (2nd)" & @CRLF & $cclick2)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait3 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait3)
$cclick3 = ControlClick('[CLASS:Button; INSTANCE:2]', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (3rd)" & @CRLF & $cclick3)
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait4 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
       "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait4)
$cclick4 = ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (4th)" & @CRLF & $cclick4)
Link to comment
Share on other sites

Stripped it back to get and get the basics working, still getting to second window and stopping. I am domain admin so should need any additional permissions

#RequireAdmin
Run(@ScriptDir & '\APP13001-154-corporate.exe')
AutoItSetOption('MouseCoordMode', 0)

WinWait('Open File - Security Warning')
ControlClick('Open File - Security Warning', '', 'Button1')
sleep(300)

Local $act1, $act2, $wait1, $wait2, $wait3, $wait4, $cclick1, $cclick2, $cclick3, $cclick4
$act1 = WinActivate('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Found the window?" & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
Send('{ENTER}')
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait1 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act1)
$cclick1 = ControlClick('[CLASS: #32770]', '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no" & @CRLF & $cclick1)
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait2 = WinWait('[CLASS: #32770]', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait2)
$act2 = WinActive($wait2, '')
MsgBox(0, "ACT", "Waited till the window is active." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $act2)
$cclick2 = ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', '[CLASS:Button; INSTANCE:2]')
MsgBox(0, "ControlClick", "1 yes, 0 no (2nd)" & @CRLF & $cclick2)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait3 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
        "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait3)
$cclick3 = ControlClick('[CLASS:Button; INSTANCE:2]', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (3rd)" & @CRLF & $cclick3)
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$wait4 = WinWait('Asta Powerproject 13.0.01 Corporate (build 154)', '')
MsgBox(0, "ACT", "Waited till the window exists." & @CRLF & _
       "Handle is yes, 0 is no" & @CRLF & "Val:" & $wait4)
$cclick4 = ControlClick('Asta Powerproject 13.0.01 Corporate (build 154)', '', 'Button2')
MsgBox(0, "ControlClick", "1 yes, 0 no (4th)" & @CRLF & $cclick4)
Link to comment
Share on other sites

The good thing when i add the same problem was to use universal mode in windows tittle match option like this:

Opt("WinTitleMatchMode", 2)

ControlClick('Open File', '', 'Button1')

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Strange, still cant get this to work but have noticed something weird

 

For the basic code below, if i press F5 it immediately opens up the Asta screen (missing the open file warning) and does nothing. If i click cancel on the setup and manually open the setup.exe the script continues and runs through the install fine. Anybody had anything like this before?

 

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Run(@ScriptDir & '\setup.exe')
AutoItSetOption('MouseCoordMode', 0)
Opt("WinTitleMatchMode", 2)

WinWait('Open File - Security Warning')
WinActivate('Open File - Security Warning')
MouseClick('primary', 276, 181, 1, 0)

WinWait('Asta Powerproject 13.0.01 Corporate')
WinActivate('Asta Powerproject 13.0.01 Corporate')
MouseClick('primary', 376, 369, 1, 0)

 

Link to comment
Share on other sites

Strange, still cant get this to work but have noticed something weird

 

For the basic code below, if i press F5 it immediately opens up the Asta screen (missing the open file warning) and does nothing. If i click cancel on the setup and manually open the setup.exe the script continues and runs through the install fine. Anybody had anything like this before?

 

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Run(@ScriptDir & '\setup.exe')
AutoItSetOption('MouseCoordMode', 0)
Opt("WinTitleMatchMode", 2)

WinWait('Open File - Security Warning')
WinActivate('Open File - Security Warning')
MouseClick('primary', 276, 181, 1, 0)

WinWait('Asta Powerproject 13.0.01 Corporate')
WinActivate('Asta Powerproject 13.0.01 Corporate')
MouseClick('primary', 376, 369, 1, 0)

 

​Anybody have any ideas about this?

Link to comment
Share on other sites

  • Developers

Strange, still cant get this to work but have noticed something weird

 

For the basic code below, if i press F5 it immediately opens up the Asta screen (missing the open file warning) and does nothing. If i click cancel on the setup and manually open the setup.exe the script continues and runs through the install fine. Anybody had anything like this before?

 

​It isn't strange that you do not get the UAC prompt when your AutoIt3 script runs the setup as this is already running at Admin level due to the #RequireAdmin statement.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks, although i think the strange part is the script only progresses when i cancel the set up screen and double the setup file manually, the script runs fine from then on

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