Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/31/2020 in all areas

  1. The GUI looks like shown in the picture: It contains a main menu, a treeview in left pane that lists UI Automation elements, a listview in right pane that displays detail information for the selected element, and a splitterbar to adjust the width of the two panes. Detect element The "Detect element" main menu is used to detect elements under the mouse with function keys F1 - F4. See How to topics number 2. Left pane The left pane is a treeview that initially lists open programs and windows. Generally, the left pane shows UI Automation elements represented as treeview items. Right pane The right pane is a listview that displays detail information for the selected treeview element. The information is grouped into different types of information. Only the relevant information for each type is displayed. Invalid elements When a window is closed the elements in UIASpy becomes invalid. But the elements are not deleted in UIASpy and can still be handled and selected in the treeview. Detail information for an element that was calculated before the window was closed can still be seen in the listview. In this way it's possible for UIASpy to show information for eg. a context menu that is closed as soon as it loses focus. Listview features Listview features Help system With completion of the Help system, a lot of information has been moved from this post and other posts into the Help system. Sample code creation Sample code creation is implemented through the UI element Detail info listview page and through the Sample code main menu. Sample code creates code snippets based on data in one or more selected rows in the Detail info listview page or based on the clicked Sample code menu item. UI Automation code is largely based on COM interface objects and thus on the function ObjCreateInterface(), which is one of the advanced functions in AutoIt. The main purpose of Sample code functionality is to eliminate the complexity of ObjCreateInterface(). Sample code creation either through the Detail info listview page or through the Sample code main menu can create all the interface objects required in UI Automation code. Another purpose is of course to make it easier and faster to implement code for simple automation tasks. Through Sample code creation, you can more or less create all code in a simple automation task: Create UI Automation initial code Create condition and find application window Create condition and find control in window Get information about windows and controls Create pattern objects to perform actions Get information related to pattern objects Perform actions with pattern object methods Add a Sleep() statement if necessary Note that the UI element used in sample code is named after the selected element in the treeview. Also note that both the Sample code menu items and the sections in the Detail info listview page are placed in approximately the order they are used in a simple automation task. Sample code creation through Detail info listview page Sample code creation through Sample code main menu Supported applications Most browsers including Google Chrome To be able to spy on web content in Google Chrome it's necessary to enable accessibility by entering chrome://accessibility/ in the address bar of a new tab item, and then check the five check boxes that are located in a column in upper left corner down along the left edge. Then the accessibility tab can be closed again. It's a global setting that applies to all open and new tabs until Chrome is closed. Without accessibility enabled you are only able to investigate the outer elements of Chrome but not web content. Internet Explorer Microsoft Edge Mozilla Firefox Most Microsoft applications and applications developed with Microsoft software including Classic Windows applications based on the standard control library Modern Universal Windows Platform apps like the Windows 10 Calculator Programs implemented through .NET Framework eg. Windows Forms applications Most applications provided by major development companies Automation issues Automation issues How to topics If UI Automation or the UIASpy tool is new to you, then you should read the How to topics. Examples Examples that demonstrates the features of UIASpy: Automating Notepad. Very detailed example. Automating Notepad - Windows XP Examples about Sample code creation: Automating Notepad with Sample code - step by step Automating Notepad with Sample code - all at once Chrome - Clicking an extension. Compact summary example. Click Save As... issue in Notepad examples: Using Expand() instead of Invoke() Updates Windows 8, Windows 8.1 and Windows 10 updates Threads UI Automation UDFs contains all include files. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. UI Automation Events is about implementing event handlers and includes GUIs to detect events. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source files for UIASpy GUI. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. UIASpy.7z
    1 point
  2. Suggestion Local $clipboard = "CLIP-1 CLIR-1 SOCFU-1 CFU-1" ; ClipGet() MsgBox(0,"", StringRegExp($clipboard, "\bCFU-1\b") )
    1 point
  3. i think yer first instinct was correct jg msgbox(0, '' , clipget() == "CFU-1")
    1 point
  4. Can you confirm what you want : clipboard contains only the string "CFU-1" (nothing else) or clipboard contains the word "CFU-1" ?
    1 point
  5. Instead of using StringInStr() use StringRegExp(), then the characters before and after "CFU-1" can be assessed. This ensures that exactly "CFU-1" is present in the clipboard string. Local $clipboard = "CLIP-1 CLIR-1 SOCFU-1 1-CFU-1" ; ClipGet() If StringRegExp($clipboard, "(^|\s)CFU-1(\s|$)") Then MsgBox(0, "", "Found") Else MsgBox(0, "", "Not Found") EndIf
    1 point
  6. Well, just : If $string = "SOCFU-1" Then ... or use "==" to match exactly (case sensitive)
    1 point
  7. water

    Analyzing COM objects

    As neither AutoIt, AutoHotkey nor the Typelib Viewer return a result it seems to be a "problem" with the object. I'm not very familiar with objects of this kind, so I fear I can't help with this problem 😥
    1 point
  8. lol, Welcome to the forum @xmustaphax Opt("GUIOnEventMode", 1) ; Enable/disable OnEvent functions notifications. The above is needed for GUICtrlSetOnEvent(-1, "gocmd") to work As @markyrocks pointed, you'll need a "While loop" like: While 1 ; so is always true sleep(100) ; any value realy wend ; ..that is all as the code runs: Opt("GUIOnEventMode", 1) ; Enable/disable OnEvent functions notifications. if you wanna read the output of the command line, you'll need to capture that and the output will go ??, ...you'll need a better GUI Again, welcome to the forum and have fun coding
    1 point
  9. 1st thing its always useful to post working code. Probably why you haven't got much of a response. You definitely get more help faster if people don't have to fight a partial script just to get something to happen. I wasn't able to test the stdread portion of this but it should give you a good idea of what needs to happen. Its based off of the examples in the help file. I'd also like to add that you will probably need to play around with the output format how its displayed etc. you will more than likely overrun the input box with the output. It will probably all fit but you probably won't be able to see it all. You may want to consider a different display method (unless it automatically resizes itself which i doubt but its possible). you may also want to consider just creating a new gui that just displays the output or instead of using the ArrayToString() just use _arraydisplay(). Would probably be easier to just read it off the cmd prompt but thats just me. Goodluck. ;the UI #include <GUIConstantsEx.au3> #include <AutoItConstants.au3> GUICreate('group',@DesktopWidth,@DesktopHeight) Global $cmd = GUICtrlCreateGroup("command sender", 13, 407, 340, 80) Global $instcmdsnd = GUICtrlCreateButton("setup", 25, 422, 100, 25) GUICtrlSetFont(-1, 8.5, 400, 0, "Segoe UI", 5) GUICtrlSetOnEvent(-1, "setcmd") Global $sendcmd = GUICtrlCreateButton("send", 133, 422, 100, 25) GUICtrlSetFont(-1, 8.5, 400, 0, "Segoe UI", 5) GUICtrlSetOnEvent(-1, "gocmd") Global $getcmd = GUICtrlCreateButton("receive", 242, 422, 100, 25) GUICtrlSetFont(-1, 8.5, 400, 0, "Segoe UI", 5) GUICtrlSetOnEvent(-1, "getcmd") Global $cmdInput = GUICtrlCreateInput("", 25, 455, 318, 22) GUISetState(@SW_SHOW) ;the function While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $sendcmd gocmd() case $getcmd getcmd() case $instcmdsnd setcmd() EndSwitch WEnd Func setcmd() ;Run(@ComSpec & " /c c:\mytool\bin\commandsender.exe start ", @ScriptDir, @SW_HIDE, $stderr_child + $stdout_child) EndFunc Func gocmd() $read=GUICtrlRead($cmdInput) if $read="" Then ;Run(@ComSpec & " /c c:\mytool\bin\commandsender.exe send -t 'HELLO' ", @ScriptDir, @SW_HIDE, $stderr_child + $stdout_child) Else ;Run(@ComSpec & " /c c:\mytool\bin\commandsender.exe send -t '" & $read & "' ", @ScriptDir, @SW_HIDE, $stderr_child + $stdout_child) EndIf EndFunc Func getcmd() ;$iPID = RunWait("c:\mytool\bin\response.bat", @ScriptDir, @SW_HIDE) ;ProcessWaitClose($iPID) ;$sOutput = StdoutRead($iPID) ;$aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF) ;$sString=ArrayToString($aArray) ;GUICtrlSetData($cmdInput,$sString) EndFunc Func ArrayToString($array) Local $temp for $x=1 to UBound($array)-1 $temp&=$array[$x] & " " Next Return $temp EndFunc
    1 point
  10. zorphnog

    log4a - A logging UDF

    I routinely need to log information for my scripts. In the past, I've usually just created functions in each script to write to a log file. I also use ConsoleWrite in conjunction with SciTE a lot when I'm trying to debug scripts. After using some logging libraries for other languages (namely NLog (C#) and Java (log4j)) I decided to write a logging UDF for AutoIt. I decided to base it loosely upon the log4j and NLog libaries. I say loosely because this one is not nearly as feature rich as either one of those, but I think it still provides a nice logging interface. What can it do? Output types: Console, File, or Both. Additionally, you can configure the logger to output differently based on whether the script is compiled or not. This way you can output to the console (SciTE) while you're writing a script, and output to a log file when you've compile the script. Log levels: While I don't think it's really necessary to have this many log levels, these are the levels in ascending order of severity: Trace Debug Info Warn Error Fatal Log Filtering: The log can be enabled and disabled. There are also minimum and maximum log levels that can be configured to only show a range of log levels (i.e. a minimum level of warn would not log messages for trace, debug, or info). These filter levels can be overridden when logging a message if the need be. Error Stream: Logging can be configured to write to the stderr (i.e. ConsoleWriteError). When enabled, any log messages at the error level and above will be written to the error stream. Message Format Macros: The logging message format can be customized to your liking using the following macros: ${date} = Long date (i.e. MM/DD/YYYY HH:MM:SS) ${host} = Hostname of local machine ${level} = The current log level ${message} = The log message ${newline} = Insert a newline ${shortdate} = Short date (i.e. MM/DD/YYYY) Available Functions: Configuration Functions _log4a_SetCompiledOutput - Sets the logging output type for the compiled version of the script (Default: $LOG4A_OUTPUT_FILE) _log4a_SetEnable - Enables or disables logging messages (Default: Disabled) _log4a_SetErrorStream - Enables or disables logging of the standard error stream (Default: Enabled) _log4a_SetFormat - Configures the format of logging messages (Default: "${date} ${level} ${message}") _log4a_SetLogFile - Sets the path of the log file (Default: "<ScriptFullPath>.log") _log4a_SetMaxLevel - Configures the maximum log level to process messages (Default: $LOG4A_LEVEL_FATAL) _log4a_SetMinLevel - Configures the minimum log level to process messages (Default: $LOG4A_LEVEL_TRACE) _log4a_SetOutput - Sets the logging output type for the non-compiled version of the script (Default: $LOG4A_OUTPUT_CONSOLE) Logging Functions _log4a_Debug - Logs a message at the debug level _log4a_Error - Logs a message at the error level _log4a_Fatal - Logs a message at the fatal level _log4a_Info - Logs a message at the info level _log4a_Message - Logs a message to the configured outputs _log4a_Trace - Logs a message at the trace level _log4a_Warn - Logs a message at the warn level See the source file for full documentation of available functions. A quick example script: #include "log4a.au3" ; Enable logging and don't write to stderr _log4a_SetEnable() _log4a_SetErrorStream(False) log_messages() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${shortdate} | ${host} | ${level} | ${message}") log_messages() ; Disable logging (except for those that override) _log4a_SetEnable(False) log_messages() Func log_messages() _log4a_Trace("A TRACE message", True) ; overrides filters _log4a_Debug("A DEBUG message") _log4a_Info("A INFO message") _log4a_Warn("A WARN message") _log4a_Error("A ERROR message", True) ; overrides filters _log4a_Fatal("A FATAL message") EndFunc Without further adieu, the UDF: log4a.au3
    1 point
  11. Earthshine

    log4a - A logging UDF

    you have to add the debug, trace, etc.. type of messages you want where you want them in the code. I log lots of things. First, in your main script, include the log4a.au3 file and configure the logging for your application or main script like so: that way it will log to console if run under editor, or log to a .log file when compiled. #include "log4a.au3" #Region ;**** Logging **** ; Enable logging and don't write to stderr _log4a_SetEnable() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_TRACE) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${date} | ${host} | ${level} | ${message}") #EndRegion ;**** Logging **** Then you can do stuff like this in other modules #include-once #include <Timers.au3> #include "log4a.au3" ; #FUNCTION# ==================================================================================================================== ; Name ..........: _waitControlClick ; Description ...: Automatically wait for a control to exist. Forever or Limited ; Syntax ........: _waitControlClick($formclass, $text, $ctrl, $ctrltxt, $timeout, $delayafter ; Parameters ....: $formclass - Form Class info. ; $text - Windows Forms text to match ; $ctrl - Class of Copntrol ; $ctrltxt - Text of the Control you search for ; $timeout - [Optional] Timeout, Default = 0, millisecond timer ; $delayafter - [Optional] Time to delay after operation carried out ; Return values .: None ; Author ........: Earthshine ; Modified ......: ; Remarks .......: Waits for each button indefinatly. ; Logger found here: https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/ ; Related .......: ; Link ..........: ; Example(s) ....: _waitControlClick ('[CLASS:#32770]', 'ApplicationX - InstallShield Wizard', '[CLASS:Button; INSTANCE:1]', , '&Next >' 5000, 0) ; _waitControlClick($formclass, $text, $button2, $TD_BTN_REMOVE, 0, 0) ; _waitControlClick($formclass, $text, $button3, $TD_BTN_NEXT, 0, 500) ; _waitControlClick($formclass, $text, $button1, $TD_BTN_YES, 0, 0) ; _waitControlClick($formclass, $text, $button4, $TD_BTN_FINISH, 0, 0) ; =============================================================================================================================== Func _waitControlClick($formclass, $text, $ctrl, $ctrltxt, $timeout = 0, $delayafter = 0) _log4a_Info("_waitControlClick():Begin") _log4a_Info("Searching for Formclass: " & $formclass) _log4a_Info("Searching for Text: " & $text) _log4a_Info("Searching for Control: " & $ctrl) _log4a_Info("Searching for Ctrl Txt: " & $ctrltxt) _log4a_Info("Timeout: " & $timeout) _log4a_Info("Time Delay (after click): " & $delayafter) Local $time_run = _Timer_Init() While (1) If WinExists($formclass) Then Local $hCtrl = ControlGetHandle($text, '', $ctrl) If $hCtrl Then If ($timeout > 0) Then _log4a_Info(_Timer_Diff($time_run)) If (_Timer_Diff($time_run) > $timeout) Then _log4a_Info("ExitLoop:Timeout - " & $ctrl) ExitLoop EndIf EndIf Local $hCtrlHandle = ControlGetText($text, '', $ctrl) _log4a_Info("Control Text Search: " & $ctrltxt) _log4a_Info("Control Text Found: " & $hCtrlHandle) If ($hCtrlHandle == $ctrltxt) Then ; we got the handle, so the button is there ; now do whatever you need to do _log4a_Info("Found Formclass: " & $formclass) _log4a_Info("Found Text: " & $text) _log4a_Info("Found Control: " & $ctrl) _log4a_Info("Found Ctrl Txt: " & $ctrltxt) _log4a_Info("Timeout: " & $timeout) _log4a_Info("Time Delay (after click): " & $delayafter) _log4a_Info('Control ' & $ctrl & ' Clicked') ControlClick($formclass, '', $ctrl) If ($delayafter > 0) Then Sleep($delayafter) EndIf _log4a_Info("ExitLoop:Normal - " & $ctrl) ExitLoop EndIf EndIf EndIf WEnd _log4a_Info("_waitControlClick():End") EndFunc ;==>_waitControlClick Here is the sample script listed above, using each type of message and how you log it. The log_messages() function is only a crude example to show you the different ways you can configure the logger. Notice you call that little function to show you the log settings you are configuring. You are just supposed to use the methods provided by the UDF to log your Warnings, Errors, Information or Fatal types #include "log4a.au3" ; Enable logging and don't write to stderr _log4a_SetEnable() _log4a_SetErrorStream(False) log_messages() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${shortdate} | ${host} | ${level} | ${message}") log_messages() ; Disable logging (except for those that override) _log4a_SetEnable(False) log_messages() Func log_messages() _log4a_Trace("A TRACE message", True) ; overrides filters _log4a_Debug("A DEBUG message") _log4a_Info("A INFO message") _log4a_Warn("A WARN message") _log4a_Error("A ERROR message", True) ; overrides filters _log4a_Fatal("A FATAL message") EndFunc
    1 point
  12. 0 points
  13. JLogan3o13

    Hold Key down

    @Ghoul2020 did you notice this thread is 13 years old? I doubt the OP is hanging about hoping for an answer still. Please refrain from resurrecting ancient threads.
    0 points
×
×
  • Create New...