Sign in to follow this  
Followers 0
Casey

Handle Access

1 post in this topic

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

Share this post


Link to post
Share on other sites



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
Sign in to follow this  
Followers 0

  • Similar Content

    • OldGuyWalking
      By OldGuyWalking
      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. 
      Thank you.
    • SnArF
      By SnArF
      Hello,
      I,m connecting to a access mdb, it works fine except when i use a select query and the requested data does not exists, then i get an error.
      ; Example Local $dbName = @ScriptDir & "\test.mdb" $dbCon = ObjCreate("ADODB.Connection") ; Create DataBase connection $dbCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbName) $sQuery = "select * from sourcefiles where Text='test'" $result = $dbCon.Execute($sQuery) MsgBox(0, "", $result.Fields( "ID" ).Value) If "test" exists in column Text then i get the ID number from column ID
      But if it doesn't exist i get an error:
      MsgBox(0, "", $result.Fields( "ID" ).Value)
      MsgBox(0, "", $result.Fields( "ID" )^ ERROR
      If the value "test"does not exist i just want $result to be 0 or ""
      Someone an idea?
    • kcvinu
      By kcvinu
      Hi all,
      This is an UDF for working with Access(2007 above) databases. I would like to say thanks to @spudw2k for his wonderful ADODB udf. That is my inspiration. And i borrowed three functions from him. The difference of this UDF is that it is using SQL statements as parameters. So if you know the SQL, then you can easily work with this UDF.
      Functions in this UDF
      1. _Start_Connection
      2. _Close_Connection
      3. _Create_Table
      4. _Delete_Table
      5. _Alter_Table
      6. _Delete_FromTable
      7. _Insert_Data - You can use this to update or delete data
      8. _Get_Records
      This is an example. This example uses an access database named Test. It is packed with the zip file
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.0 Author: kcvinu Date : sep 2015 Script Function: Examples of Access_UDF Template AutoIt script. #ce ---------------------------------------------------------------------------- #include "Access_UDF.au3" #include <Array.au3> ; only for displaying data Example1() Func Example1() Local $MsgBox1 = MsgBox(4, "Access UDF Examples", " Starting Connection example, Ready ?") If $MsgBox1 = 6 Then ; We are starting a connection Local $Connection = _Start_Connection(@ScriptDir & "\Test.accdb;") ConsoleWrite($Connection & " Started" & @CRLF) ; Look for the function status Else Exit EndIf Local $MsgBox2 = MsgBox(4, "Access UDF Examples", " Starting Create Table example, Ready ?") If $MsgBox2 = 6 Then ; We need to create a new table Local $CreateTable = _Create_Table("CREATE TABLE TestTable(Column1 Text, Column2 Text);") ConsoleWrite($CreateTable & " Table Created" & @CRLF) Else Exit EndIf Local $MsgBox3 = MsgBox(4, "Access UDF Examples", " Starting Alter Table example, Ready ?") If $MsgBox3 = 6 Then ; We need to add a column to that table Local $AlterTable = _Alter_Table("ALTER TABLE TestTable ADD Column3 int;") ConsoleWrite($AlterTable & " Table Alterd" & @CRLF) Else Exit EndIf Local $MsgBox4 = MsgBox(4, "Access UDF Examples", " Starting Insert data example, Ready ?") If $MsgBox4 = 6 Then ; Insert some data Local $InsertData = _Insert_Data("INSERT INTO Table1([Col1], [Col2], [Col3]) VALUES ('AutoIt', 'Coding is Fun', 'AutoIt Rocks');") ConsoleWrite($InsertData & " Data inserted" & @CRLF) Else Exit EndIf Local $MsgBox5 = MsgBox(4, "Access UDF Examples", " Starting Update table example, Ready ?") If $MsgBox5 = 6 Then ; Let us update the table Local $UpdateData = _Insert_Data("UPDATE Table1 SET Col1 = 'Autoit Is Great', Col2 = 'Coding is Really Fun' WHERE Col3 = 'AutoIt Rocks';") ConsoleWrite($UpdateData & " Table Updated" & @CRLF) Else Exit EndIf Local $MsgBox6 = MsgBox(4, "Access UDF Examples", " Starting Get records example, Ready ?") If $MsgBox6 = 6 Then ; Now, collect some data Local $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Rocks' ;") _ArrayDisplay($GetData) Else Exit EndIf Local $MsgBox7 = MsgBox(4, "Access UDF Examples", " Starting Delete from Table example, Ready ?") If $MsgBox7 = 6 Then ; Let us delete the whole data from that table, but not the table Local $DeleteAll = _Delete_FromTable("DELETE FROM Table1;") ConsoleWrite($DeleteAll & " All data deleted from Table" & @CRLF) Else Exit EndIf Local $MsgBox8 = MsgBox(4, "Access UDF Examples", " Starting Delete the entire table example, Ready ?") If $MsgBox8 = 6 Then ; Now, we are going to delete the entire table Local $DeleteTable = _Delete_Table("DROP TABLE TestTable;") ConsoleWrite($DeleteTable & " Table deleted" & @CRLF) Else Exit EndIf ; Last but not least, close the connection. _Close_Connection() ConsoleWrite("Examples Over...." & @CRLF) EndFunc ;==>Example1 Here is the files. 
      Access UDF.rar
      Access UDF.zip
    • Lukeo
      By Lukeo
      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?
    • aNewLyfe
      By aNewLyfe
      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