SadBunny Posted November 29, 2016 Share Posted November 29, 2016 I tried it too. With the Ninite dialog open, this code: While WinExists("Ninite") WinActivate("Ninite") If ControlClick("Ninite", "", "[CLASS:Button; INSTANCE:1]") = 1 Then ConsoleWrite("OK" & @CRLF) ExitLoop ; Successfull clicked the button EndIf ConsoleWrite("Nok" & @CRLF) Sleep(1000) ; Wait for a second WEnd ... immediately says "OK", but nothing happens to the window. (If I click the "Close" button manually everything is ok.) I also doublechecked that "CLASS:Button; INSTANCE:1" is indeed the Close button we're talking about, and if I read out the handle (ControlGetHandle) I get a non-null result, so it's found. If I break it (say, I ask it to ControlClick INSTANCE:2, then it keeps saying Nok and looping. So it really looks like the button can be found like any other, it even accepts the click, but it just doesn't react to it if it came from the AutoIt script's ControlClick command. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted November 29, 2016 Share Posted November 29, 2016 AH! I got it. Should have seen it right away with these results Put #RequireAdmin on top of your script! (The Ninite installer seems to elevate itself to admin rights, and if a gui runs as admin you can normally read it as a user, even interact with it, but Windows just makes everything act as though it accepted commands while it actually didn't. Now, if you make your script elevate itself to admin rights as well, it works with the gui just fine.) Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
water Posted November 29, 2016 Share Posted November 29, 2016 That would have been my next guess My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
AutoDaemon Posted November 30, 2016 Author Share Posted November 30, 2016 Okay that was a bit fast for me. Sorry I had some meetings yesterady and didn't get the chance to check back here.. Thank you for your replies! Anyways I executed the script after I've run Ninite and those were the results. Tried the script with #requireadmin but it didn't click the button so far. Link to comment Share on other sites More sharing options...
water Posted November 30, 2016 Share Posted November 30, 2016 So we have multiple windows all starting with the text we are looking for. Could you please insert the following line at the top of your script so AutoIt does an exact title match? Opt("WinTitleMatchMode", 3) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
AutoDaemon Posted November 30, 2016 Author Share Posted November 30, 2016 I hope I'm doing this right Link to comment Share on other sites More sharing options...
water Posted November 30, 2016 Share Posted November 30, 2016 Perfect. Now we are sure we access the correct window. Still not clicking the Close button? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
water Posted November 30, 2016 Share Posted November 30, 2016 Another idea would be to set Opt("WinSearchChildren", 1) so AutoIt searches child windows as well. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
SadBunny Posted November 30, 2016 Share Posted November 30, 2016 Just to be sure... You've done so many tries by this time, maybe post the script you're using now to make sure there isn't something simple we're overlooking? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
AutoDaemon Posted December 1, 2016 Author Share Posted December 1, 2016 Hi. So far I've tried each suggestion of yours. At the moment it looks like this: Quote #RequireAdmin #include <Array.au3> RunWait("C:\ninite\ninite.exe") Opt("WinTitleMatchMode", 3) Opt("WinSearchChildren", 1) Global $aWinList = WinList("Ninite") _ArrayDisplay($aWinList) While WinExists("Ninite") If ControlClick("Ninite", "", "[CLASS:Button; INSTANCE:1]") = 1 Then ExitLoop ; Successfull clicked the button Sleep(1000) ; Wait for a second WEnd I have tried your (SadBunnys) suggestion on the top of this page as well. Am I overlooking something obvious? To get some practice I wrote some easier scripts for my daily use yesterday Thank you guys so much! Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 Yes, you're using RunWait, which makes the script halt until the process has finished. Replace it by Run. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
AutoDaemon Posted December 1, 2016 Author Share Posted December 1, 2016 Replaced it in the aforementioned code to Run but it doesn't click the button. Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 (edited) Ok, there's more. I tried it, apparently there's a close button somewhere in the quick windows that ninite opens and closes which is not the final close button you're looking for and clicking it works, but does nothing, then your loop quits, then the final popup comes and the script doesn't find that button any more. This works for me. It feels way wonky but sometimes you have to do some wonkiness to work around a weird 3rd-party GUI #RequireAdmin #include <Array.au3> Run("C:\tmp\nin.exe") $handle = 0 While True While True Sleep(10) If getCloseButtonHandle() Then If ControlClick("Ninite", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]") Then ToolTip("Clicked OK!") ExitLoop EndIf EndIf WEnd ; Wait for a possible next Ninite window containing a close button ; if it exists after a second, keep the loop going, otherwise exit Sleep(1000) $handle = getCloseButtonHandle() If Not getCloseButtonHandle() Then ExitLoop WEnd Func getCloseButtonHandle() Return ControlGetHandle("Ninite", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]") EndFunc ;==>getCloseButtonHandle /edit2: be sure to repair the link to your ninite exe Edited December 1, 2016 by SadBunny Pasted wrong version of code AutoDaemon 1 Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 Slightly improved the code, final version is now in my last post Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
AutoDaemon Posted December 1, 2016 Author Share Posted December 1, 2016 Wow. This is awesome! Thank you so much! I will make sure to study the code as to understand every step instead of just copy pasting it. Thank you! Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 But does it work? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 Refactored button definition into a variable so you only have to change it in one place if you have to change it (easier and less error-prone): #RequireAdmin #include <Array.au3> Run("C:\tmp\nin.exe") $handle = 0 $buttonDefinition = "[CLASS:Button; TEXT:Close; INSTANCE:1]" While True While True Sleep(10) If getCloseButtonHandle() Then If ControlClick("Ninite", "", $buttonDefinition) Then ToolTip("Clicked OK!") ExitLoop EndIf EndIf WEnd ; Wait for a possible next Ninite window containing a close button ; if it exists after a second, keep the loop going, otherwise exit Sleep(1000) $handle = getCloseButtonHandle() If Not getCloseButtonHandle() Then ExitLoop WEnd Func getCloseButtonHandle() Return ControlGetHandle("Ninite", "", $buttonDefinition) EndFunc ;==>getCloseButtonHandle Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
AutoDaemon Posted December 1, 2016 Author Share Posted December 1, 2016 It worked perfectly! Tried it with a ninite installer that only installed updates (meaning the main programs were already installed) and one where i chose some new software. Like a charm! Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 I know I keep changing the code, but I noticed I really wasn't using $handle anymore #RequireAdmin #include <Array.au3> Run("C:\tmp\nin.exe") $buttonDefinition = "[CLASS:Button; TEXT:Close; INSTANCE:1]" While True While True Sleep(10) If getCloseButtonHandle() Then If ControlClick("Ninite", "", $buttonDefinition) Then ToolTip("Clicked OK!") ExitLoop EndIf EndIf WEnd ; Wait for a possible next Ninite window containing a close button ; if it exists after a second, keep the loop going, otherwise exit Sleep(1000) If Not getCloseButtonHandle() Then ExitLoop WEnd Func getCloseButtonHandle() Return ControlGetHandle("Ninite", "", $buttonDefinition) EndFunc ;==>getCloseButtonHandle Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted December 1, 2016 Share Posted December 1, 2016 All in all the whole thing looks overly complicated, but it's simply because of how the Ninite gui's seem to operate Roses are FF0000, violets are 0000FF... All my base are belong to you. 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