Jump to content

Recommended Posts

Posted

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.

V/r

Casey

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...