Leaderboard
Popular Content
Showing content with the highest reputation on 07/27/2022 in all areas
-
It has been a while since I posted in here, but I have been revamping the internals and adding functionality onto the previously shown base logic. It is all working faster and the AutoComplete has become "smarter". This Video-gif shows how it works currently in my test environment. It now includes partial Variable names/UDFnames sorted on position typed word found, and also includes matching defined abbreviations, which will expand upon selection: .. will be continued...2 points
-
I've been doing a lot of sql queries to pull data for some automation and I got tired of manually converting my queries into strings that I can use in my scripts. "last one was 288 lines" This will convert either your current clipboard or a selected .sql file into an AutoIt $sSQL = "" string. It will automatically remove any comments "not block comments though" and it should keep the formatting that you had. I like to have my queries in a nice spacing so it's easy to tell where a sub-query starts and ends so I wanted to keep that look in the AutoIt string. I'm sure this could be done more efficient so if you have suggestions please let me know. #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $iGuiW = 350 $iGuiH = 80 $hGUI = GUICreate("Convert SQL Query to Au3 String", $iGuiW, $iGuiH) GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitApp") GUICtrlCreateButton("Convert .sql file", 15, 20, 150, 40) GUICtrlSetOnEvent(-1, "_ConvertFile") GUICtrlCreateButton("Convert Clipboard", $iGuiW - 165, 20, 150, 40) GUICtrlSetOnEvent(-1, "_ConvertClipboard") GUISetState(@SW_SHOW, $hGUI) ;Display the GUI for the User While 1 ;Loop waiting for the user to click something. sleep(100) WEnd ;Function if a user selects the "Convert .sql file" button Func _ConvertFile() $sFile = FileOpenDialog("SQL File", @ScriptDir, "SQL (*.sql)") ;Select the .sql file to convert If @error Then Return $sQuery = FileRead($sFile) ;Read the file into a string $sOutput = _GenerateString($sQuery) ;Use the convert function to return the updated string $sSaveAs = FileSaveDialog("SaveAs", @ScriptDir, "Text (*.txt)") ;Prompt for where to save the new file If @error Then Return FileWrite($sSaveAs, $sOutput) ;Write the file If MsgBox(4, "Finished", "Your string has been saved as " & $sSaveAs & @CRLF & "Would you like to open the file now?") = 6 Then ShellExecute($sSaveAs) ;Launch the new file if they pick [Yes] EndIf Exit EndFunc ;Function if a user selects "Convert Clipboard" button Func _ConvertClipboard() $sQuery = ClipGet() ;Read the clipboard into a string ClipPut(_GenerateString($sQuery)) ;Use the convert function and write results directly to clipboard MsgBox(0, "Finished", "Your Clipboard has been Updated with the AutoIt String") Exit EndFunc ;Function that converts the sql query into an actual String that can be pasted into an AutoIt script Func _GenerateString($sQuery) $aRawData = StringSplit($sQuery, @CRLF, 3) $iLines = UBound($aRawData) Local $sStringValue = "" Local $sSpace = " " For $i = 0 to $iLines - 1 $sLine = StringStripWS(StringReplace($aRawData[$i], '"', '""'), 2) ;change any " in the query with double "" and remove all spaces from the end of the line If StringLeft(StringStripWS($sLine, 1), 1) = "--" Then ContinueLoop ;skip any comment lines $iComment = StringInStr($sLine, "--") ;Remove any comments at the end of the line If $iComment > 0 Then $sLine = StringStripWS(StringLeft($sLine, $iComment - 1), 2) If StringStripWS($sLine, 3) = "" Then ContinueLoop ;Remove any empty lines If $sStringValue = "" Then $sStringValue = @TAB & '$sSQL = "' & StringStripWS($sLine, 3) & ' " & _' & @CRLF ;Don't include leading spaces in the first line Else If $i = $iLines - 1 Then $sStringValue &= @TAB & @TAB & @TAB & '"' & StringStripWS($sLine, 3) & '"' ;Don't include leading spaces in the last line Else $iLeadingSpaces = StringLen($sLine) - StringLen(StringStripWS($sLine, 1)) ;Find how many leading spaces are there $sLine = StringLeft($sSpace, $iLeadingSpaces) & '"' & StringStripWS($sLine, 1) ;insert a " between leading spaces and sql line $sStringValue &= @TAB & @TAB & @TAB & $sLine & ' " & _' & @CRLF EndIf EndIf Next Return $sStringValue EndFunc Func _ExitApp() Exit EndFunc1 point
-
Search the help file for the term #forceref.1 point
-
You can also use: _WD_CapabilitiesAdd("mobileEmulation", "deviceName", 'Nexus 5') WIP on deviceMetrics1 point
-
For an hour I searched first for the cause of the problem in my IE to WD migration project. Then I wrote a question (post above). And a while ago, I found a solution. https://stackoverflow.com/questions/22095346/loading-a-url-in-a-frame-using-selenium-c-sharp _WD_FrameEnter($sSession, Null) _WD_FrameEnter($sSession, 2) Local $s_JavaScript = "window.location.href='" & $s_Warehouse_url & "'" _WD_ExecuteScript($sSession,$s_JavaScript)1 point
-
Taking the idea from @Melba23's (btw, thanks ) ExtMsgBox and also making use of his StringSize UDF, I made a extended version of the InputBox function. From the README file: This UDF creates input boxes (just like native InputBox), but with multiple inputs. You can also set some inputs to be password-style, set the default texts for some of the edits and even set the label of the OK/cancel buttons. How to use _ExtInputBox($sTitle, $sTexts [ , $sDefaults = Null [ , $sPasswords = Null [ , $sBtnLabels = "OK|Cancel" [ , $iWidth = -1 [ , $iLeft = -1 [ , $iTop = -1 [ , $iTimeout = 0 [ , $hParent = 0 ] ] ] ] ] ] ] ] ) Arguments are: $sTitle (mandatory): The window title (e.g.: "Hello World") $sTexts (mandatory): The edit labels, separated by | (e.g.: "Your email|Your password") $sDefaults: The default input texts, separated by | (e.g.: "|you@us.com||" will tell that the first input will have nothing as default text, the second will have you@us.com as default text and the third and forth will also have nothing). Note that if you set the default value of 1 input, you must set the value of them all (even if it's nothing), otherwise all inputs will have no default value. Default is none. $sPasswords: One or more 1-based index of inputs, separated by anything that is not a number (pipeline - | - recommended), of the inputs that will receive password style (e.g.: "2|3" wíll tell that the second and third inputs are password-style, default is none) $sBtnLabels: The TWO label of the default OK/Cancel buttons (e.g.: "Submit|Close") $iWidth: Window width (default is the size of the longest string with the limit of 25% of the screen width). Obviously it's not possible to set the height as it's calculated automatically. $iLeft: Distance of the window from the left side of the screen (default is centered) $iTop: Distance of the window to the top of the screen (default is centered) $iTimeout: Time limit for filling the form data (default is none) $hParent: Parent form (default is none) Return value Sucess: an 1-based array with the input values entered ($aArray[1] = 1st input value, $aArray[2] = 2nd input value, $aArray[n] = nth input value, whereas $aArray[0] = input count) Failure: False, and set @extended to 1 if the user clicked cancel, 2 if the user closed the window, or 3 if timeout ended. Examples (two of them) #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Username|Password", Null, "2") If $sData = False Then MsgBox(0, "", "You pressed cancel, exit or timeout ended.") Else MsgBox(0, "You entered:", "Username: " & $sData[1] & @CRLF & "Password: " & $sData[2]) EndIf #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Your full name|Your email|Your telephone|Choose an username|Choose a password|Repeat password", "Mr./Ms. ||+1 |admin||", "5,6", "Register|Cancel") If $sData = False Then Switch @extended Case 1 MsgBox(0, "", "You clicked Cancel") Case 2 MsgBox(0, "", "You closed the window.") Case 3 MsgBox(0, "", "Timeout ended (but we have no timeout on this example, so this will never happen)") EndSwitch Else MsgBox(0, "You entered:", "Full name: " & $sData[1] & @CRLF & _ "Email: " & $sData[2] & @CRLF & _ "Telephone:" & $sData[3] & @CRLF & _ "Username: " & $sData[4] & @CRLF & _ "Password: " & $sData[5] & @CRLF & _ "Password repeat: " & $sData[6]) EndIf Download Download ZIP from GitHub Btw, fork me on Github1 point
-
you can use: document.querySelector("label[for='input34']").click() or: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "label[for='input34']" _WD_ElementAction($sSession, $sElement, 'CLICK')1 point
-
Count number of files in folder..?
pixelsearch reacted to Belini for a topic
If you want only the number of files using DirGetSize $patch = "C:\Windows\System32\" $test = DirGetSize($patch, 1) MsgBox(4096,'Test', "Number of files found: " & $test[1])1 point