
cag8f
Active Members-
Posts
285 -
Joined
-
Last visited
Everything posted by cag8f
-
Is there an official VSCode extension for AutoIt?
cag8f replied to cag8f's topic in AutoIt Technical Discussion
OK no problem, thanks for the confirmation. -
Hi all. I would like to do my AutoIt coding using the VSCode editor if possible. Is there an official AutoIt extension for VSCode, i.e. one maintained by the AutoIt development team which would do things like provide syntax highlighting? Searching, I see one from a developer named Damien, and a ssecond from 'Cory Stein' and a third from 'Anders Pedersen.' ChatGPT seems to think there is one here: https://marketplace.visualstudio.com/items?itemName=AutoItTeam.autoit. But that leads to a 404 error. I've also seen this post, which seems to indicate there is no official extension. But before I go with a third party extension I just thought I'd ask here. Thanks in advance.
-
ControlGetHandle not matching on regex?
cag8f replied to cag8f's topic in AutoIt General Help and Support
It looks like I need to add the INSTANCE in this case. If I remove it, ControlGetHandle still returns the correct handle ID. But the click from ControlClick doesn't seem to occur 😕 -
ControlGetHandle not matching on regex?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 @Nine Thanks for that. Using CLASS instead of CLASSNAMENN, and adding the INSTANCE, resolved my issue. Thanks very much. But what about the value for instance? In my case it is `42` which I've hardcoded. What if that changes in the future? Can I use a regex pattern to match on it in my code? Or maybe it is something that shouldn't change very often? -
Hi all. I'm having issues understanding a regular expression when used with ControlGetHandle. If I call ControlGetHandle and pass it a string value for the third parameter, it returns a valid ID (0x00150BE8). But if I change that parameter from a string to a regular expression that I think should match, the function returns an invalid ID and an error code 1. What am I misunderstanding? My code is below. $cWnd = WinWait("ShareX - Color picker", "", 3) ControlClick($cWnd, '', ControlGetHandle($cWnd, "", 'WindowsForms10.BUTTON.app.0.1a52015_r6_ad14')) ControlGetHandle($cWnd, "", 'WindowsForms10.BUTTON.app.0.1a52015_r6_ad142'); Returns: 0x00150BE8 ;~ ControlGetHandle($cWnd, "", '[REGEXPCLASS:^WindowsForms10\.BUTTON\.app\.0\.1a52015_r6_ad142$]'); Returns: 0x00000000 (error code 1)
-
@mLipok thanks for that. And @Nine thanks for your reply in the other thread. I'll continue it here. So to be clear, these are three different possible solutions. These are not steps I need to carry out, in order, to achieve what I want. Am I understanding that correctly? Let me give the regex a go. @Nine was kind enough to give me something to start with. I'll report back here.
-
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 I'm having a problem with control/handle IDs changing on me, requiring me to manually update my code to reflect the new IDs. How do you handle that? I posted details here. -
TL;DR The handles/IDs of my Windows application changed from 1a52015_r6 to 13f26d9_r6. To fix, i had to manually edit all my AutoIt code. Why did this change happen, and what are typical approaches to prevent these kind of edits in the future? ___ Hi all. My AutoIt code has various handles and IDs which contain the string 1a52015_r6, e.g. ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r6_ad11", "left", 1, 875, 20) These handles/IDs correspond to the Windows program I'm controlling with AutoIt: My code was working without issue for a few months, then all of a sudden it stopped working. I determined that the reason was because the handles/IDs for my Windows program no longer used this string, but instead replaced it with a different one: 13f26d9_r6, e.g. ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.13f26d9_r6_ad11", "left", 1, 875, 20) I manually made the fix. But for the future, why exactly did this occur? And more importantly, is there a way to guard against this? Maybe in my code I can/should use regex to match string patterns, rather than the full hardcoded string? Thanks in advance.
-
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
It worked--thanks! -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
Ah cool. OK give me some time to try that out, thanks. I had also noticed the beeping as well. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 I'm back 🙂 I'm still finalizing what I want, but have run into a new issue. In short, I have code that does exactly what is desired/expected when I run it from within SciTE (by pressing F5). But when I move that same code into a new .au3 file, and assign it to run when a keyboard shortcut is pressed, the code seems to skip the last step--i.e. the 'Tool options' dropdown remains open, as if no 'Enter' key press was sent (see screenshot below). Thoughts? Here's a screenshot of the still-open 'Tool options.' After that I've posted both version of my code. Naked code. This is working as desired/expected when I run it via SciTE (with F5)--including the last `ControlSend` command. Note: When run, the code opens 'Tool options' and sets a value for 'Border Size.' The last step in this code is one you added: to send an "Enter" key press to the 'Border Size' control. Local $hWnd = WinWait("ShareX - Editor menu", "", 3) Local $aWinPos = WinGetPos($hWnd) Local Const $iSZ = $aWinPos[3] / 2 ; - 16 ConsoleWrite(ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r6_ad11", "left", 1, 1356-416, $iSZ) & @CRLF) ControlSetText("[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11", "1") Sleep(50) ControlSend("[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11", "{ENTER}") Keyboard shortcut code. Executing this code, via its keyboard shortcut, leaves the 'Tool options' dropdown open: Opt("SendKeyDelay", 0) ; 0 removes completely the delay Opt("SendKeyDownDelay", 0) ; 0 removes completely the delay Local $kb_sxb = "!^v"; define keyboard shortcut to toggle ShareX border size between 1 and 5. Uses ctrl+alt+v. HotKeySet($kb_sxb, "send_sxb") Func send_sxb(); Check value of ShareX border size. If 5, change to 1. Otherwise, change to 5. HotKeySet($kb_sxb) ; deactivate the hotkey in case the user presses it too long ;Begin naked code that I copied from previous .au3 file. Local $hWnd = WinWait("ShareX - Editor menu", "", 3) Local $aWinPos = WinGetPos($hWnd) Local Const $iSZ = $aWinPos[3] / 2 ; - 16 ConsoleWrite(ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r6_ad11", "left", 1, 1356-416, $iSZ) & @CRLF) ControlSetText("[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11", "1") Sleep(50) ControlSend("[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11", "{ENTER}") ;End naked code that I copied from previous .au3 file. HotKeySet($kb_sxb, "send_sxb"); reactivate it EndFunc -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
OK thanks very much for this! Looks like it is exactly what I need. Give me a few days to have a proper read/test. Edit: It does the trick (with a few mods). So thanks for that! -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
> in this shot icons 2 and 3 do not exist for me You're referencing the blue chevron, and the red x icons on the left? If so, those are 'Continue task' and 'Cancel task' respectively. I guess they are present because this screenshot is technically part of a ShareX 'After workflow task?' That is just an educated guess though. Let me try to explain my question again. Your code contains AutoIt code to do the following in ShareX: Automatically create a rectangle, then change its border size. Automatically create an arrow, then change its border size and arrow head direction. What I would like to do is slightly different: Before any AutoIt code is executed, I will manually create either a rectangle or an arrow in ShareX. After the shape has been created on-screen, execute AutoIt code to automatically change the border size, regardless of whether a rectange or arrow is selected. This code should not require any additional user input, Would you agree that my primary issue is the following: How will my AutoIt code know exactly where to click to open 'Tool options?' If so, thoughts? I guess as a last resort I can choose a pixel that will have COLOR-A if rectangle is selected, and COLOR-B if arrow is selected. Then my code can read the color of this pixel, which should then tell it where to click in order to open 'Tool options. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
OK. So with that solution, I would then have to create/use two different keyboard shortcuts to change Border Size: One shortcut which calls ShareXMenu("Send", "r"); Rectangle One shortcut which calls ShareXMenu("Send", "a"); Arrow Am I understanding that correctly? I think I am still misunderstanding something. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
>> so that it knows which tool is active, in order to correctly select the 'tools' option >> or declaring a variable that holds which tool is active, and update every time I change a tool e.g. $sMyTool = "Rectangle" OK right that makes sense. But how do I have AutoIt automatically determine which tool is active? i.e. without me having to pass that as input. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
Regarding my issue about the tool options button for different shapes, you're suggesting that I create one keyboard shortcut to change the border size for rectangles, and a second keyboard shortcut to change the border size for arrows. Am I understanding that correctly? Not arguing or anything--just want to make sure I'm understanding 🙂 >> haven't found the golden rule >> Everything is done after testing. >> when you give a value, and while it's there, and you don't get it, then you give it a little time and try again OK yep fair enough--will keep that in-mind. Thanks! -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 Bingo, that did it--thanks! So the solution here was to simply sleep for a short interval. For the future, are there hard and fast rules as to when that's needed? Or maybe rules of thumb? Or is it random? Or something else? Edit: Nevermind, I see the solution required more than just a sleep. Let me be sure I understand the fix. Edit 2: OK I think I see the fix. You basically added a step in which the user presses 'Enter.' Sound right? If so, understood, and good to know for the future. Thanks. Edit 3: My issue is resolved, so thanks again. But I have one follow-up question while we're here. Your full code that you posted in this thread on June 13 works solidly when the ShareX shape is rectangle. But if the shape is arrow, at least some things (maybe all?) will break, since, as you pointed out at one point, there is one fewer button in the ShareX toolbar. How do you (or would you) fix that? Namely, I'd like my AutoIt code to change the border size regardless of whether the selected shape is a rectangle or an arrow. I guess I can have the code first check the color value of certain pixels in the toolbar (e.g. the extra button added when selecting 'rectangle')--that could then tell my code which pixel to click to open 'Tool options.' That's a bit fragile though, so if you know any other ways I'm all ears 🙂 -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
OK thanks very much for that. Let me have a look and give it a try later today or tomorrow. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 I'm back, and experiencing an issue with the border size code. In short, my code will change the value displayed in the border size control, and change it to my desired value. For example, my code will change the value from 1 to 5--exactly as desired. But when I then use ShareX to actually draw a shape (e.g. rectangle), the border size of that shape still remains at the previous value (see screenshots below). Any ideas how to troubleshoot that? Of Note I can confirm that the value displayed in the 'Border size' control remains at 5 during the entirety of these steps. It does not get reset back to 1 at any point. Here are screenshots. My code is below. For simplicity I've removed some lines that are extraneous for this task. My Code ShareXMenu("Click", 940);Tool Options ShareXMenu("Set_ToolOptions", "BorderSize=5") Func ShareXMenu($sCommand, $sOption) Local $hWnd = WinWait("ShareX - Editor menu", "", 3) Local $aWinPos = WinGetPos($hWnd) Local Const $iSZ = $aWinPos[3] / 2 ; - 16 Switch $sCommand Case "Click" $sOption = Int($sOption) ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r6_ad11", "left", 1, $sOption, $iSZ) Case "Set_ToolOptions" ControlClick($hWnd, "", "WindowsForms10.Window.EDIT.app.0.1a52015_r6_ad11", "left", 1, 940, $iSZ) Local $aSplt = StringSplit($sOption, "=") If $aSplt[0] <> 2 Then Exit ConsoleWrite("! exit" & @CRLF) ControlSetText("[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11", $aSplt[2]) Send("{ESC}") Send("{ESC}") EndSwitch EndFunc -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747 Please don't insinuate that I would do something so stupid as to assign a ShareX hotkey that collides with the AutoIt Window Info tool hotkey. What actually happened is that I created a custom hotkey using an AutoIt script I wrote myself which collides with the AutoIt Window Info tool hotkey 🙃😅 Anyway, mystery solved on that. -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
OK thanks for that. Using your code, with a few tweaks, I was able to obtain the value of Tool Options-->Border Size. Here were the tweaks: For me, line 2 of your code clicked the 'Border color' button, not 'Tool options.' When I changed the value to `940`, then the line of code successfully clicked 'Tool options' and opened its dropdown. So Ieft the value at `940`. Later in the code the value `969` appears a second time--I also changed it to `940` there. In your definition of `$Result`, you pass a value for `CLASS` containing the substring `Window.808.app`. To get mine to work, my substring was `Window.20808.app`. See Window Info tool below. So let's call this question resolved, thanks! I'll try to press on and figure out how to change the value (using your code as a guide). Final question while we're here: How do I freeze the AutoIt Window Info tool when ShareX is open? Pressing ctrl+alt+f seems to activate a ShareX shortcut, and doesn't freeze the Window Info tool. > because I have ShareX version 15 I'm also using ShareX v15.0. Yep I am indeed congnizant that the rectangle must be selected in order for the correct 'Tool Options' button to appear. Although I acquiesce that I may have overlooked it in some tests. Window Info Tool -
How to read the 'text' value from an input field?
cag8f replied to cag8f's topic in AutoIt General Help and Support
@ioa747@Andreik Thanks very much for your replies. I'm experiencing an issue though in which `ControlGetText` is not returning anything. I tried the code given by each of you, but with the same result. I've attached my code as well as Window Info tool results and output below, Thoughts? Local $hWnd = WinWait("ShareX - Editor menu", "", 3) ConsoleWrite("$hWnd: " & $hWnd & @CRLF) Local $aWinPos = WinGetPos($hWnd) ConsoleWrite("$aWinPos:" & $aWinPos[0] & ", " & $aWinPos[1] & ", " & $aWinPos[2] & ", " & $aWinPos[3] & @CRLF) Local $hControl = ControlGetHandle($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r6_ad11") ConsoleWrite("$hControl=" & $hControl & @CRLF) Local $hMouseClick = MouseClick("left", 1319, 33); Click the 'Tool options' button. The previous code using ControlClick was proving to be buggy. ConsoleWrite("$hMouseClick=" & $hMouseClick & @CRLF) Sleep (2000) $Result = ControlGetText('[CLASS:WindowsForms10.Window.20808.app.0.1a52015_r6_ad1]', '', '[CLASS:WindowsForms10.EDIT.app.0.1a52015_r6_ad11; INSTANCE:1]') ;~ $Result = ControlGetText("[CLASS:WindowsForms10.Window.20808app.0.1a52015_r6_ad1]", "", "WindowsForms10.EDIT.app.0.1a52015_r6_ad11") ConsoleWrite("$Result = " & $Result & @CRLF) As an aside, do you have this code in-hand already? Or are you writing from scratch each time. What you're providing me is truly amazing--thank you very much. -
Hi all. A certain third party Windows app displays an on-screen text input field. If I click inside, the AutoIt Window Info tool correctly displays the value of this input field (see screenshots below). In my AutoIt script, what's proper way to read this value? I've attached a screenshot of the Window Info tool results. Note that in it are values for Class and ClassName. These values are not specific to this particular input field; they are the values of the entire parent control (which contains many different buttons; see screenshot below). FYI the text input field in-question is itself part of a dropdown menu, and that dropdown menu is opened only when the user clicks a particular button. Thanks in advance.