Leaderboard
Popular Content
Showing content with the highest reputation on 07/19/2023 in all areas
-
What is stopping you from testing this yourself?2 points
-
Condition question
argumentum reacted to mistersquirrle for a topic
Just because I've had the same question and tested this a bit myself, here's results from a test that I ran in 2018: From this, Switch was always the fastest, and if you can, you should set/keep OnEventMode off. Things depend though, and you may not be able to always use Switch, or the different logic needed to get a specific way working may introduce additional slowdowns Edit: Just to be clear, the OnEventMode stuff doesn't have any direct connection/impact with Select/Switch/If, it's just something else that I was testing at the same time. In general things are a bit slower with OnEventMode, not just Select/Switch/If1 point -
If you are afraid of Mod() you can use a simple counter: $Counter = 0 While True If $Counter = 10000 Then $Counter = 0 MyFunc() EndIf $Counter += 1 ; rest of the code WEnd1 point
-
1 point
-
Not sure why you are at ll worried about cpu cycles when using an interpreter scripting language! As to the Mod() function, it is simple so I am sure you will be able how to code an if that will be true each 1000 cycles. Just kick your brain in gear at try it as that takes less time than tying your question here.1 point
-
@UEZ hopefully this will work #include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ ; Search taskbars $ahWnd = WinList("[REGEXPCLASS:Shell_(Secondary)?TrayWnd]") ConsoleWrite("Found taskbars " & $ahWnd[0][0] & @CRLF) ; Search controls Global $ahCtrl[$ahWnd[0][0]] For $i = 1 To $ahWnd[0][0] $ahCtrl[$i - 1] = ControlGetHandle($ahWnd[$i][1], "", "MSTaskListWClass1") Next ; Get UIAutomation object $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Exit ConsoleWrite("Error create UIA object" & @CRLF) ; Create 2D array of buttons [name,left,top,right,bottom] Global $aBtnInfo[0][5], $Count, $pElement, $pCondition, $pElementArray, $iButtons, $vValue $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") For $n = 0 To UBound($ahCtrl) - 1 ; Get taskbar element $oUIAutomation.ElementFromHandle($ahCtrl[$n], $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($iButtons) ReDim $aBtnInfo[UBound($aBtnInfo) + $iButtons][5] ; Get name and position for each button For $i = 0 To $iButtons - 1 $oElementArray.GetElement($i, $pElement) $oButton = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oButton.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) $oButton.CurrentBoundingRectangle($tRect) $aBtnInfo[$i + $Count][0] = $vValue $aBtnInfo[$i + $Count][1] = $tRect.Left $aBtnInfo[$i + $Count][2] = $tRect.Top $aBtnInfo[$i + $Count][3] = $tRect.Right $aBtnInfo[$i + $Count][4] = $tRect.Bottom Next $Count += $iButtons Next #include <Array.au3> _ArrayDisplay($aBtnInfo)1 point
-
FormCompletion GUI assistant for Form Completion a tool - aid for filling in details in online shopping we can easily add new elements, (by adding new keys to the ini file) e.g. VATnumber=1234567890 ; https://www.autoitscript.com/forum/topic/210568-formcompletion/ ;---------------------------------------------------------------------------------------- ; Title...........: FormCompletion.au3 ; Description.....: GUI assistant for Form Completion ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=CodeWiz.ico #AutoIt3Wrapper_Res_ProductName=FormCompletion.au3 #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Res_Description=GUI assistant for Form Completion #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <Misc.au3> If _Singleton(@ScriptName, 1) = 0 Then Exit ; to avoid running it multiple times! ; Read the INI file for the value of 'Elements' Global $MyIni = @ScriptDir & "\FormCompletion.ini" Global $aElements = Elements_ReadIni() Global $iStep = 25 ConsoleWrite("$aElements[0][0]=" & $aElements[0][0] & @CRLF) #Region === GUI section === Global $MyGui = GUICreate("FormCompletion", $iStep * 8, ($aElements[0][0] * $iStep) + $iStep + 1, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Global $id_EditIni = GUICtrlCreateButton(" 📂 ", 1, 1, $iStep + $iStep, 22, $BS_VCENTER) GUICtrlSetTip(-1, "📂 Edit ini") GUICtrlSetFont(-1, 12) Global $id_Reload = GUICtrlCreateButton(" ♻ ", 2 * $iStep, 1, $iStep + $iStep, 22, $BS_VCENTER) GUICtrlSetTip(-1, "♻ Reload GUI") GUICtrlSetFont(-1, 12) Global $id_Previous = GUICtrlCreateButton(" ◀ ", 4 * $iStep, 1, $iStep + $iStep, 22, $BS_VCENTER) GUICtrlSetTip(-1, "◀ Previous") GUICtrlSetFont(-1, 12) Global $id_Next = GUICtrlCreateButton(" ▶ ", 6 * $iStep, 1, $iStep + $iStep, 22, $BS_VCENTER) GUICtrlSetTip(-1, "▶ Next") GUICtrlSetFont(-1, 12) For $i = 1 To $aElements[0][0] $aElements[$i][3] = GUICtrlCreateButton($aElements[$i][1], 1, $i * $iStep, 198, 22, $BS_VCENTER) GUICtrlSetTip(-1, $aElements[$i][1], $aElements[$i][2] & ": ") Next #EndRegion === GUI section === GUISetState(@SW_SHOW) Global $nMsg, $hActiveWin, $sActiveTitle, $ClipBack $ClipBack = ClipGet() ; backup clip data ; Loop until the user exits. ;*********************************************************************** While 1 If WinGetHandle("[ACTIVE]") <> $hActiveWin And WinGetHandle("[ACTIVE]") <> $MyGui Then $hActiveWin = WinGetHandle("[ACTIVE]") ;ConsoleWrite("$hActiveWin=" & $hActiveWin & @CRLF) $sActiveTitle = WinGetTitle($hActiveWin) ConsoleWrite("$sActiveTitle=" & $sActiveTitle & @CRLF) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $id_EditIni ShellExecute($MyIni) Case $id_Reload _Restart() Case $id_Previous WinActivate($hActiveWin) Send("+{TAB}") Case $id_Next WinActivate($hActiveWin) Send("{TAB}") Case $aElements[1][3] To $aElements[1][3] + $aElements[0][0] - 1 $ClipBack = ClipGet() ; backup clip data ; Add new data to the clipboard. ClipPut($aElements[$nMsg - 6][1]) Sleep(100) WinActivate($hActiveWin) Send("^v") ; paste ClipPut($ClipBack) ; restore clip data ;ConsoleWrite("$nMsg=" & $nMsg & @CRLF) EndSwitch Sleep(10) WEnd ;*********************************************************************** Exit ;---------------------------------------------------------------------------------------- Func Elements_ReadIni() Local $iniFileExists = FileExists($MyIni) Local $index = 0 Local $aArray[1][4] $aArray[0][0] = $index $aArray[0][1] = "Element" $aArray[0][2] = "label" $aArray[0][3] = "ID" ;Checks if .ini not exists then make one. If Not $iniFileExists Then ;Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($MyIni, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred while writing the " & $MyIni & ".ini") Exit EndIf ;Write Example data to the ini file FileWrite($hFileOpen, "[Elements]" & @CRLF) FileWrite($hFileOpen, "Email=StephenKing@gmail.com" & @CRLF) FileWrite($hFileOpen, "FirstName=Stephen" & @CRLF) FileWrite($hFileOpen, "LastName=King" & @CRLF) FileWrite($hFileOpen, "Phone=0123456789" & @CRLF) FileWrite($hFileOpen, "Born=21-09-1947" & @CRLF) FileWrite($hFileOpen, "Adress=452 SE 10th Ave, Hillsboro" & @CRLF) FileWrite($hFileOpen, "City=Hillsboro" & @CRLF) FileWrite($hFileOpen, "PostCode=97003" & @CRLF) FileWrite($hFileOpen, "Area=Oregon market" & @CRLF) ;Close the handle returned by FileOpen. FileClose($hFileOpen) Sleep(100) EndIf ; Read the INI section labelled 'Elements'. This will return a 2 dimensional array. Local $aIniArray = IniReadSection($MyIni, "Elements") ; Check if an error occurred. If Not @error Then ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To $aIniArray[0][0] ReDim $aArray[UBound($aArray) + 1][4] $aArray[0][0] = $i $aArray[$i][0] = $i $aArray[$i][1] = $aIniArray[$i][1] $aArray[$i][2] = $aIniArray[$i][0] Next EndIf Return $aArray EndFunc ;==>Elements_ReadIni ;----------------------------------------------------------------------------------- Func _Restart() ; Restart If @Compiled Then Run('"' & FileGetShortName(@ScriptFullPath) & '"') Else Run('"' & FileGetShortName(@AutoItExe) & '" /AutoIt3ExecuteScript "' & FileGetShortName(@ScriptFullPath) & '"') EndIf Exit EndFunc ;==>_Restart ;-------------------------------------------------------------------------------------------- Please, leave your comments and experiences here. thank you very much !1 point
-
@CYCho I'm confused. Did you mean Chromedriver?1 point