Jump to content
nooneclose

[SOLVED] How do I read / get the valve of a "read only" field using the UIA UDF?

Recommended Posts

Good morning, I am having a hard time figuring out how to read or get the valve (628850) from the red squared box in the picture below. 

897281675_Screenshot(3).thumb.png.da8fc9a92e5e7cf696f4743b249c0f64.png

Here is what I have tried so far. (see code below. Also, I'm very sorry my code is sloppy.)

 

#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
                                                                        ;Allows for the combining of UDFs by disabling error messages. (I get error messages for "problems" that dont actually exsist)
#include <AD.au3>                                                       ;Allows Active Directory functions
#include <Array.au3>                                                    ;Allows special Array functions
#include <Constants.au3>                                                ;Allows constants to be used
#include <Date.au3>                                                     ;Allows Date and Time functions
#include <DateTimeConstants.au3>                                        ;Allows Date and Time constant functions
#include "DTC.au3"                                                      ;Allows Custom Date and Time functions
#include <IE.au3>                                                       ;Allows Internet Explorer functions
#include <Misc.au3>                                                     ;Allows the "is pressed" function to be used
#include <MsgBoxConstants.au3>                                          ;Allows Message box function to be used
#include <OutlookEX.au3>                                                ;Allows the Outlook functions
#include <String.au3>                                                   ;Allows special string functions
#include <StringConstants.au3>                                          ;Allows String constant functions
#include <Timers.au3>                                                   ;Allows timer functions
;#RequireAdmin                                                          ;Requests admin privliges before starting program

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <debug.au3>
#include <WinAPI.au3>
#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=N ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os


; Sets the script to accept coordinates off the program window and not the screen
AutoItSetOption('MouseCoordMode', 0)
; Defines the time it takes to send text to the software/program
AutoItSetOption('SendKeyDelay', 10)

;*******************************************************************************
; Close the script if "End" is pressed
;*******************************************************************************
Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

HotKeySet("{END}", "Terminate")
Func Terminate()
    MsgBox($MB_ICONINFORMATION, "DEATH", "AI Stoped!", 5)
    Exit
EndFunc


;*******************************************************************************
; Script has started
;*******************************************************************************
Sleep(2000)
MsgBox($MB_ICONINFORMATION, "WO_AI", "AI Started!", 5)
Sleep(1500)

;*******************************************************************************
; Main functions of the program
;*******************************************************************************

test()

;===============================================================================
; Function Definitions
;===============================================================================
Func test()

    MsgBox("", "TESTing", "Timer Started")
    Sleep(15000)
    MsgBox("", "TESTing", "timer Finished")

;~ *** Standard code maintainable ***
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=Work Order Tracking - Google Chrome;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1")    ;Work Order Tracking - Google Chrome
_UIA_setVar("oP2","Title:=Work Order Tracking;controltype:=UIA_DocumentControlTypeId;class:=Chrome_RenderWidgetHostHWND")   ;Work Order Tracking
_UIA_setVar("oP3","Title:=  Work Order Tracking;controltype:=UIA_CustomControlTypeId;class:=")  ;  Work Order Tracking
_UIA_setVar("oP4","Title:=main form;controltype:=UIA_GroupControlTypeId;class:=")   ;main form
_UIA_setVar("oP5","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
_UIA_setVar("oP6","Title:=View Work Details;controltype:=UIA_CustomControlTypeId;class:=")  ;View Work Details
_UIA_setVar("oP7","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
_UIA_setVar("oP8","Title:=Location: Location description Long Description Include Children? Include Children: unchecked Include Ancestors? Include Ancestors: unchecked Include History? Include History: unchecked Work Scope Minimize Work Scope Section Minimize Work Scope Section Work Scope Work Close Filter CTRL+Z Close Filter CTRL+Z Filter Filter Table Filter Table Next Row [CTRL+Down Arrow] Next Row [CTRL+Down Arrow] 1 - 4 of 4 Download Hide Table: Work Hide Table: Work Work Work Table Button Group;controltype:=UIA_CustomControlTypeId;class:=") ;Location: Location description Long Description Include Children? Include Children: unchecked Include Ancestors? Include Ancestors: unchecked Include History? Include History: unchecked Work Scope Minimize Work Scope Section Minimize Work Scope Section Work Scope Work Close Filter CTRL+Z Close Filter CTRL+Z Filter Filter Table Filter Table Next Row [CTRL+Down Arrow] Next Row [CTRL+Down Arrow] 1 - 4 of 4 Download Hide Table: Work Hide Table: Work Work Work Table Button Group
_UIA_setVar("oP9","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
_UIA_setVar("oP10","Title:=Work;controltype:=UIA_TableControlTypeId;class:=")   ;Work
_UIA_setVar("oP11","Title:=;controltype:=UIA_CustomControlTypeId;class:=")  ;
_UIA_setVar("oP12","Title:=Record Detail Menu;controltype:=UIA_DataItemControlTypeId;class:=")  ;Record Detail Menu

; Clicks on the main record field
_UIA_setVar("oUIElement","Title:=Record ;controltype:=UIA_EditControlTypeId;class:=") ;ControlType:=UIA_EditControlTypeId;classname:=")

; Trying to click on / get value from the 3rd from top record field (this is me trying to use the id to access the record box)
Local $otest =_UIA_getObjectByFindAll("Record.mainwindow", "id:=ma9038468_tdrow_[C\:1]_txt-tb[R\:3].;ControlType:=UIA_DataItemControlTypeId", $treescope_subtree)


;~ Actions split away from logical/technical definition above can come from configfiles

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")
;~_UIA_Action("oP7","highlight")
_UIA_Action("oP7","setfocus")
;~_UIA_Action("oP8","highlight")
_UIA_Action("oP8","setfocus")
;~_UIA_Action("oP9","highlight")
_UIA_Action("oP9","setfocus")
;~_UIA_Action("oP10","highlight")
_UIA_Action("oP10","setfocus")
;~_UIA_Action("oP11","highlight")
_UIA_Action("oP11","setfocus")
;~_UIA_Action("oP12","highlight")
_UIA_Action("oP12","setfocus")

_UIA_action("oUIElement","highlight")
_UIA_Action("oUIElement","setfocus")
_UIA_action("oUIElement","click")

Sleep(2500)

_UIA_action($otest,"highlight")
_UIA_Action($otest,"setfocus")
_UIA_action($otest,"click")


MsgBox("", "End of program", "death")

EndFunc

I'm using $otest to try and click on the box, through the id that chrome gives it, with the UIA functions. I am kind of completely new to the UIA UDF but I do find it capable of doing a lot of cool things.  :) 

as always any help would be greatly appreciated. I know how hard you people hard. Thank you for taking the time to help us. 

Edited by nooneclose

Share this post


Link to post
Share on other sites

I figured it out. :) 

Here is my finished code that collects the numbers I wanted. 

#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
                                                                        ;Allows for the combining of UDFs by disabling error messages. (I get error messages for "problems" that dont actually exsist)
#include <AD.au3>                                                       ;Allows Active Directory functions
#include <Array.au3>                                                    ;Allows special Array functions
#include <AutoItConstants.au3>
#include <Constants.au3>                                                ;Allows constants to be used
#include <Date.au3>                                                     ;Allows Date and Time functions
#include <DateTimeConstants.au3>                                        ;Allows Date and Time constant functions
#include "DTC.au3"                                                      ;Allows Custom Date and Time functions
#include <IE.au3>                                                       ;Allows Internet Explorer functions
#include <Misc.au3>                                                     ;Allows the "is pressed" function to be used
#include <MsgBoxConstants.au3>                                          ;Allows Message box function to be used
#include <OutlookEX.au3>                                                ;Allows the Outlook functions
#include <String.au3>                                                   ;Allows special string functions
#include <StringConstants.au3>                                          ;Allows String constant functions
#include <Timers.au3>                                                   ;Allows timer functions
;#RequireAdmin                                                          ;Requests admin privliges before starting program

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <debug.au3>
#include <WinAPI.au3>
#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=N ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os


; Sets the script to accept coordinates off the program window and not the screen
AutoItSetOption('MouseCoordMode', 0)
; Defines the time it takes to send text to the software/program
AutoItSetOption('SendKeyDelay', 10)

;*******************************************************************************
; Close the script if "End" is pressed
;*******************************************************************************
Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

HotKeySet("{END}", "Terminate")
Func Terminate()
    MsgBox($MB_ICONINFORMATION, "DEATH", "AI Stoped!", 5)
    Exit
EndFunc


;*******************************************************************************
; Script has started
;*******************************************************************************
Sleep(2000)
MsgBox($MB_ICONINFORMATION, "WO_AI", "AI Started!", 5)
Sleep(1500)


;*******************************************************************************
; Global Variables
;*******************************************************************************
Global $NumOfWork = 0
Global $wOrders[50]


;*******************************************************************************
; Main functions of the program
;*******************************************************************************

Sleep(10000)

FindNumber()
GetOrderNums()


;===============================================================================
; Function Definitions
;===============================================================================

; Find how many work orders are possible duplicates
; This is the number od times the test will need to loop
Func FindNumber()

    MouseClick("Left", 971, 252, 2)

    ; Left click drag from 0, 200 to 600, 700
    MouseClickDrag($MOUSE_CLICK_LEFT, 886, 296, 948, 305)

    Send("^c") ; sends ctrl+c (copy to clip)

    Local $clip = ClipGet() ; sets variable $clip to "copied text"?

    Local $String = StringSplit($clip, "of")

    $NumOfWork = $String[3]

    ; For the loops to work right
    $NumOfWork += 1

    ConsoleWrite(@CRLF & $clip & @CRLF)
    ConsoleWrite(@CRLF & $NumOfWork & @CRLF)

EndFunc


; Get all the numbers in the list
Func GetOrderNums()

    Local $count = 1

    While $count <= $NumOfWork

        If $count <= 1 Then
            AutoItSetOption("MustDeclareVars", 1)

            ; get the work order number
            _UIA_setVar("oP1","Title:=Work Order Tracking - Google Chrome;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1")    ;Work Order Tracking - Google Chrome
            _UIA_setVar("oP2","Title:=Work Order Tracking;controltype:=UIA_DocumentControlTypeId;class:=Chrome_RenderWidgetHostHWND")   ;Work Order Tracking
            _UIA_setVar("oP3","Title:=  Work Order Tracking;controltype:=UIA_CustomControlTypeId;class:=")  ;  Work Order Tracking
            _UIA_setVar("oP4","Title:=main form;controltype:=UIA_GroupControlTypeId;class:=")   ;main form
            _UIA_setVar("oP5","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
            _UIA_setVar("oP6","Title:=Problem Already Reported;controltype:=UIA_CustomControlTypeId;class:=")   ;Problem Already Reported
            _UIA_setVar("oP7","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
            _UIA_setVar("oP9","Title:=;controltype:=UIA_CustomControlTypeId;class:=")   ;
            _UIA_setVar("oP10","Title:=;controltype:=UIA_CustomControlTypeId;class:=")  ;
            _UIA_setVar("oP11","Title:=;controltype:=UIA_CustomControlTypeId;class:=")  ;
            _UIA_setVar("oP12","Title:=;controltype:=UIA_CustomControlTypeId;class:=")  ;
            _UIA_setVar("oP13","Title:=Similar Work Requests Found;controltype:=UIA_TableControlTypeId;class:=")    ;Similar Work Requests Found
            _UIA_setVar("oP14","Title:=;controltype:=UIA_CustomControlTypeId;class:=")  ;
            _UIA_setVar("oP15","Title:=Work Order ;controltype:=UIA_DataItemControlTypeId;class:=") ;Work Order

            ; Get the number
            ;~ $oUIElement=_UIA_getObjectByFindAll("WorkOrder.mainwindow", "title:=Work Order ;ControlType:=UIA_EditControlTypeId", $treescope_subtree)
            _UIA_setVar("oUIElement","Title:=Work Order ;controltype:=UIA_EditControlTypeId;class:=") ;ControlType:=UIA_EditControlTypeId;classname:=")

            Sleep(500)

            ;~_UIA_Action("oP1","highlight")
            _UIA_Action("oP1","setfocus")
            ;~_UIA_Action("oP2","highlight")
            _UIA_Action("oP2","setfocus")
            ;~_UIA_Action("oP3","highlight")
            _UIA_Action("oP3","setfocus")
            ;~_UIA_Action("oP4","highlight")
            _UIA_Action("oP4","setfocus")
            ;~_UIA_Action("oP5","highlight")
            _UIA_Action("oP5","setfocus")
            ;~_UIA_Action("oP6","highlight")
            _UIA_Action("oP6","setfocus")
            ;~_UIA_Action("oP7","highlight")
            _UIA_Action("oP7","setfocus")
            ;~_UIA_Action("oP8","highlight")
            _UIA_Action("oP8","setfocus")
            ;~_UIA_Action("oP9","highlight")
            _UIA_Action("oP9","setfocus")
            ;~_UIA_Action("oP10","highlight")
            _UIA_Action("oP10","setfocus")
            ;~_UIA_Action("oP11","highlight")
            _UIA_Action("oP11","setfocus")
            ;~_UIA_Action("oP12","highlight")
            _UIA_Action("oP12","setfocus")
            ;~_UIA_Action("oP13","highlight")
            _UIA_Action("oP13","setfocus")
            ;~_UIA_Action("oP14","highlight")
            _UIA_Action("oP14","setfocus")
            ;~_UIA_Action("oP15","highlight")
            _UIA_Action("oP15","setfocus")

            _UIA_action("oUIElement","highlight")
            _UIA_action("oUIElement","click")

            $wOrders[$count] = _UIA_action("oUIElement","getvalue")

            ; Move down by one
            Sleep(5000)
            Send("{CTRLDOWN}{DOWN}")
            Send("{CTRLUP}")
            Sleep(5000)
        Else
            _UIA_Action("oP14","setfocus")
            _UIA_Action("oP15","setfocus")
            _UIA_action("oUIElement","highlight")

            $wOrders[$count] = _UIA_action("oUIElement","getvalue")

            ; Move down by one
            Sleep(5000)
            Send("{CTRLDOWN}{DOWN}")
            Send("{CTRLUP}")
            Sleep(5000)
        EndIf

        $count += 1

    WEnd

EndFunc

_ArrayDisplay($wOrders, "Work Order Numbers")

MsgBox("", "End of program", "death")

 

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

  • Similar Content

    • By bylly
      Hello this is the code maybe you can figure it out I placed some comments to try and explain what I want
      #include <Array.au3> AnyDeskOpen() Func AnyDeskOpen() Global $aWinList = WinList("[REGEXPTITLE:(?i)(.*Anydesks*)]") ;get window name and handle from windows and store into an array $asd = $aWinList $aExtract = _ArrayExtract($asd) ; beginner babble clean this Sh** up Global $default = _ArrayToString($aExtract, "", 0, 0) EndFunc StartWait() ; check in the array to see how many windows are opened Func StartWait() While 1 AnyDeskOpen() If $Default = 1 Then Sleep (3500) Else Exitloop EndIf WEnd EndFunc If $default = "2" Then ; If two windows are opened than someone is trying to connect to that computer and needs a click to accept connection try and click accept Button in the first window and the second one by activating diffrent window handle $extra = _ArrayToString($aWinList, "", 1, 1) $sString = StringReplace($extra, "AnyDesk", "") $hGUI = $sString WinActivate(HWnd($hGUI)) winmove (HWnd($hGUI), "", 50, 50) Mouseclick ("left", 100, 500) Sleep (1500) $extra = _ArrayToString($aWinList, "", 2, 2) $sString = StringReplace($extra, "AnyDesk", "") $hGUI = $sString WinActivate(HWnd($hGUI)) winmove (HWnd($hGUI), "", 50, 50) Mouseclick ("left", 100, 500) EndIf While 1 ;up to here everything seems to work AnyDeskOpen() ; while there is a connection there are two AnyDesk windows, if we close the connection than only one window remains opened and we check the array to see how many values it has If $Default = 2 Then Sleep (3500) Else ; At this point the program exits code 0 instead of resseting to function above StartWait() Exitloop EndIf WEnd ; thank you  the intent is to keep the program going so it clicks accept again when reconnecting
    • By Colduction
      Hi guys, i want to convert WebKit/Chrome timestamps that i've found in chrome cookie database to Human-Readable time (if possible, with UTC or GMT offset).
      Example of WebKit/Chrome timestamp: 13228999534132232 Output that i want: 2020-03-18 20:16:56 This site has a tool to do this work, but i wonder how to convert this time (this timestamp's time bases are 1600/01/01) to human-readable time:
      https://www.epochconverter.com/webkit
    • By Colduction
      Hi everyone! i have Two-Problems:
      I've used this code to decode and export cookies from Google Chrome application's "C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cookie" file but i can't receive any data: #include <CryptProtect.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global Const $g_sLoc_Output = @ScriptDir & "\Cookies.txt" If FileExists($g_sLoc_Output) Then FileDelete($g_sLoc_Output) EndIf $hFO_Output = FileOpen($g_sLoc_Output ,1) If $hFO_Output <> -1 Then FileWrite($hFO_Output, Chrome()) FileFlush($hFO_Output) FileClose($hFO_Output) EndIf Func Chrome() Local $q, $r, $sOutput, $sLoc_ChromeDB = EnvGet("localappdata") & "\Google\Chrome\User Data\Default\Cookies" If FileExists($sLoc_ChromeDB) = False Then Return "" _SQLite_Startup() If @error Then MsgBox(16, "SQLite Error", "SQLite3.dll Can't be Loaded! - " & $__g_hPrintCallback_SQLite & @CRLF & @CRLF & "Exiting application") Exit -1 EndIf _SQLite_Open($sLoc_ChromeDB) _SQLite_Query(-1, 'SELECT host_key, name, value, encrypted_value FROM cookies', $q) While _SQLite_FetchData($q, $r) = 0 $sOutput = $sOutput & r[0] & @CRLF & r[1] WEnd _SQLite_Close() _SQLite_Shutdown() Return $sOutput EndFunc I've used this code too for decrypt my saved passwords and export from Google Chrome application's "C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Login Data" file but i can't get decrypted data: #include <CryptProtect.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global Const $g_sLoc_Output = @ScriptDir & "\Credentials.txt" If FileExists($g_sLoc_Output) Then FileDelete($g_sLoc_Output) EndIf $hFO_Output = FileOpen($g_sLoc_Output ,1) If $hFO_Output <> -1 Then FileWrite($hFO_Output, Chrome()) FileFlush($hFO_Output) FileClose($hFO_Output) EndIf Func Chrome() Local $q, $r, $sOutput, $sLoc_ChromeDB = EnvGet("localappdata") & "\Google\Chrome\User Data\Default\Login Data" If FileExists($sLoc_ChromeDB) = False Then Return "" _SQLite_Startup() If @error Then MsgBox(16, "SQLite Error", "SQLite3.dll Can't be Loaded! - " & $__g_hPrintCallback_SQLite & @CRLF & @CRLF & "Exiting application / Zavolej Honzovi") Exit -1 EndIf _SQLite_Open($sLoc_ChromeDB) _SQLite_Query(-1, "select * from logins;", $q) While _SQLite_FetchData($q, $r) = 0 $sOutput = $sOutput & "======================| " & $r[7] & " |======================" & @CRLF & "Login URL: " & $r[0] & @CRLF & "Email/User: " & $r[3] & @CRLF & "Password: " & _CryptUnprotectData($r[5], "") & @CRLF & @CRLF WEnd _SQLite_Close() _SQLite_Shutdown() Return $sOutput EndFunc Thanks!
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.20 contains 197 functions divided into these topics:
      window, desktop and monitor mouse and GUI GUI controls including graphical buttons (jpg, png) logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By water
      Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF.
      Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver.
      That's why I have started to create a tutorial in the wiki.
      It should describe all necessary steps from intallation to usage.

      I'm still collecting ideas for the tutorial - that's where you come into play.
      What do you expect to see in such a tutorial?
      Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments
       
      ToDo-List:
      Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).
×
×
  • Create New...