Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/05/2019 in all areas

  1. There is a simpler method #include <MsgBoxConstants.au3> MsgBox($MB_TOPMOST, "Topmost Message", "This message box will always be on top.")
    2 points
  2. Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip
    1 point
  3. What is Rollbar? Rollbar provides real-time error alerting & debugging tools for developers. Learn more about it at https://rollbar.com/product/ Demo: https://rollbar.com/demo/demo/ Screenshot: Instructions: (RollbarTest.au3) ; Include RollbarSDK #include "RollbarSDK.au3" ;Turns on ConsoleWrite debugging override. ;Global $Rollbar_Debug=False ; Initialize RollbarSDK with the project's API key. ; Parameters ....: $__Rollbar_sToken - [Required] Go to https://rollbar.com/<User>/<ProjectName>/settings/access_tokens/ for your project. Use the token for post_server_item. _Rollbar_Init("eaa8464a4082eeabd9454465b8f0c0af") ; Write code that causes an error you want to catch, then call ; _Rollbar_Send ; Parameters ....: $__Rollbar_sErrorLevel - [Required] Must be one of the following values: Debug, Info, Warning, Error, Critical. ; $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_Send("Debug", "This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_Send("Warning", "This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_Send("Error", "This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_Send("Critical", "This is an critical message. If you received this, you were successful!", "Critical Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!") ;No Message ; Rollbar_Send's helper functions ; Parameters ....: $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_SendDebug("This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_SendInfo("This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_SendWarning("This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_SendError("This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_SendCritical("This is an critical message. If you received this, you were successful!", "Critical Message") ; Usable Example Local $sImportantFile = "C:\NOTAREALFILE_1234554321.txt" Switch FileExists($sImportantFile) Case True MsgBox(0, "Example Script", "An important file was found. Continuing...") Case Else _Rollbar_SendCritical('An important file was missing. Halting... File: "' & $sImportantFile & '"', 'Important file "' & $sImportantFile & '" is missing.') EndSwitch Notes: Please comment your feedback, advice, & suggestions below. While this is only a proof of concept, I will expand its feature set for everyone to use. Right now, it is fully functional but not tested in production. Changelog: RollbarSDK.au3 RollbarTest.au3 v0.2 v0.1.1
    1 point
  4. I hope they found a way well before, else they should have gone bankrupt since then.
    1 point
  5. jchd

    Problem text

    Local $s = "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" Local $i = 0 Local $t = Execute("'" & StringRegExpReplace($s, "(?m)\w+\R?", "Welcome' & _Inc($i) & @CRLF & '") & "'") ConsoleWrite($t & @CRLF) Func _Inc(ByRef $n) $n += 1 Return $n EndFunc Bot? Can't you say "program"? Note that if you don't want a possible extra line termination at the end, then use that instead: Local $t = Execute("'" & StringRegExpReplace($s, "(?m)\w+(\R?)", "Welcome' & _Inc($i) & '$1' & '") & "'") Also if you want a running counter across several uses, plus the ability to reset the counter when needed, then try this: Local $s = "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" & @CRLF & "TEXT" Local $t = Execute("'" & StringRegExpReplace($s, "(?m)\w+(\R?)", "Welcome' & _RunningCount() & '$1' & '") & "'") ConsoleWrite($t & @CRLF) ConsoleWrite("Another invokation" & @CRLF) $t = Execute("'" & StringRegExpReplace($s, "(?m)\w+(\R?)", "Welcome' & _RunningCount() & '$1' & '") & "'") ConsoleWrite($t & @CRLF) ConsoleWrite("Reset count then yet another invokation" & @CRLF) _RunningCount(1) $t = Execute("'" & StringRegExpReplace($s, "(?m)\w+(\R?)", "Welcome' & _RunningCount() & '$1' & '") & "'") ConsoleWrite($t & @CRLF) Func _RunningCount($bReset = 0) Local Static $n $n = $bReset ? 0 : $n + 1 Return $n EndFunc
    1 point
  6. @Exit regarding your accessibility check see simplespy in IUIAutomation examples thread that has this code iturn accessibility on when chrome opens a new tab or when it starts ;~ Chrome accessibility looks for screenreaders when starting or opening new tab so reply that we are a screen spy ;~ https://www.chromium.org/developers/design-documents/accessibility ;~ Windows: Chrome calls NotifyWinEvent with EVENT_SYSTEM_ALERT and the custom object id of 1. ;~ If it subsequently receives a WM_GETOBJECT call for that custom object id, it assumes that assistive technology is running. Local $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword') Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadID, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadID, $iEventTime local $result=0 #forceref $result Switch $iEvent Case $EVENT_SYSTEM_ALERT if $iObjectID=1 then $result = _SendMessage($hWnd, $WM_GETOBJECT, 0, 1) consolewrite("Chrome gave a call so we replied " & $iObjectID) GUICtrlSetData($edtCtrlInfo, "Chrome gave a call so we replied " & $iObjectID & @CRLF, 1) EndIf EndSwitch EndFunc ;==>_EventProc
    1 point
  7. I know you know, but for other readers: Indeed, AutoIt will perform thru the loop as dictated by the code using e.g. string functions, applying stringizing input data as required. That's a consequence of using variants under the hood. This may seem uncomfortable or even odd, but if you compare with doing blindly the same in strict-typed languages (say C), you'd get anything from garbage out to a hard crash. In fact, in C (or other strict-typed languages) you'd have to switch according to datatype to perform only sensible operations. Advice: as far as possible store only a consistent datatype in arrays. If you really can't, just switch inside the loop using VarGetType.
    1 point
  8. Have you tried using IsObj()? That seems like an obvious choice to me. 🤨
    1 point
  9. This topic has been beaten to death way too often: *click* Jos
    1 point
  10. Could you please explain the purpose of all of this? Jos PS; everybody else stay out please until it's clear.
    1 point
  11. mikell

    Regex help

    Ah OK Try this one StringRegExp($test, '(?im)^C:\\\N*\S\N*$') It only checks "if there is a line that starts with "C:\" and it has some text after "C:\" "
    1 point
  12. mikell

    Regex help

    This one returns the n'th non-empty last line $test = 'foo' & @CRLF $test &= 'C:\' & @CRLF $test &= 'foobar' & @CRLF $test &= 'hello' & @CRLF $test &= 'C:\temp\dir' & @CRLF $test &= 'Last line with chars' & @CRLF $test &= @CRLF $test &= @CRLF $n = -2 ; number of the line to get Msgbox(0,"", StringRegExpReplace($test, '(?ms).*?(^\N*\S\N*$)\s*(?:(?1)\s*){0,' & -$n-1 & '}\z', "$1") )
    1 point
  13. iamtheky

    Regex help

    so you just need to know if that string is present or not? $test = 'foo' & @CRLF $test &= 'C:\' & @CRLF $test &= 'foobar' & @CRLF $test &= 'hello' & @CRLF $test &= 'C:\temp\dir' & @CRLF $test &= 'Last line with chars' & @CRLF $test &= @CRLF $test &= @CRLF msgbox(0, '' , StringInStr($test , 'C:\temp\dir') > 1 ? "Match" : "No Match")
    1 point
  14. Well that's easier. Lol. Thank you.
    1 point
  15. iamtheky

    Regex help

    In addition to modifying the expression, if you want the return you need to use the correct flag on stringregexp. These efforts are only better in that they return the desired result, they are not optimal. one regex, one not: $test = 'foo' & @CRLF $test &= 'C:\' & @CRLF $test &= 'foobar' & @CRLF $test &= 'hello' & @CRLF $test &= 'C:\temp\dir' & @CRLF $test &= 'Last line with chars' & @CRLF $test &= @CRLF $test &= @CRLF msgbox(0, '' , stringregexp(StringStripWS($test , 2) , @CRLF & "(.*?)" & @CRLF & ".*?\z" , 3)[0]) ;~ msgbox(0,'' , stringmid(stringstripws($test , 2) , stringinstr(stringstripws($test , 2) , @LF , 0 , -2) , stringinstr(stringstripws($test , 2) , @LF , 0 , -1) - stringinstr(stringstripws($test , 2) , @LF , 0 , -2) ))
    1 point
  16. Why not use the Ping function to do it yourself in the script? No need to waste resources slicing up the output into an array and sorting it out before processing: Global Const $HOST = "example.com" Global Const $COUNT = 4 Example() Func Example() Local $iLost = 0 Local $iCounter = 0 Do Ping($HOST) If @error Then $iLost += 1 $iCounter += 1 Until $iCounter = $COUNT Local $sMsg = StringFormat("Sent %i packets and recieved %i packets (%i lost)", $iCounter, $iCounter - $iLost, $iLost) ConsoleLog($sMsg & @CRLF) EndFunc Should work just as well
    1 point
  17. This the effect of AutoIt duck typing. Internal functions explicitely expecting a type force a conversion of the argument into the wanted type. The multiple If block can be: Switch StringLower($strVal) Case 'maximized' $strVal = @SW_MAXIMIZE Case 'minimized' $strVal = @SW_MINIMIZE Case 'normal' $strVal = @SW_RESTORE Case 'false', 'off', '0', '' $strVal = False Case Else $strVal = True EndSwitch
    1 point
  18. gcue

    Array To SQLite

    This function is to convert a 2d array to sqlite database. Improvement suggestions welcome! Original idea taken from here #include <array.au3> #include <sqlite.au3> $sqlDB = @ScriptDir & '\test.sql' FileDelete($sqlDB) _SQLite_Startup() $array = Build_Array() $array_start_index = 0 $table = "aTest" $columns = "Col1, Col2, Col3" ArrayToSQL($array, $array_start_index, $sqlDB, $table, $columns) _SQLite_Shutdown() Func ArrayToSQL($array, $array_start_index, $sqlDB, $table, $columns) Local $hDB = _SQLite_Open($sqlDB) Local $ret = _SQLite_Exec(-1, 'CREATE TABLE if not exists ' & $table & ' (' & $columns & ');') If $ret <> $SQLITE_OK Then Exit (MsgBox(0, 'SQLITE ERROR', 'Create Table Failed')) $columns_array = StringSplit($columns, ",") $num_columns = $columns_array[0] Local $sSQLHead = 'INSERT INTO ' & $table & ' VALUES ' Local $sSQLWork = $sSQLHead For $x = $array_start_index To UBound($array) - 1 $sSQLWork &= '("' For $y = 0 To $num_columns - 1 $sSQLWork &= $array[$x][$y] & '","' Next $sSQLWork = StringTrimRight($sSQLWork, 3) $sSQLWork &= '")' _SQLite_Exec($hDB, $sSQLWork) $sSQLWork = $sSQLHead Next _SQLite_Close($hDB) EndFunc ;==>ArrayToSQL Func Build_Array() Local $iNumRecs = 800 Local $aTest[$iNumRecs][3] For $i = 0 To $iNumRecs-1 $aTest[$i][0] = Random(100, 199, 1) $aTest[$i][1] = Random(500, 599, 1) $aTest[$i][2] = Random(300, 699, 1) Next Debug($aTest) Return $aTest EndFunc ;==>Build_Array Func Debug($variable1 = "", $variable2 = "", $variable3 = "", $variable4 = "") If IsArray($variable1) Then _ArrayDisplay($variable1) Else If $variable2 <> "" Then $variable1 &= @CRLF & $variable2 EndIf If $variable3 <> "" Then $variable1 &= @CRLF & $variable3 EndIf If $variable4 <> "" Then $variable1 &= @CRLF & $variable4 EndIf ClipPut($variable1) MsgBox(0, "Debug", $variable1) EndIf EndFunc ;==>Debug
    1 point
  19. Nope it only currently supports English the next update would come with an online speech recognizer which would suite your need.
    1 point
  20. You could try setting focus to the Span element before clicking it - _IEAction($oDiv1, "focus") But I would expect to see some events attached to that element. If not there, then check the parent Div elements.
    1 point
  21. Decipher

    FileExist - Trigger

    I call this work of art the file iteration simplificationer or maybe not. func _summary($sfile, $isdir) If stringinstr($sfile, "summary.txt") then ;Do Something with that file - $sfile is the fully qualified file path to bla endif if $isdir than ;Do something with it maybe? endif endfunc _FileListEx("C:Software", "_Summary") Func _FileList_Ex($s_Dir = @WorkingDir, $s_Func = "") ConsoleWrite(@CRLF & "!>Root Directory is set to " & $s_Dir & " and will be preserved." & @CRLF) Local $a_Directory_List[2] = ["", $s_Dir] __FileList_Ex($a_Directory_List, $s_Func) ConsoleWrite(@CRLF & "!> Search Finished!" & @CRLF & @CRLF) EndFunc ;==>_FileList_Ex Func __FileList_Ex(ByRef $a_Directory_List, $s_Func) ; Recursive Local $iFile = 0, $sDir = _ArrayPop($a_Directory_List) If Not IsArray($a_Directory_List) Then Return FileChangeDir($sDir) If FileExists($sDir) Then ConsoleWrite(@CRLF & ">Search: " & $sDir) Else Return EndIf Local $h_Files = FileFindFirstFile("*.*") While 1 Local $sFile = FileFindNextFile($h_Files) If @error Then If FileExists($sDir) Then ConsoleWrite(@CRLF & "+> " & $iFile & " File(s)" & @CRLF) If IsArray($a_Directory_List) Then __FileList_Ex($a_Directory_List, $s_Func) ExitLoop EndIf $iFile += 1 $sFile = _PathFull($sFile) Local $Is_Dir = False If StringInStr(FileGetAttrib($sFile), "D") Then _ArrayAdd($a_Directory_List, $sFile) $Is_Dir = True EndIf Call($s_Func, $sFile, $Is_Dir) WEnd FileClose($h_Files) EndFunc ;==>__FileList_Ex I wrote this recursive function a couple of days ago, maybe you will find it of use + just call the function with your own that way you can forget about the painful loops. *Edit You'll need these at the top of your script for it to work. #include <Array.au3> #include <File.au3> I'm really starting to hate Google Chrome....
    1 point
  22. JohnOne

    FileExist - Trigger

    Here is an example of one way you could go about your task. #include <File.au3> #include <Array.au3> ; just for testing $Path = "c:software" $Summary = "summary.txt" $iCount = 0 ; to check how many folders have been processed $AFolders = _FileListToArray($Path, "*", 2) ; lists all folders to array _ArrayDisplay($AFolders) ; just for testing While 1 ; $AFolders[0] contains the amount of folders found For $i = 1 To $AFolders[0] ; loop through all found folders If FileExists($Path & $AFolders[$i] & $Summary Then ; your summery file exists here ; you can process it, but must delete, or rename it after, or it might find it twice $iCount += 1 ; you processed a file so increase the count EndIf Next If $iCount >= $AFolders[0] Then ;you processed them all ExitLoop ; bail out of loop EndIf WEnd
    1 point
×
×
  • Create New...