Bagel Posted January 19, 2021 Posted January 19, 2021 I have a GUI that I've created and a script I use with that GUI that needs to be able to pull values from input boxes, press buttons etc. When I make changes to the GUI it often reassigns control IDs to these items that I then need to retrieve and then update in the script otherwise of course it won't be able to interact with the GUI properly. I use the AutoIt v3 Window Info tool to get the new IDs to put in the script. The problem is that the Finder Tool that drag and drop over the controls and boxes in my GUI to get the IDs is EXTREMELY SLOW in pulling the information. Why does it take so long to report the information about the controls? Is there any way I can create a list of all the controls in the GUI along with their associated IDs to make the job easier? Is there an easier way I don't know about? THanks!
Moderators JLogan3o13 Posted January 19, 2021 Moderators Posted January 19, 2021 Please post your script, so we can see what you're doing. To your question (more easily answered upon you posting your code): I have personally never seen the Window Info Tool take more than a second to return info, even on very large/complex GUIs The only time you should see a control ID change is if you are rearranging the order in which said controls are created. But this should not be causing any slowness in the Window Info Tool. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Bagel Posted January 19, 2021 Author Posted January 19, 2021 Well, I can't post the code because it has some sensitive information in it that can't be disclosed. I can tell you that it has over 180 buttons, labels and input boxes along with 9 combo boxes and 93 cases in the while loop. What I've found is that if I pare down the GUI to the point where there is only a handful of these controls most of the delay is gone. There is still a slight delay when displaying the information on the controls through the Info tool. The GUI was initially generated in Koda. Here are the headers: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GuiComboBoxEx.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Inet.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode", $GUI_DOCKAUTO) I'm not using any Sleep function calls in the script though I doubt that would contribute to the issue.
Moderators JLogan3o13 Posted January 19, 2021 Moderators Posted January 19, 2021 Unfortunately, without being able to post your code (or at least a viable reproducer of the issue) there is little anyone can do but make wild guesses. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
JockoDundee Posted January 20, 2021 Posted January 20, 2021 2 hours ago, Bagel said: Is there any way I can create a list of all the controls in the GUI along with their associated IDs to make the job easier? Is there an easier way I don't know about? Maybe this could help? expandcollapse popup#include <Winapi.au3> Sleep(5000) Var_GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func Var_GetAllWindowsControls($hCallersWindow) ; Get all list of controls $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) If IsArray($aPos) Then ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]" & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>Var_GetAllWindowsControls Credit: Code hard, but don’t hard code...
Bagel Posted January 20, 2021 Author Posted January 20, 2021 JLogan, thanks for your intent to help. What's interesting is that the slowdown I see in the responsiveness of the Info tool has been noticeable since the very beginning of the development of the GUI with only 4 or 5 controls and just progressively became worse. I can't imagine what I could have done to generate it and it's something I only see when using the tool on the GUI I created. When I use it on ANY other program, no matter how large or complex it returns control/window information almost instantaneously. JockoDundee: Thank you! I was hoping to not have to resort to a brute force solution like that and it would have been a project for me to work one like that out. I am getting an undefined function error at _ArraySort($aClassList) though. It's given me lots of ideas though and I'm going through how it works now.
JockoDundee Posted January 20, 2021 Posted January 20, 2021 1 hour ago, Bagel said: I am getting an undefined function error at _ArraySort($aClassList) though. You need to include <Array.au3>, not sure why it’s not in the source. Code hard, but don’t hard code...
Zedna Posted January 21, 2021 Posted January 21, 2021 (edited) Try to disable Windows Aero theme. If it helps then add this to your controls (to disable Windows theme on each control in your GUI): DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($ctrl_id), "wstr", "", "wstr", "") Edited January 21, 2021 by Zedna Earthshine 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
Earthshine Posted January 21, 2021 Posted January 21, 2021 (edited) my crystal ball says you should post simple gui with only 4-5 controls on it here so we can test and see what happens in our dev environments. as stated above, all other stuff is just wild guesses. if that is too much work for you--or you just can't be arsed--then I guess you don't want any real help anyway. I used examples from this post and the 64bit and 32 bit info tool were lightning fast an educated guess says your windows environment is hosed--or you have something interfering with AutoIt Edited January 21, 2021 by Earthshine My resources are limited. You must ask the right questions
Bagel Posted January 28, 2021 Author Posted January 28, 2021 Sorry for the slow follow up. After looking into the code that Jocko posted it occurred to me that I could simply record the control IDs. What I did was create a function in my script that when called creates a text file and writes variable names and associated control IDs as well as some surrounding code I need in the file. When I need to fix any of the IDs I can simply copy the whole block of text from the file and paste it into my other script. When I have a bit more time I want to continue investigating this though. Apparently I'm the only one on the planet with this issue. The idea regarding Windows Aero is interesting. I've tried monitoring Task Manager while using the info tool and see absolutely nothing unusual in CPU or memory usage. I've tried creating a simple GUI with just a few controls and I still have the same issue with the info tool. I think it's important to get it resolved eventually, after all, if there's something in my system that's interfering with the info tool then maybe it's also impacting the performance of the GUI I've developed in other subtle ways. Thanks for the suggestions.
Zedna Posted January 29, 2021 Posted January 29, 2021 It's documented (also on this forum) that there were some (big) performance problems on "Aero enabled systems" when using some graphic related Windows API functions. As far as I can remember it was GetPixel, but that problem can be theoretically related to more system API functions. That's why I recomeended to try to disable Aero to exclude this suspicion. Resources UDF ResourcesEx UDF AutoIt Forum Search
Earthshine Posted January 29, 2021 Posted January 29, 2021 (edited) Create a virtual machine and test it on the virtual machine if it works there that it’s your windows installatioN or try on another pc or! Post your test GUI code so it can be observed by others. He’s not willing to do any of these things so he’s never going to get an answer. Only guessing Edited January 29, 2021 by Earthshine My resources are limited. You must ask the right questions
Bagel Posted February 1, 2021 Author Posted February 1, 2021 Thanks for the suggestions. And the virtual machine idea is great. I'll be able to investigate more when I have the time and post back here about what I find.
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