Leaderboard
Popular Content
Showing content with the highest reputation on 10/16/2019 in all areas
-
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.zip1 point
-
I was asking @eltorro serveral times for any support for XML DOM wrapper (COM) - with no success So I took matters into my hands ..... I want to present XMLWrapperEx.au3 - BETA Version Want to join to the project ? Here is some description: ; #INDEX# ======================================================================================================================= ; Title .........: XMLWrapperEx.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: Functions to use for reading and writing XML using msxml. ; Remarks .......: BETA Version ; Author ........: mLipok ; Version .......: "1.1.1.01" ; _XML_MiscProperty_UDFVersion() #CS This UDF is created on the basis of: https://www.autoitscript.com/forum/topic/19848-xml-dom-wrapper-com/ For this reason, I attach also the last known (to me) previous version ($_XMLUDFVER = "1.0.3.98" _XMLDomWrapper_1.0.3.98_CN.au3 ) For the same reason I continue to recognize the achievements of the work of my predecessors (they are still noted in each Function header). . . . . !!!!!!!!! This is BETA VERSION (all could be changed) !!!!!!!!! . . . WORK IN PROGRES INFORMATION: For now 2015-09-01 the descripion (Function Header) can not entirely correctly describe the function. TODO: in many places I used "TODO" as a keyword to find what should be done in future . I want to: PREVENT THIS: The unfortunate nature of both the scripts is that the func return results are strings or arrays instead of objects. . I want to: USE THIS CONCEPT: . All function should use Refernce to the object as first Function parameter . All function should return in most cases objects. There should be separate functions to Change Object collection to array . All function should use COM Error Handler in local scope. . All function should return @error which are defined in #Region XMLWrapperEx.au3 - @ERROR Enums . All function should have the same naming convention . All variables should have the same naming convention . There should not to be any Global Variable - exception is $g__oXMLDOM_Events . It should be possible easy to use XML DOM Events . https://msdn.microsoft.com/en-us/library/ms764697(v=vs.85).aspx . It should be possible easy to Debug . Ultimately, you should be able to do anything with your XML without having to use your own Error Handler. #CE More info inside zip archive. This UDF can be downloaded from here: REMARK: This UDF was formerly named: XMLWrapperEx.au31 point
-
Hi, This UDF originaly started in this thread, on the latest post you can find rasim's examples and my initial BlockInputEx udf example. But eventualy i improved the UDF and i thought that it would be better to place it here, in Examples forum. This UDF supports few features that built-in BlockInput() function does not. Here is a quick "features list" if you can call it like this : Block seperately mouse or keyboard input.Block specific keyboard/mouse keys/clicks. [+] Not only hex keys are supported, string keys (such as {ENTER}) is also valid.Block all keyboard/mouse keys *except* specific keys/events.Block keys by CLASS Name (see UDF documentation).Block inputs only for specific window.BlockInput does not re-enables input after pressing Ctrl+Alt+Del.Note: This UDF, same as built-in BlockInput function, can not block Ctrl+Alt+Del, however, it will not re-enable the input. Example #1 (hWindows usage): #include <BlockInputEx.au3> ;================== hWindows usage Example ================== HotKeySet("{ESC}", "_Quit") ;This will trigger an exit (on any window except the window of Notepad). Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE) WinWait("[REGEXPCLASS:Notepad.*]") $hNotepad_Wnd = WinGetHandle("[REGEXPCLASS:Notepad.*]") ControlSetText($hNotepad_Wnd, "", "", _ "Now try to input some keys in here..." & @CRLF & _ "Well, that's the idea, you can't, don't you?" & @CRLF & @CRLF & ":)") ;Here we block *All* keyboard keys for specific window (in this case the Notepad's window). _BlockInputEx(3, "", "", $hNotepad_Wnd) ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncExample #2 (CLASSes usage): #include <BlockInputEx.au3> ;================== CLASSes usage Example ================== HotKeySet("{ESC}", "_Quit");This will trigger an exit ;Here we block Numeric keyboard keys, "Test" string (every char in this group), and UP / DOWN arrow keys. _BlockInputEx(3, "", "[:NUMBER:]|[Test]|{UP}|{DOWN}") ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncDownload (In the archive there is 11 nice examples including the two above): BlockInputEx_UDF_1.8.zip BlockInputEx_UDF_1.6.zip _BlockInputEx_UDF_1.5.zip _BlockInputEx_UDF_1.4.zip _BlockInputEx_UDF_1.3.zip _BlockInputEx_UDF_1.2.zip _BlockInputEx_UDF_1.1.zip _BlockInputEx_UDF.zip Enjoy! ================================================================= ChangeLog:1 point
-
RegExp - Remove white spaces before and after coma
FrancescoDiMuro reacted to iamtheky for a topic
an irregular straight to array version #include <Array.au3> local $a[0] , $s = "TDM111A5, RCT222Y5/ 7 ; FDT444E4 /8 , ABC222R5" _ArrayAdd($a , StringReplace(StringStripWS($s , 4) , "," , ";") , "" , ";") _ArrayDisplay($a)1 point -
RegExp - Remove white spaces before and after coma
FrancescoDiMuro reacted to mikell for a topic
Straight-to-array version #include <Array.au3> $s = "TDM111A5, RCT222Y5/ 7 ; FDT444E4 /8 , ABC222R5" $a = StringRegExp($s, "\h*([^,;]+)\h*", 3) _ArrayDisplay($a)1 point -
What does ConsoleWrite($oWorkbook.Path & @CRLF) return?1 point
-
You're welcome! You could simplify it by doing something like this: set() Func set() ;Set COM error handler $oComErr = ObjEvent("AutoIT.Error", "com_error_handler") $conn = ObjCreate( "ADODB.Connection" ) $DSN = "xxx" $conn.Open($DSN) If @error Then MsgBox(4096, "COM Error Detected", $oComErr.description) EndFunc Func com_error_handler($oError) Return EndFunc1 point
-
I bet those 9/10 had COM error handlers defined. In order to be able to process @error after the COM statement, you need to have a COM error handler. Lookup the ObjEvent() function in the Help File, especially example 2 if you just want to be able to process @error.1 point
-
Check the state of multiple radio buttons.
pixelsearch reacted to Nas for a topic
Thanks, guys, I was thinking there's a grouping variable that I can check with, but my code is really huge so I end up doing it this way : Local $Checked = 0 $Checked = GUICtrlRead($SP01) + GUICtrlRead($SP02) + GUICtrlRead($SP03) + GUICtrlRead($SP05) + GUICtrlRead($SP07) + GUICtrlRead($SP08) + GUICtrlRead($SP09) + GUICtrlRead($SP10) + GUICtrlRead($SP11) $Checked += GUICtrlRead($H03) + GUICtrlRead($H04) + GUICtrlRead($H05) + GUICtrlRead($H06) + GUICtrlRead($H07) + GUICtrlRead($H08) + GUICtrlRead($H09) if $Checked = 64 then MsgBox(16, "Error", "You did not choose any server.") EndIf 1 point -
We have discussed solutions already a couple of times but I don't think it would be a good idea to deny access to these forums for other groups. Especially Examples contains a wealth of information for starters. It is just on click to get the topic moved and standard post added, so it's not that much work anymore these days. Jos Jos1 point
-
[SOLVED] Taskbar icons coordinates
newbie2019 reacted to InnI for a topic
#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ Global $pElement, $pCondition, $pElementArray, $iElements, $vValue ; Get taskbar handle $hCtrl = ControlGetHandle("[Class:Shell_TrayWnd]", "", "MSTaskListWClass1") ; Get UIAutomation object $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) ; Get taskbar element $oUIAutomation.ElementFromHandle($hCtrl, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) ; Get condition (ControlType = Button) $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) ; Find all buttons $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iElements) ; Get array of buttons Global $aElements[$iElements] For $i = 0 To $iElements - 1 $oElementArray.GetElement($i, $pElement) $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) Next ; Get name and position for each button $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") For $i = 0 To UBound($aElements) - 1 $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) ConsoleWrite("Name:" & $vValue) $aElements[$i].CurrentBoundingRectangle($tRect) ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF) Next1 point -
Storing a random password that is not able to be retrieved untill a later date
Musashi reacted to abberration for a topic
Encrypt the password with your own key (memorize it) using _Crypt_EncryptData and print out the encrypted password string on paper then put it in a safe deposit box, put it under insulation in your attic, seal it up and bury it in the woods, etc. Get creative.1 point -
Check the state of multiple radio buttons.
pixelsearch reacted to spudw2k for a topic
If it were me, I'd opt for an event based solution which tracks the last clicked radio button. Depending on how complex your code is, converting it to OnEventMode instead of using a GUIGetMsg loop may not be cut and dry, but might be worth considering. #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Local $aIdSP[20], $bChecked, $idChecked, $y = 10 GUICreate("Example", 190, (UBound($aIdSP) + 1) * 25 + 20) For $i = 0 To UBound($aIdSP) - 1 $aIdSP[$i] = GUICtrlCreateRadio("SP0" & $i, 40, $y, 110, 20) GUICtrlSetOnEvent(-1, "_RadioEvent") ;<========= $y += 25 Next Local $idSubmit = GUICtrlCreateButton("Submit", 40, $y, 110, 30) GUICtrlSetOnEvent(-1, "_SubmitButtonEvent") ;<========= GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;<========= GUISetState() While 1 ;~ $iMsg = GUIGetMsg() ;~ Switch $iMsg ;~ Case $GUI_EVENT_CLOSE ;~ ExitLoop ;~ Case $idSubmit ;~ $idChecked = "" ;~ $bChecked = False ;~ For $i = 0 To UBound($aIdSP) - 1 ;~ If BitAND(GUICtrlRead($aIdSP[$i]), $GUI_CHECKED) = $GUI_CHECKED Then ;~ $bChecked = True ;~ $idChecked = $aIdSP[$i] ;~ ExitLoop ;~ EndIf ;~ Next ;~ If $bChecked Then MsgBox(4096, "Selected", GUICtrlRead($idChecked, 1) & " is selected.") ;~ EndSwitch sleep(10) ;<========= WEnd Func _RadioEvent() $idChecked = @GUI_CtrlId EndFunc Func _SubmitButtonEvent() If $idChecked Then MsgBox(4096, "Selected", GUICtrlRead($idChecked, 1) & " is selected.") EndFunc Func _Exit() Exit EndFunc1 point -
Automate MSI Install > Wrap with Creds & Convert to Exe
MinatorMash reacted to abberration for a topic
You may want to look at the command FileInstall to build the setup file into your exe. You can extract it to a temporary folder and delete it after the program has been installed. You are not converting it to an exe, but you will have everything built into your autoit exe.1 point -
IUIAutomation MS framework automate chrome, FF, IE, ....
Professor_Bernd reacted to junkew for a topic
Quickstart Unzip the 2 zips (UIA*.zip and examples*.zip) of post #1 Start simplespy.au3 Hover your mouse over the element you want to handle Press ctrl+w Copy / paste the given source to a new AutoIT script If you need help ask for help in new thread in general support section and post screenshot that shows your element is highlighted with simplespy post output of simplespy with all properties attached log.txt if available in your script directory use allways contents of latest zip files which could be work in progress (WIP) zip As you will not come far if you do not understand the basics first do this Understand AutoIT http://www.autoitscript.com/autoit3/docs/tutorials/helloworld/helloworld.htm http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm http://www.autoitscript.com/autoit3/docs/tutorials/notepad/notepad.htm Understand testing frameworks and related concepts http://en.wikipedia.org/wiki/Test_automation http://safsdev.sourceforge.net/FRAMESDataDrivenTestAutomationFrameworks.htm http://en.wikipedia.org/wiki/Keyword-driven_testing http://ewildsch.home.xs4all.nl/testautomation.htm If you understand above learn the basic way of setting focus and clicking thru UIA and the wrappers Understand IUIAutomation wrappers and framework Lets do the QuickStart steps as described above on the Start Button of Windows You will get this *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=;controltype:=Pane;class:=Shell_TrayWnd", $treescope_children) _UIA_Action($oP0,"setfocus") _UIA_setVar("Starten.mainwindow","title:=Starten;classname:=Button") _UIA_action("Starten.mainwindow","setfocus") This code is not yet perfect (and simplespy will improve over time) and you will have to change still manually _UIA_setVar is only used to get a "logical" name for a technical description There are many ways for UIA which varies from simple thru the wrappers to advanced based on the CUIAutomation2.au3 This is better coded #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP0 $oP0=_UIA_action("Title:=;controltype:=Pane;class:=Shell_TrayWnd", "getobject") _UIA_Action($oP0,"move") _UIA_action("title:=Starten;classname:=Button;controltype:=Button","move") _UIA_action("title:=Starten;classname:=Button;controltype:=Button","invoke") ;~ _UIA_action("title:=Start.*;classname:=Button;instance:=2","move") ;~ _UIA_action("title:=Start.*;classname:=Button;instance:=2","invoke") Exercise Learn first to automate some simple stuff on notepad.exe and calc.exe by starting those applications and with ctrl+w within simplespy try some code snippets See for latest examplecode the zip in first post Example 1 Iterating thru the different ways of representing the objects in the tree a. Autoit WinList function b. UIAutomation RawViewWalker c. UIAutomation ControlViewWalker d. UIAutomation ContentViewWalker e. Finding elements based on conditions (based on property id, frequently search on name or classname) ;~ Example 1 Iterating thru the different ways of representing the objects in the tree ;~ a. Autoit WinList function ;~ b. UIAutomation RawViewWalker ;~ c. UIAutomation ControlViewWalker ;~ d. UIAutomation ContentViewWalker ;~ e. Finding elements based on conditions (based on property id, frequently search on name or classname) #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include "CUIAutomation2.au3" #include "UIAWrappers.au3" #AutoIt3Wrapper_UseX64=Y ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os ;~ To prevent some FAQ questions consolewrite("*** Some important settings you can find in " & @scriptdir & "\UIA.CFG ***" & @CRLF) consolewrite("*** " & _UIA_getVersionInfoString() ) consolewrite("*** If logging is turned on you can find it here :" & _UIA_getVar("logFileName") & @CRLF) samplewinlist() sampleTW(1) sampleTW(2) sampleTW(3) ConsoleWrite("**** Desktop windows ****" & @CRLF) findThemAll($UIA_oDesktop, $TreeScope_Children) ConsoleWrite(@CRLF & "**** All childs of the taskbar ****") $oTaskBar = _UIA_gettaskbar() findThemAll($oTaskBar, $treescope_subtree) ConsoleWrite(@CRLF & "**** Deal with browser windows ****" & @CRLF) Local $myBrowser ;- Just get the first browser we can find $myBrowser=getBrowser() $tReturn=MsgBox($MB_SYSTEMMODAL + $MB_OKCANCEL , "Title", "Make sure you have 2 chrome browsers open otherwise press X button to abort.") if $tReturn<>$IDOK Then ConsoleWrite(@CRLF & "**** ABORTING chrome browser demo ****" & @CRLF) exit EndIf consolewrite(@CRLF & "**** Continue with finding 2 browser windows ****" & @CRLF) ;- Just get the first browser we can find of this type $browserType= "Google Chrome" ;~ $browserType= "Internet Explorer" ;~ $browserType= "Opera" $myBrowser=getBrowser($browserType,1) if isobj($myBrowser) Then consolewrite("Yes found first browser " & @CRLF) endif ConsoleWrite(@CRLF & "**** Deal with 2nd browser window****" & @CRLF) ;- Just get the 2nd browser we can find of this type $myBrowser=getBrowser($browserType,2) if isobj($myBrowser) Then consolewrite("Yes found second browser " & @CRLF) Else consolewrite("No 2nd browser found so unable to focus and highlight " & @CRLF) exit endif _UIA_Action($myBrowser,"setfocus") _UIA_Action($myBrowser,"highlight") Func sampleWinList() ConsoleWrite("sample winlist (title not empty and visible windows only)" & @CRLF) Local $hTimer = TimerInit() Local $var = WinList() For $i = 1 To $var[0][0] ; Only display visble windows If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then ConsoleWrite($i & ": Title=" & $var[$i][0] & @TAB & "Handle=" & $var[$i][1] & " Class=" & _WinAPI_GetClassName($var[$i][1]) & @CRLF) EndIf Next Local $fDiff = TimerDiff($hTimer) Consolewrite("SampleWinList took: " & $fDiff & " milliseconds" & @CRLF & @CRLF) EndFunc ;==>sampleWinList Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func getBrowser($browserName="",$browserIndex=1) local $iBrowserIdx=0 ;- Create treewalker $UIA_oUIAutomation.RawViewWalker($UIA_pTW) $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker) If IsObj($oTW) = 0 Then MsgBox(1, "UI automation treewalker failed", "UI Automation failed failed", 10) EndIf ;~ Get first element $oTW.GetFirstChildElement($UIA_oDesktop, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) ;~ Iterate all desktopwindows While IsObj($oUIElement) = True local $tName= _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) Local $tHandle= Hex(_UIA_getPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId)) Local $tClassName= _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) ;~ Browser normally put their browsername after the - (so this fails when multiple - are in title so thats why we search from right) local $tStr=stringmid($tname,stringinstr($tName,"-", $STR_NOCASESENSE, -1)+2) ;- See if its a browser (based on title it could be done on class but preferred logical name instead of a classname) ;~ Private modes diffferent title to deal with only IE misbehaves ;~ InPrivate - Internet Explorer - [InPrivate] ;~ InPrivate - [InPrivate] ?- Microsoft Edge ;~ Google Chrome (Incognito) ;~ Mozilla Firefox (Private Browsing) ;~ Privé-browsen - Opera< ;~ Fix misbehave if $tStr="[InPrivate]" then $tStr="Internet Explorer" if stringinstr($tStr," (") then $tStr=stringleft($tstr,stringinstr($tStr," (")-1) EndIf ;~ consolewrite("location: " & stringinstr($tName,"-", $STR_NOCASESENSE, -1) & "<" & $tstr & "><" & $tname & "><" & $tclassname & "><" & $tHandle & ">"& @CRLF) $itsABrowserTitle=stringinstr("Google Chrome,Internet Explorer,Mozilla Firefox,Microsoft Edge,Opera",$tStr,$STR_NOCASESENSE ) if $itsABrowserTitle > 0 then ;~ consolewrite("** Potential match ** " & $tStr & ":" & $browserName& @tab & $tname & @tab & $tclassname & @CRLF) if ($browserName=stringleft($tStr,stringlen($browsername))) or ($browserName="") Then ;~ consolewrite("** match ** " & $tStr & ":" & $browserName& @tab & $tname & @tab & $tclassname & @CRLF) $iBrowserIdx=$iBrowserIdx+1 ;~ consolewrite($browserIndex & $iBrowserIdx) if $iBrowserIDX=$browserIndex Then return $oUIElement endif EndIf EndIf $oTW.GetNextSiblingElement($oUIElement, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) WEnd EndFunc ;==>sampleTW Func sampleTW($t) ConsoleWrite("initializing tw " & $t & @CRLF) Local $hTimer = TimerInit() Local $i=0 ;~ ' Lets show all the items of the desktop with a treewalker If $t = 1 Then $UIA_oUIAutomation.RawViewWalker($UIA_pTW) If $t = 2 Then $UIA_oUIAutomation.ControlViewWalker($UIA_pTW) If $t = 3 Then $UIA_oUIAutomation.ContentViewWalker($UIA_pTW) $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker) If IsObj($oTW) = 0 Then MsgBox(1, "UI automation treewalker failed", "UI Automation failed failed", 10) EndIf $oTW.GetFirstChildElement($UIA_oDesktop, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) While IsObj($oUIElement) = True ConsoleWrite($i & "Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Handle=" & Hex(_UIA_getPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId)) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @CRLF) $oTW.GetNextSiblingElement($oUIElement, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $i=$i+1 WEnd Local $fDiff = TimerDiff($hTimer) Consolewrite("Sample tw " & $t & " took: " & $fDiff & " milliseconds" & @CRLF & @CRLF) EndFunc ;==>sampleTW Func findThemAll($oElementStart, $TreeScope) Local $hTimer = TimerInit() ;~ Get result with findall function alternative could be the treewalker Dim $pCondition, $pTrueCondition Dim $pElements, $iLength $UIA_oUIAutomation.CreateTrueCondition($pTrueCondition) $oCondition = ObjCreateInterface($pTrueCondition, $sIID_IUIAutomationCondition, $dtagIUIAutomationCondition) ;~ $oCondition1 = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationCondition) ;~ Tricky to search all descendants on html objects or from desktop/root element $oElementStart.FindAll($TreeScope, $oCondition, $pElements) $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oAutomationElementArray.Length($iLength) For $i = 0 To $iLength - 1; it's zero based $oAutomationElementArray.GetElement($i, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) ConsoleWrite("Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @CRLF) Next Local $fDiff = TimerDiff($hTimer) Consolewrite("Findthemall took: " & $fDiff & " milliseconds" & @CRLF & @CRLF) EndFunc ;==>findThemAll edit 21 aug 2014 Added quick start stuff1 point -
Using #AutoIt3Wrapper_Res_Fileversion info in script
ioa747 reacted to AdmiralAlkex for a topic
IniRead() anyone? #cs [FileVersion] #ce #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=1.0.0.2 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** MsgBox(0, "Version:", _GetVersion()) Func _GetVersion() If @Compiled Then Return FileGetVersion(@AutoItExe) Else Return IniRead(@ScriptFullPath, "FileVersion", "#AutoIt3Wrapper_Res_Fileversion", "0.0.0.0") EndIf EndFunc1 point -
Check\Uncheck Single RadioButton
pixelsearch reacted to Melba23 for a topic
1905russell, A thought has just struck me - take a look at this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hRadio = GUICtrlCreateRadio("Single Radio", 10, 10, 100, 20) GUISetState() $fState = False While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hRadio $fState = Not $fState If $fState = False Then GUICtrlSetState($hRadio, $GUI_UNCHECKED) EndSwitch WEndNow you can have the "look" you wanted. M231 point -
how to detect if the mouse DOES NOT MOVE ?
taypatte reacted to jvanegmond for a topic
$lastMousePos = MouseGetPos() $lastMouseMove = TimerInit() While ( True ) $curMousePos = MouseGetPos() If ( $lastMousePos[0] == $curMousePos[0] And $lastMousePos[1] == $curMousePos[1] ) Then If ( TimerDiff($lastMouseMove) > 10000 ) Then ; 10,000 ms = 10 seconds MsgBox(0, "", "Mouse hasn't moved for 10 seconds.") EndIf Else $lastMousePos = $curMousePos $lastMouseMove = TimerInit() EndIf WEnd This.1 point