jh212

Script freezing - not recognizing window

18 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

 

Share this post


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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

 

Share this post


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

 

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Thanks, it goes past the open file window and the "Asta Powerproject 13.0.01 Corporate (build 154)" is displayed on screen

Share this post


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

Share this post


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

 

Share this post


Link to post
Share on other sites

I thought I'd try the trial for myself, but that 200 MB it's a 3 hour download here from Oz :/


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


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

Share this post


Link to post
Share on other sites

#16 ·  Posted

Would really like to get this software working as it offers some great opportunities for our department. Is anyone able to offer advice on the above please?

Share this post


Link to post
Share on other sites

#17 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#18 ·  Posted

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

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