VeeDub Posted September 19, 2023 Posted September 19, 2023 Hello, I'm trying to control / automate some steps with an application. At the moment, I'm trying to use ControlSend to send the clicks, as I want to ensure that each "step" in my workflow is completed successfully, before proceeding to the next "step". I will probably need to add some code to what I already have, to try and check that the expected window / dialog box has appeared. Unfortunately, I've encountered an early problem with my code. Local $bWndIsActive = False Do Local $hWnd = WinActivate("Macrium viBoot - Hyper-V") Sleep(1000) $bWndIsActive = WinActive($hWnd) Until ($bWndIsActive) Local $ControlSendStatus = ControlSend($hWnd,"","","^N") ; Ctl-N ConsoleWrite("ControlSendStatus: " & $ControlSendStatus & @CRLF) In the console: ControlSendStatus: 1 What actually happens is: The application window is given focus. But the window / dialog box that is supposed to appear when: Ctl-N is pressed Does not. I've also tried this version of the code Local $bWndIsActive = False Do Local $hWnd = WinActivate("Macrium viBoot - Hyper-V") Sleep(1000) $bWndIsActive = WinActive($hWnd) Until ($bWndIsActive) Local $ControlSendStatus = ControlSend($hWnd,"","ToolbarWindow32","^N") ; Ctl-N ConsoleWrite("ControlSendStatus: " & $ControlSendStatus & @CRLF) And ControlSendStatus = 0
Solution ioa747 Posted September 19, 2023 Solution Posted September 19, 2023 ; Pauses execution of the script until the MacriumViboot window exists Local $hWnd = WinWait("Macrium viBoot - Hyper-V") ;Then first activates (gives focus to) a MacriumViboot window WinActivate($hWnd) ConsoleWrite("$hWnd=" & $hWnd & @CRLF) ;and then send "^n" not '^N' which is 'Ctrl Shift n' Send("^n") ; and/or if you want to use the control, ; then you find the id (here in 1280 I put it in a blank because I don't know it) ; use the ToolBar tab of Au3Info to get the Command ID ;~ $ControlSendStatus = ControlCommand($hWnd, "", "ToolbarWindow321", "SendCommandID", 1280) ; and/or if you want to use the menu, ; you have to find where to place the & (usually when we press alt this appears with an _ underscore below the letter) ; e.g. &New... as Ṉew ;~ WinMenuSelectItem($hWnd, "", "Virtual Machine", "&New...") I know that I know nothing
VeeDub Posted September 19, 2023 Author Posted September 19, 2023 The issue with my code was the capital "N" Thanks!
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