I want to click on a button that is inside a custom ToolBar on a nonAutoIT created form. I've been using MouseClick but that fails if the toolbar is detached or if the form is resized.
There is no ID associated with the toolbar but there is a handle. I'm thinking that to get the handle I need a ControlID but that only gets me to the toolbar and I'd then need to have a way to identify the position of a button in order to click on it.
I'd found a discussion about identifying the position of a noname button by, I believe, it's Tip text back in December but I can't find it now. Memory is a bit fuzzy on how I even got to the topic because at the time I was searching for something else. I'll continue to search but if anyone has seen the topic, or knows of another solution could you please point me in that direction.
The problem with not knowing the answer is not knowing the correct question to ask to find the answer. This is the exact predicament that I find myself at this moment so I will do my best to put order to some abstract thoughts.
Given the function ControlGetHandle by definition retrieves the internal handle of a control. Let’s assume for the sake of argument that I have turned off UAC on both my test system and my problem system and that both systems are Windows 7 x86.That regardless of whether I have #RequireAdmin at the beginning of my script, that the results are the same on my test system.
That the lines of code that I am having difficulty with are as follows
$d = 0 Do $TestX = ControlFocus("Pxl", "Database has expired for", "Button1") $TestXa = ControlGetHandle("Pxl", "Database has expired for", "Button1") If $TestXa <> 0 Then ControlClick("Pxl", "Database has expired for", "Button1") Sleep(2000) EndIf $d = $d + 1 Until $d = 7 What I am seeing happen is that on a test system, this works and I am able to interact with this button. However, if I take this same code to another system that has this client software installed, I cannot. I checked to see what was going on by doing the following:
$Hope=WinExists("Pxl", "Database has expired for") MsgBox(0,"","If equals one window can be seen = " & $Hope) MsgBox(0,"",WinGetText("Pxl", "Database has expired for")) The result was a zero with no text being returned on the problem system. I then had the client software uninstalled and reinstalled making sure that elevated permissions were used. Following the reinstall, WinExists returned a 1, the text was returned, and the automation was successful. Sunshine, puppies and unicorns all day long.
Two days later, on this same system, WinExists went back to being a zero for some unexplained reason. After doing an uninstall / reinstall routine again, WinExists still returns a zero. The fairy tale ended.
Part of me wants to believe that it is an issue with the client installer but the other part fails to understand why it would just stop working or why on another system of the same OS persuasion, it runs flawlessly for 5,000 executions.
To take this a step farther, if I run the Client software on the problem system as an administrator, WinExists returns a 1. So what would make a control that was previously available to a standard user session suddenly only want to give up its information when run as administrator? Why would one install work for 2 days and then break? Then have another install not work?
So if I am making sense to this point, I have to ask, what I am missing? I have a reliable test where neither the script nor the client application need to be run as administrator yet I have this problem on other systems.
Are there other factors that would create this behavior in AutoIt other than UAC?
If I wanted to search the internet to find articles on how AutoIt retrieves the handles or better yet how the handles are exposed to the user session, what would I really search for? I have looked at process explorer and I see an access column if I turn on handles but it is my understanding that this is the access that was requested at the time the handle was created and is aimed at what the control is allowed to do but not who can access the information of the control. I am guessing that this possibility of access to the handle exists as it is the only conclusion that fits with what I am seeing, or am I wrong? This last question is what drove me to ask this question in the forum as I am having no success in understanding the concept of how this happens or what to search for. Any ideas?
As a side note, here is what the info tool exposes about the button:
>>>> Window <<<< Title: Pxl Class: #32770 Position: 477, 412 Size: 326, 161 Style: 0x94C801C5 ExStyle: 0x00010101 Handle: 0x00200880 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 2 Text: OK Position: 226, 96 Size: 88, 26 ControlClick Coords: 22, 14 Style: 0x50030000 ExStyle: 0x00000004 Handle: 0x00130752 >>>> Mouse <<<< Position: 728, 547 Cursor ID: 0 Color: 0xDBDBDB >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< OK Database has expired for >>>> Hidden Text <<<<
P.S. Thank you Jon for getting my access restored.
I am trying to send external commands to a flash player in an iframe. I need to get a handle on it in a browser opened by the $oIE.navigate method.
is there a way that this can be done?
I'm trying to make a desktop wallpaper application with video support.
But stuck at z-order.
Any suggestions? How to put autoit window before desktop listview?
I'm currently attaching window to the WorkerW. also tried the $HWND_BOTTOM const of _WinAPI_SetWindowPos but when i apply this, win goes invisible.
no luck yet any help will be appreciated
I'm making a something like the Windows 7-app Sticky-note consisting of unspecified numbers of "note"-GUIs with RichEdits in them.
The problem I'm facing is that for the RichEdit to work it requires the hWnd of its GUI (which can be solved by just having a variable that's getting replaced as new "notes" are being made), but the next problem is to read the handle/ID of the RichEdit for further functions.
This is what it looks like atm:
#cs Unlimited, controlable windows #ce Opt("GUIOnEventMode", 1) Opt("TrayMenuMode", 1 + 2) Opt("TrayOnEventMode",1) #include <array.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <TrayConstants.au3> #include <GuiRichEdit.au3> TrayCreateItem("LAN-notes") TrayItemSetState(-1, $TRAY_DISABLE) TrayCreateItem("") TrayCreateItem("New") TrayItemSetOnEvent(-1, "New") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"TrayExit") TraySetState(1) $hWnd = GUICreate("",0,0) GUISetState(@SW_HIDE,-1) Call("New") while 1 Sleep(10) #cs $GUI_CurrentSize = WinGetPos($hGui) If $GUI_CurrentSize <> $GUI_PrevSize Or $GUI_CurrentSize <> $GUI_PrevSize Then _WinAPI_MoveWindow($Edit1,0,20,$GUI_CurrentSize-20,$GUI_CurrentSize-60) $GUI_PrevSize = $GUI_CurrentSize $GUI_PrevSize = $GUI_CurrentSize EndIf #ce WEnd Func New() $p = GUICreate("LAN-notes - ",200,200,Default,Default,BitOR($ws_sizebox,$WS_MINIMIZEBOX),Default,$hWnd) $winlist = WinList("LAN-notes") GUISetOnEvent($GUI_EVENT_CLOSE, "MainEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainEvents") GUICtrlCreateButton("+",0,0,20,20) GUICtrlSetFont(-1,12) GUICtrlSetOnEvent(-1,"New") GUICtrlCreateButton("Save",22,0,35,20) GUICtrlSetOnEvent(-1,"Save") ;GUICtrlCreateButton("Test", 50,80) ; GUICtrlSetOnEvent(-1,"Test") GUICtrlCreateInput("",60,0,105,20) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateButton("Edit",165,0,35,20) GUICtrlSetOnEvent(-1,"EditProjName") _GUICtrlRichEdit_Create($p, "",0,25,180,160, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_WANTRETURN,$ES_MULTILINE)) GUISetState() EndFunc Func Test() $winlist = WinList("LAN-notes") _ArrayDisplay($winlist) EndFunc Func MainEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE If WinExists("LAN-notes") Then If MsgBox(4,"Exit?","You sure you want to close this note?") = 6 Then GUIDelete(@GUI_WinHandle) EndIf EndSelect EndFunc Func EditProjName() ConsoleWrite("Edit projName" & @CRLF) If GUICtrlGetState(@GUI_CtrlId-1) = 144 Then GUICtrlSetState(@GUI_CtrlId-1,$GUI_ENABLE) GUICtrlSetData(@GUI_CtrlId,"Done") Else WinSetTitle(@GUI_WinHandle,"","LAN-notes - " & GUICtrlRead(@GUI_CtrlId-1)) GUICtrlSetState(@GUI_CtrlId-1,$GUI_DISABLE) GUICtrlSetData(@GUI_CtrlId,"Edit") EndIf EndFunc Func Save() ConsoleWrite("--> Save" & @CRLF) ConsoleWrite(_GUICtrlRichEdit_GetText(@GUI_CtrlId+4) & @CRLF) EndFunc Func TrayExit() ConsoleWrite("TrayExit") Exit EndFunc