Newb Posted October 19, 2022 Share Posted October 19, 2022 Hello AutoIT community, Long time I didn't log back here, absolutely happy to see the project is still alive and maintained. AutoIT taught me programming and gave me many joys, I was trying to automate some setups for a machine, and Powershell was just not enough for my needs:https://stackoverflow.com/questions/39353073/how-i-can-send-mouse-click-in-powershell Looking here, it seems quite a clunky task to do. So, since I automated a lot of stuff in AutoIT, I've decided to get back at it (and it feels so much better now that I'm a full stack developer since a decade). I managed to automate all the setup and configuration except a point where I need to select a drive in the scroll down list show here: I tried all that I know, so I think I'm missing something. The idea is to focus it, then move up and down with arrow (or Send() a drive letter so it gets highlighted) then follow up with TABS and ENTER and Send() to compile the rest of the form. Sample script: #Truecrypt window name Local Const $TC71WindowName = "TrueCrypt" Local Const $TC71Location = "C:\Program Files\TrueCrypt\TrueCrypt.exe" #Configuring TC Run($TC71Location) Sleep(500) If WaitAndActivateWindow($TC71WindowName) Then #TC installed Open and configure MsgBox(0,"Error", "Sending D") #Handler of drive select form Local $driveControlHandler = HWnd("[CLASS:Static; INSTANCE:2]") ControlFocus($driveControlHandler) Send("D") Sleep(200) Send("{TAB}") Sleep(200) Send("{TAB}") Sleep(200) Send($PathTc) Else Exit() EndIf The thing revolves around " HWnd("[CLASS:Static; INSTANCE:2]")" where I try to get handle of the window section in the screenshot. I also tried to get it by Window Name/Text and whatever, but it just seems that I cant navigate or interact with it. NOTE: The scroll list CANNOT be navigated with tab, arrow or anything. I've aleady tried. Also I would avoid doing MouseClicks because that's really resolution and window position dependent.. If anyone dares to try, heres the setup for Truecrypt 7.1a.http://www.oldversion.com/windows/truecrypt-7-1 or google it from wherever you feel BONUS: I really would like to avoid doing all the navigation in the old fashioned way "TAB TAB TAB ENTER TAB TAB SEND("SOMEKEYS") TAB TAB ENTER SPACE.....", you got what I mean. I would like to be able to handle buttons by their class/handle to do some bulletproof code. What am I missing? Why I can't select buttons and windows correctly? I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
KaFu Posted October 19, 2022 Share Posted October 19, 2022 What do you want to achieve? Mount a container? I know TC supports an extensive list of command line arguments. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
OJBakker Posted October 19, 2022 Share Posted October 19, 2022 5 hours ago, Newb said: The thing revolves around " HWnd("[CLASS:Static; INSTANCE:2]")" where I try to get handle of the window section in the screenshot. I also tried to get it by Window Name/Text and whatever, but it just seems that I cant navigate or interact with it. Try replacing the use of HWnd(...) with ControlGetHandle(...) spudw2k 1 Link to comment Share on other sites More sharing options...
Newb Posted October 20, 2022 Author Share Posted October 20, 2022 On 10/19/2022 at 4:41 PM, KaFu said: What do you want to achieve? Mount a container? I know TC supports an extensive list of command line arguments. Hello! I want to automate the setup process and container mount. I knew about command line but making it with keystrokes was faster I also want to learn to get control handles efficiently to ease the automation processes. Anyway, I found a solution, I can just do it with keystrokes, it just required a bit of thinkering with how windows controls work. I just needed to send a few {UP} and {DOWN} keystrokes I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
Newb Posted October 20, 2022 Author Share Posted October 20, 2022 On 10/19/2022 at 8:08 PM, OJBakker said: Try replacing the use of HWnd(...) with ControlGetHandle(...) Ok, I will experiment with it. Anyway, I found a solution, I can just do it with keystrokes, it just required a bit of thinkering with how windows controls work. I just needed to send a few {UP} and {DOWN} keystrokes I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
Newb Posted October 20, 2022 Author Share Posted October 20, 2022 (edited) Update: I tried ControlGetHandle As suggested. NOTE: To make the Window info detection work, I had to deactivate Spy++ logic detection or else it won't detect all the properties correctly But maybe I'm doing something wrong in clicking the control. Here's what I do: WinActivate($WindowTitle) $a = ControlGetHandle("TrueCrypt","E&xit",1062) if Not $a Then MsgBox(0,"No handle","Not found") Else MsgBox(0,"Handle", String($a)) EndIf ControlClick($a, "E&xit", 1062) Here's with spy: Trying to close the program and it will stay in the traybar (so I can't kill the process). Handle is found: The click just doesn't happen. Anyone can help? EDIT: More info: I tried to check return value of controlclick MsgBox(0,"ctrlcickreturn", String(ControlClick($a, "E&xit", 1062))) and it returns 0, so basically looks like it's not working Edited October 20, 2022 by Newb I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
OJBakker Posted October 20, 2022 Share Posted October 20, 2022 (edited) Add ControlFocus(...) before the ControlClick(...) Your are using the wrong values for the parameters parameters of the control* functions. The first 2 parameters identify the window, the 3 parameter identifies the control, so you do not need the handle for the control to use the controlclick function. Edited October 21, 2022 by OJBakker additional info. Link to comment Share on other sites More sharing options...
Newb Posted October 21, 2022 Author Share Posted October 21, 2022 On 10/21/2022 at 12:04 AM, OJBakker said: Add ControlFocus(...) before the ControlClick(...) Your are using the wrong values for the parameters parameters of the control* functions. The first 2 parameters identify the window, the 3 parameter identifies the control, so you do not need the handle for the control to use the controlclick function. Ok everything worked out wonderfully. Thank you! I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. 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