JonF Posted August 6 Posted August 6 I'm building a bootable flash drive. I want to include the Wireshark packet watcher. It requres the Npcap service to be running. I'm trying to automate the installation of Npcap after boot. I'm testing in VirtualBox but the same thing happens on physical hardware. In both the "Installing" window and the "Options" window appear AutoIT clicks the appropriate button. When the "Installing" windiow appears, a second or two later the WinWaitActive($Handle,"Completed") fires the ControlClick($WindowTitle"&Next",1) for a button that doesn't exist yet. I sprinkled WinActivate throughout because another program window is on screen while this is happening, but it made no difference. If I close the other program window first it makes no difference. expandcollapse popup#include <FileConstants.au3> #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> If $CmdLine[0] >= 1 Then $Pause=$CmdLine[1] Else MsgBox(4096,"NPcap installer","Please include the pause flag (False or True) on the command line.") Exit EndIf If $CmdLine[0] >= 2 Then $StartDriver=$CmdLine[2] Else MsgBox(4096,"NPcap installer","Please include the start driver flag (False or True) on the command line.") Exit EndIf $FileList = _FileListToArray(@ScriptDir,"npcap-*.exe",$FLTA_FILES ,True) Select Case @error = 4 MsgBox($MB_OK,"File error","Npcap installer " & @ScriptDir & "\npcap-*.exe not found!") Exit Case @error = 1 MsgBox($MB_OK,"File error","Npcap installer path " & @ScriptDir & " not found!") Exit Case @error=0 EndSelect ; Wait until PE Network Manager settles down. If WinExists("PE Network Manager") Then WinWait("PE Network Manager","Properties",3) $Version = StringRight(StringTrimRight($FileList[1],4),4) $WindowTitle = "Npcap " & $Version & " Setup" ShellExecute($FileList[1]) $WindowTitle = WinWait($WindowTitle,"License Agreement",10) If $WindowTitle <> 0 Then WinActivate($WindowTitle) ControlClick($WindowTitle,"License Agreement",1) WinWaitActive($WindowTitle,"Installation Options") WinActivate($WindowTitle) If $Pause = "False" Then ControlClick($WindowTitle,"&Install",1) EndIf WinActivate($WindowTitle) WinWaitActive($WindowTitle,"Setup was completed") WinActivate($WindowTitle) ; Wait for the "Next" button to be active Sleep(3000) ControlClick($WindowTitle,"&Next",1) WinWaitActive($WindowTitle,"Finished") ControlClick($WindowTitle,"&Finish",1) Else MsgBox($MB_OK,"Npcap install","Did not see the installation window " & $WindowTitle & "!") EndIf If $StartDriver = "True" Then If @OSArch="X86" Then $Command = @WindowsDir & "\SysWOW64\cmd.exe" Else $Command = @SystemDir & "\cmd.exe" EndIf ShellExecute($Command," /c net start npcap") EndIf If you want to wattch it, https://fleming-group.com/Hidden/Video/Video.html. The cmd window flashing is the end of the AutoIT script.
argumentum Posted August 6 Posted August 6 Fortunately npcap has these "&" that allows you to, instead of aiming the mouse, send the "ALT + n" to the window. Try that. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Nine Posted August 6 Posted August 6 Seems a bit strange that all your buttons have a control id equals to 1. All your ControlClick are using the control id 1. Are you sure about that ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ioa747 Posted August 6 Posted August 6 (edited) maybe for such an action ( installation ) you need #RequireAdmin Edited August 6 by ioa747 I know that I know nothing
JonF Posted August 7 Author Posted August 7 On 8/6/2025 at 2:33 PM, Nine said: Seems a bit strange that all your buttons have a control id equals to 1. All your ControlClick are using the control id 1. Are you sure about that ? Yes.
argumentum Posted August 7 Posted August 7 @JonF I don't like you To the ignore list ! Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Nine Posted August 7 Posted August 7 (edited) 14 hours ago, JonF said: Yes. No. Show me au3info, I think you are mistaken with the number of clicks...Anyway you do not need to provide the text of a button (or any other controls) if you know the control id. It is just an overkill... Edited August 8 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JonF Posted August 9 Author Posted August 9 On 8/7/2025 at 5:11 PM, argumentum said: @JonF I don't like you To the ignore list ! I''ve seen people like you before.
JonF Posted August 9 Author Posted August 9 On 8/7/2025 at 5:44 PM, Nine said: No. Show me au3info, I think you are mistaken with the number of clicks...Anyway you do not need to provide the text of a button (or any other controls) if you know the control id. It is just an overkill... I'm trying, but the program has decided to run minimized and can't be restored. Arghh...... It seeems nobody is addressing the issue, which is that... WinWaitActive($WindowTitle,"Setup was completed") ... is reporting the windows is active before the window containing that text is on-screen.
JonF Posted August 9 Author Posted August 9 On 8/7/2025 at 5:44 PM, Nine said: No. Show me au3info, I think you are mistaken with the number of clicks...Anyway you do not need to provide the text of a button (or any other controls) if you know the control id. It is just an overkill... The Help file does NOT list the second argument as optional.
Solution Nine Posted August 9 Solution Posted August 9 (edited) 36 minutes ago, JonF said: The Help file does NOT list the second argument as optional. True. For all Control* functions it doesn't say it is optional. It is not optional in terms of skipping it. It is optional (check examples of Control* functions) in the sense that you must provide a string, but most of the time, it is going to be empty... However, it is clearly stated that the second parameter of many Win* functions is optional (meaning that you can skip it). Edited August 9 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JonF Posted August 9 Author Posted August 9 (edited) I finally managed to get Au3Info screenshots. During installation the "Next" button is ID 1 and when installtion is complet the Next button is ID 1. However, the program doesn't try to click anything during installation, It is supposed to WAIT until the "Installation Complete" window appears and click button ID 1. IT DOESN'T WAIT! Edited August 9 by JonF
Werty Posted August 9 Posted August 9 (edited) Npcap supports Silent Install with no graphical interface or prompts. https://npcap.com/guide/npcap-users-guide.html /edit, just saw that silent install option is only available for OEM version of npcap, not the free version, dont know which you use. Edited August 9 by Werty Some guy's script + some other guy's script = my script!
Nine Posted August 9 Posted August 9 Ok it seems all the controls have the id of 1. Maybe you should try to loop until you get a valid handle of the control. You are currently looking at the activation of the window, but maybe the control is not available yet. Try this : $WindowTitle = "Npcap " & $Version & " Setup" $hWnd = WinGetHandle($WindowTitle) ConsoleWrite($hWnd & @CRLF) While Not ControlGetHandle($hWnd, "", "Button2") Sleep(100) WEnd ControlClick($hWnd, "", "Button2") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
pixelsearch Posted August 9 Posted August 9 10 hours ago, JonF said: It seeems nobody is addressing the issue, which is that... WinWaitActive($WindowTitle,"Setup was completed") ... is reporting the windows is active before the window containing that text is on-screen. If not mistaken, $WindowTitle was a string, then it becomes a handle as found in your code : $WindowTitle = "Npcap " & $Version & " Setup" ; $WindowTitle is a string $WindowTitle = WinWait($WindowTitle,"License Agreement",10) ; $WindowTitle becomes a handle Now have a look at this line : WinWaitActive($WindowTitle,"Setup was completed") 1) If $WindowTitle is a handle (your case) then the 2nd parameter ("Setup was completed") has no meaning as stipulated by the help file : When you use a window handle for the title parameter then the text parameter is completely ignored. That's why your window is active, no matter the text you indicated as 2nd parameter 2) If $WindowTitle is NOT a handle, then the 2nd parameter is useful ("Setup was completed") So what you should try is a 1st parameter not being a handle (it can be a title, a class etc...) then your second parameter will be useful. This is a part of my personal test on NotePad : WinWaitActive($hWnd, "123", 10) ; immediately active, "123" doesn't mean anything when 1st param. title is a handle ; WinWaitActive("[CLASS:Notepad]", "123", 10) ; active only when "123" is typed (title is not a handle) ; WinWaitActive("Sans titre - Bloc-notes", "123", 10) ; active only when "123" is typed (title is not a handle) Good luck "I think you are searching a bug where there is no bug... don't listen to bad advice."
argumentum Posted August 9 Posted August 9 expandcollapse popup;~ ConsoleWrite('- WinGetHandle_NcapSetup() = ' & WinGetHandle_NcapSetup() & @TAB & @error & ',' & @extended & @CRLF) Func WinGetHandle_NcapSetup() Local $n, $aArray = WinList("[TITLE:Npcap;CLASS:#32770;]") ; Npcap 1.83 Setup If UBound($aArray) < 2 Then Return SetError(1, UBound($aArray), 0) For $n = 1 To $aArray[0][0] If StringInStr($aArray[$n][0], "Setup") Then Return SetExtended(UBound($aArray) - 1, $aArray[$n][1]) Next Return SetError(2, UBound($aArray) - 1, 0) EndFunc ;==>WinGetHandle_NcapSetup Exit AnswerSetup() Func AnswerSetup() Local $hTimer = TimerInit() Local $iDone = 0, $sTextWas, $sTextIs, $hWin = WinGetHandle_NcapSetup() If @error Then Return @ScriptLineNumber WinActivate($hWin) WinSetOnTop($hWin, "", 1) While Not $iDone Sleep(1000) If TimerDiff($hTimer) > 60 * 1000 Then Return @ScriptLineNumber $sTextIs = WinGetText($hWin) If $sTextWas = $sTextIs Then ContinueLoop $sTextWas = $sTextIs ConsoleWrite($sTextIs) If StringInStr($sTextIs, "Reinstall (possibly with different options)") Then ControlSend($hWin, "", "", "!y") WinWaitClose($hWin, "", 5) $hWin = WinGetHandle_NcapSetup() WinSetOnTop($hWin, "", 1) EndIf If StringInStr($sTextIs, "I &Agree") Then ControlSend($hWin, "", "", "!a") If StringInStr($sTextIs, "&Install") Then ControlSend($hWin, "", "", "!i") If StringInStr($sTextIs, "&Next >") Then ControlSend($hWin, "", "", "!n") If StringInStr($sTextIs, "Click Finish to close this wizard.") Then WinClose($hWin) ControlSend($hWin, "", "", "{ENTER}") WinWaitClose($hWin, "", 5) If Not WinExists($hWin) Then Return EndIf WEnd EndFunc ;==>AnswerSetup Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Numeric1 Posted August 10 Posted August 10 In your script, I noticed that you use WinWaitActive($WindowTitle, "Setup was completed"). However, it appears that "Setup was completed" is displayed in a label within the window, not in its title. To check the state of this label, which contains the main message you're interested in, you should inspect this control. I recommend using the AutoIt Window Info tool to identify its properties. Additionally, to make window detection more flexible, I suggest adding Opt("WinTitleMatchMode", 2) at the beginning of your script. This option allows for partial matching of the window title, which is particularly useful if the title varies slightly. From 0 and 1 to the stars, it all starts with binary, Numeric1
Numeric1 Posted August 10 Posted August 10 You could also tackle that fancy progress bar to make sure the operation is truly done, but hold your horses! First, check that it’s a real, honest-to-goodness progress bar and not some glamorous poser from a trendy drawing library. These days, with all their aesthetic swagger, these bars think they’re modern art and scoff at the old-school programming rules. Beware, they’re often more about looks than reliability! 🙊 From 0 and 1 to the stars, it all starts with binary, Numeric1
JonF Posted August 11 Author Posted August 11 On 8/9/2025 at 8:33 AM, Nine said: True. For all Control* functions it doesn't say it is optional. It is not optional in terms of skipping it. It is optional (check examples of Control* functions) in the sense that you must provide a string, but most of the time, it is going to be empty... However, it is clearly stated that the second parameter of many Win* functions is optional (meaning that you can skip it). Well, it doesn't seem to me to be clearly stated: Quote The only required parameter for this function is title. However, the text and timeout parameters are optional. In some functions, the text parameter is not optional. "In some functiions" isn't clear. it appears that in some functions the Text argument must not be specified when an ID is specified. I removed all the Text arguments and rteplaced them with an empty string, and the entire function works! Thank you.
pixelsearch Posted August 11 Posted August 11 2 hours ago, JonF said: it appears that in some functions the Text argument must not be specified when an ID is specified. This is not always True As I already explained in this post above, if the 1st parameter (title) is NOT a handle, then the Text argument is important, no matter you indicate a valid control ID . For example : ControlClick("Untitled - Notepad", "123", "Edit1") The ControlID (3rd parameter) has been correctly indicated, but ControlClick won't perform unless the text (2nd parameter) contains "123" : this is because the 1st parameter (title) is NOT a handle ControlClick($hWnd, "123", "Edit1") The ControlID (3rd parameter) has been correctly indicated, and ControlClick will perform no matter what's in the 2nd Text parameter : this is because the 1st parameter (title) IS a handle And it helps to answer your "issue" question : On 8/9/2025 at 1:24 PM, JonF said: It seeems nobody is addressing the issue, which is that... WinWaitActive($WindowTitle,"Setup was completed") ... is reporting the windows is active before the window containing that text is on-screen. You indicated a handle as 1st parameter (your bad named $WindowTitle is a handle), this is why your 2nd Text parameter is ignored and your window is always active, as stipulated in the help file : When you use a window handle for the title parameter then the text parameter is completely ignored. "I think you are searching a bug where there is no bug... don't listen to bad advice."
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