trof Posted July 30, 2016 Share Posted July 30, 2016 Hi I'm trying to automate installation of PowerDirector title templates. The installation routines of these items are very similar: it changes the Title and so I used WinGetTitle("[ACTIVE]") function to bypass this problem. However, I encountered a problem since there is another exception in some installation routine. This exception consists in a further dialog popup. Title of this popup is the same of prior popups but it changes the visible text. So I'm trying to take advantage of this diversity using WinGetText("[ACTIVE]") function, but what I did doesn't work. Here the script expandcollapse popup#RequireAdmin Local $aArray[16] $aArray[0] = "Around the World.exe" $aArray[1] = "Autumn Romance.exe" $aArray[2] = "Baby.exe" $aArray[3] = "Birthday Jolly.exe" $aArray[4] = "Brush.exe" $aArray[5] = "Eternal Love.exe" $aArray[6] = "Green Clover.exe" $aArray[7] = "Interaction.exe" $aArray[8] = "Lovely Day.exe" $aArray[9] = "LowerThird 1.exe" $aArray[10] = "LowerThird 2.exe" $aArray[11] = "Rainbow Delights.exe" $aArray[12] = "Road Trip.exe" $aArray[13] = "True Love.exe" $aArray[14] = "Under the Sea.exe" $aArray[15] = "Vintage Memories.exe" For $vElement In $aArray Run($vElement) WinWait("Seleziona la lingua dell'installazione") WinActivate("Seleziona la lingua dell'installazione") ControlClick("Seleziona la lingua dell'installazione", "", "Button1") WinWait("Installazione di CyberLink", "InstallShield Wizard per CyberLink", 10) Local $sTitle = WinGetTitle("[ACTIVE]") if "Installazione di in corso ..." = $sTitle then WinWait("Installazione di in corso", "InstallShield Wizard per CyberLink") WinActivate("Installazione di in corso", "InstallShield Wizard per CyberLink") ControlClick("Installazione di in corso", "", "Button1") WinWaitActive("Installazione di in corso", "Contratto di Licenza per l'Utente") ControlClick("Installazione di in corso", "", "Button2") Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. if $aSplit[$i] = "Informazioni sul cliente" then WinWaitActive("Installazione di in corso", "Informazioni sul cliente") ControlClick("Installazione di in corso", "", "Button2") WinWaitActive("Installazione di in corso", "Cartella di destinazione") ControlClick("Installazione di in corso", "", "Button1") WinWaitActive("Installazione di in corso", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di in corso", "", "Button2") WinWaitActive("Installazione di in corso", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di in corso", "", "Button4") else WinWaitActive("Installazione di in corso", "Cartella di destinazione") ControlClick("Installazione di in corso", "", "Button1") WinWaitActive("Installazione di in corso", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di in corso", "", "Button2") WinWaitActive("Installazione di in corso", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di in corso", "", "Button4") EndIf Next Else WinWait("Installazione di CyberLink", "InstallShield Wizard per CyberLink") WinActivate("Installazione di CyberLink", "InstallShield Wizard per CyberLink") ControlClick("Installazione di CyberLink", "", "Button1") WinWaitActive("Installazione di CyberLink", "Contratto di Licenza per l'Utente") ControlClick("Installazione di CyberLink", "", "Button2") Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. if $aSplit[$i] = "Informazioni sul cliente" then WinWaitActive("Installazione di CyberLink", "Informazioni sul cliente") ControlClick("Installazione di CyberLink", "", "Button2") WinWaitActive("Installazione di CyberLink", "Cartella di destinazione") ControlClick("Installazione di CyberLink", "", "Button1") WinWaitActive("Installazione di CyberLink", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di CyberLink", "", "Button2") WinWaitActive("Installazione di CyberLink", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di CyberLink", "", "Button4") else WinWaitActive("Installazione di CyberLink", "Cartella di destinazione") ControlClick("Installazione di CyberLink", "", "Button1") WinWaitActive("Installazione di CyberLink", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di CyberLink", "", "Button2") WinWaitActive("Installazione di CyberLink", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di CyberLink", "", "Button4") EndIf Next EndIf Next Au3Info.exe reports this visible text Digitare il proprio nome e il nome della propria società. &Nome utente: Ottavio Nome &società: Company < &Indietro &Avanti > Annulla Informazioni sul cliente Digitare i propri dati. Link to comment Share on other sites More sharing options...
kcvinu Posted July 30, 2016 Share Posted July 30, 2016 Read help file for ControlClick function. It needs the button1's Control ID Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 30, 2016 Author Share Posted July 30, 2016 (edited) 2 hours ago, kcvinu said: Read help file for ControlClick function. It needs the button1's Control ID No problem with Button1, Button2 etc in ControlClick. The script doesn't work after Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') For $i = 1 To $aSplit[0] if $aSplit[$i] = "Informazioni sul cliente" then Edited July 30, 2016 by trof Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 (edited) Just try @CRLF instead of '\n' And you need to write proper error checking code after WinGetText to catch if any error occurred. Edited July 31, 2016 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 I tried @CRLF and it doesn't work. I don't know how to write proper error checking code Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 Here is the model If @error Then ConsoleWrite(@error & @CRLF) ; This is for knowing error code If @error Then ConsoleWrite(@extended & @CRLF) ; this is for knowing extended error code Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 I tried Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, @CRLF) For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. if $aSplit[$i] = "Informazioni sul cliente" then If @error Then ConsoleWrite(@error & @CRLF) ; This is for knowing error code If @error Then ConsoleWrite(@extended & @CRLF) ; this is for knowing extended error code and Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, @CRLF) For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. If @error Then ConsoleWrite(@error & @CRLF) ; This is for knowing error code If @error Then ConsoleWrite(@extended & @CRLF) ; this is for knowing extended error code if $aSplit[$i] = "Informazioni sul cliente" then no error message Link to comment Share on other sites More sharing options...
JohnOne Posted July 31, 2016 Share Posted July 31, 2016 Try if StringStripWS($aSplit[$i], 3) = "Informazioni sul cliente" then AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 No luck, it doesn't work Link to comment Share on other sites More sharing options...
JohnOne Posted July 31, 2016 Share Posted July 31, 2016 What does ... ConsoleWrite($aSplit[$i] & @LF) ...give you? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 trof, When you read window text, make sure that you have some text in your variable. And when you splitt some text, make sure you got the correct result. So please don not put the error checking code inside the loop. Place it under window text function. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 Nothing Link to comment Share on other sites More sharing options...
AutoBert Posted July 31, 2016 Share Posted July 31, 2016 Try this script: expandcollapse popup#RequireAdmin Local $aArray[16] $iDebug = True ; Toggle to False if you don't need debug infos $aArray[0] = "Around the World.exe" $aArray[1] = "Autumn Romance.exe" $aArray[2] = "Baby.exe" $aArray[3] = "Birthday Jolly.exe" $aArray[4] = "Brush.exe" $aArray[5] = "Eternal Love.exe" $aArray[6] = "Green Clover.exe" $aArray[7] = "Interaction.exe" $aArray[8] = "Lovely Day.exe" $aArray[9] = "LowerThird 1.exe" $aArray[10] = "LowerThird 2.exe" $aArray[11] = "Rainbow Delights.exe" $aArray[12] = "Road Trip.exe" $aArray[13] = "True Love.exe" $aArray[14] = "Under the Sea.exe" $aArray[15] = "Vintage Memories.exe" For $vElement In $aArray Run($vElement) WinWait("Seleziona la lingua dell'installazione") WinActivate("Seleziona la lingua dell'installazione") ControlClick("Seleziona la lingua dell'installazione", "", "Button1") WinWait("Installazione di CyberLink", "InstallShield Wizard per CyberLink", 10) Local $sTitle = WinGetTitle("[ACTIVE]") If "Installazione di in corso ..." = $sTitle Then WinWait("Installazione di in corso", "InstallShield Wizard per CyberLink") WinActivate("Installazione di in corso", "InstallShield Wizard per CyberLink") ControlClick("Installazione di in corso", "", "Button1") WinWaitActive("Installazione di in corso", "Contratto di Licenza per l'Utente") ControlClick("Installazione di in corso", "", "Button2") Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') If $iDebug Then ConsoleWrite('SplitActiveWindowText Error: '&@error&' Extended: '&@extended& 'Split: '&$aSplit[0]&@CRLF) For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. If $aSplit[$i] = "Informazioni sul cliente" Then _WinWaitActivated("Installazione di in corso", "Informazioni sul cliente") ControlClick("Installazione di in corso", "", "Button2") _WinWaitActivated("Installazione di in corso", "Cartella di destinazione") ControlClick("Installazione di in corso", "", "Button1") _WinWaitActivated("Installazione di in corso", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di in corso", "", "Button2") _WinWaitActivated("Installazione di in corso", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di in corso", "", "Button4") Else _WinWaitActivated("Installazione di in corso", "Cartella di destinazione") ControlClick("Installazione di in corso", "", "Button1") _WinWaitActivated("Installazione di in corso", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di in corso", "", "Button2") _WinWaitActivated("Installazione di in corso", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di in corso", "", "Button4") EndIf Next Else WinWait("Installazione di CyberLink", "InstallShield Wizard per CyberLink") WinActivate("Installazione di CyberLink", "InstallShield Wizard per CyberLink") ControlClick("Installazione di CyberLink", "", "Button1") _WinWaitActivated("Installazione di CyberLink", "Contratto di Licenza per l'Utente") ControlClick("Installazione di CyberLink", "", "Button2") Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') For $i = 1 To $aSplit[0] ; Loop through the array returned by StringSplit to display the individual values. If $aSplit[$i] = "Informazioni sul cliente" Then _WinWaitActivated("Installazione di CyberLink", "Informazioni sul cliente") ControlClick("Installazione di CyberLink", "", "Button2") _WinWaitActivated("Installazione di CyberLink", "Cartella di destinazione") ControlClick("Installazione di CyberLink", "", "Button1") _WinWaitActivated("Installazione di CyberLink", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di CyberLink", "", "Button2") _WinWaitActivated("Installazione di CyberLink", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di CyberLink", "", "Button4") Else _WinWaitActivated("Installazione di CyberLink", "Cartella di destinazione") ControlClick("Installazione di CyberLink", "", "Button1") _WinWaitActivated("Installazione di CyberLink", "L'installazione aggiungerà le icone dei programmi") ControlClick("Installazione di CyberLink", "", "Button2") _WinWaitActivated("Installazione di CyberLink", "Il Setup ha completato l'installazione CyberLink") ControlClick("Installazione di CyberLink", "", "Button4") EndIf Next EndIf Next Func _WinWaitActivated($Title, $text, $iTimeOut = 10) If $iDebug Then ConsoleWrite('_WinWaitActivated: ' & $Title & ' ' & $text & ' ' & $iTimeOut & @CRLF) Local $bOK = False Local $iStart = TimerInit() WinActivate($Title, $text) Do Sleep(10) If WinActive($Title, $text) Then $bOK = True $iDiff = TimerDiff($iStart) Until $bOK Or $iDiff > $iTimeOut * 1000 If $iDebug Then ConsoleWrite($Title & ': ' & $bOK & ' ' & $iDiff & @CRLF) EndFunc ;==>_WinWaitActivated if didn't work as expected post console output. Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 (edited) I have a strange script behaviour. this window is the one related to _WinWaitActivated("Installazione di in corso", "Informazioni sul cliente") ControlClick("Installazione di in corso", "", "Button2") It should be pressed Button2 but, I don't know why, but it's pressed Button1. In fact the next window that appeared me is This is a previous window I don't have console output Edited July 31, 2016 by trof Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 1 hour ago, kcvinu said: trof, When you read window text, make sure that you have some text in your variable. And when you splitt some text, make sure you got the correct result. So please don not put the error checking code inside the loop. Place it under window text function. I did it Local $sText = WinGetText("[ACTIVE]") Local $aSplit = StringSplit($sText, '\n') For $i = 1 To $aSplit[0] if $aSplit[$i] = "Informazioni sul cliente" then WinActivate("Installazione di CyberLink", "Informazioni sul cliente") ControlClick("Installazione di CyberLink", "", "Button2") If @error Then ConsoleWrite(@error & @CRLF) ; This is for knowing error code If @error Then ConsoleWrite(@extended & @CRLF) ; this is for knowing extended error code again, no error message Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 Local $sText = WinGetText("[ACTIVE]") If @error Then ConsoleWrite(" WingetText Error = " & @error & @CRLF) Local $aSplit = StringSplit($sText, '\n') If @error Then ConsoleWrite(" String split Error = " &@error & @CRLF) For $i = 1 To $aSplit[0] @trof , this is what i meant Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 again, no error message Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 So winget text is ok, string split is ok. Then, get the control id of Button2 and make that statement inside an if statement. Like this If If WinActivate("Installazione di CyberLink", "Informazioni sul cliente") Then ControlClick("Installazione di CyberLink", "", $BTN_ID) Else ConsoleWrite("The window is not activated") Endif Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
trof Posted July 31, 2016 Author Share Posted July 31, 2016 I declared $BTN_ID in this way Local $BTN_ID = @error No error message Script is always blocked in this window (I forgot to say it) Link to comment Share on other sites More sharing options...
kcvinu Posted July 31, 2016 Share Posted July 31, 2016 No No.. don't do that. $BTN_ID is the control ID of your button which you will get from WindowInfo tool. Use window info tool in that purticular window. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) 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