Leaderboard
Popular Content
Showing content with the highest reputation on 10/01/2020 in all areas
-
If ProcessExists - Wildcard question
Starlord30 and one other reacted to TheXman for a topic
Here's a quick & dirty example of using COM to find a process using a partial match. It is written so that if the process name contains the string, it will return true. #include <Constants.au3> If fuzzy_process_match('svchost') Then MsgBox($MB_ICONINFORMATION, "INFO", "Process found!") Else MsgBox($MB_ICONWARNING, "WARNING", "Process not found!") EndIf Func fuzzy_process_match($sFuzzyMatch) ; This function will return true if there are process names ; that contain the specified string Local $oWmi, $oInstances ObjEvent("AutoIt.Error", comm_error_handler) ;Get WMI object $oWmi = ObjGet("winmgmts:\\.\root\CIMV2") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Search for process names that contain the specified string $oInstances = $oWmi.ExecQuery(StringFormat("SELECT name FROM Win32_Process WHERE name like '%%%s%%'", $sFuzzyMatch)) ;Return boolean result Return ($oInstances.Count > 0 ? True : False) EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc2 points -
This UDF was created for give any kind of support for GDPR solutions in AutoIt. #include "GDPR.au3" #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel ; #AutoIt3Wrapper_Run_Debug_Mode=Y _Example() Func _Example() _GDPR_Crypter_Wrapper(_Example_Crypter) Local $sText = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.' MsgBox(0, @ScriptLineNumber, _GDPR_Anonymize_String($sText)) Local $dCrypted = _GDPR_Crypt_String($sText) MsgBox(0, @ScriptLineNumber, $dCrypted & @CRLF & @error & @CRLF & @extended) Local $sDecrypted = _GDPR_DeCrypt_AsString($dCrypted) MsgBox(0, @ScriptLineNumber, $sDecrypted & @CRLF & @error & @CRLF & @extended) _GDPR_Crypt_File(@ScriptFullPath, @ScriptFullPath & '.CRYPTED') If @error Then ConsoleWrite('! ---> @error=' & @error & ' @extended=' & @extended & ' : _GDPR_Crypt_File' & @CRLF) _GDPR_DeCrypt_File(@ScriptFullPath & '.CRYPTED', @ScriptFullPath & '.DECRYPTED.au3') If @error Then ConsoleWrite('! ---> @error=' & @error & ' @extended=' & @extended & ' : _GDPR_DeCrypt_File' & @CRLF) EndFunc ;==>_Example Func _Example_Crypter($dBinaryData, $bDataAlreadyEncrypted) _Crypt_Startup() ; Start the Crypt library. Local $dResult If $bDataAlreadyEncrypted Then $dResult = _Crypt_DecryptData($dBinaryData, 'securepassword', $CALG_3DES) ; Decrypt the data using the generic password string. The return value is a binary string. Else $dResult = _Crypt_EncryptData($dBinaryData, 'securepassword', $CALG_3DES) ; Encrypt the text with the new cryptographic key. EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $dResult EndFunc ;==>_Example_Crypter Download link: WIKI: This UDF was added here: https://www.autoitscript.com/wiki/User_Defined_Functions1 point
-
Custom Grid with Desktop App fitin -Windows 10
Nine reacted to seadoggie01 for a topic
I really need a sarcasm font1 point -
I don't need to. I tried it with Edge, Chrome, and Firefox. They all exhibited this behavior. Chances are that IE would do the same if it wasn't so outdated. 😄1 point
-
This is about using more than 500 #include statements in the master, not about the total nested included files! In the attached example you can move block of include files from Main into one of the included files to make them nested and things will work fine. Jos1 point
-
If ProcessExists - Wildcard question
Starlord30 reacted to Musashi for a topic
A (simple) approach : The name with the highest increment will be determined. Local $sSearchStr = "ProcessToIncrement" Local $aProcessList = ProcessList() Local $sProcessName = '' Local $bProcessFound = False For $i = 1 To $aProcessList[0][0] If StringRegExp($aProcessList[$i][0], "^" & $sSearchStr & "\d+\.exe$") Then $sProcessName = $aProcessList[$i][0] ConsoleWrite("> >>>> Process in List : " & $sProcessName & @CRLF) $bProcessFound = True EndIf Next If $bProcessFound Then ConsoleWrite("+ >>>> Found : " & $sProcessName & @CRLF) Else ConsoleWrite("! >>>> No process found" & @CRLF) EndIf1 point -
The syntax may be different but the logic is the same. I would do one of 2 things: Get a list of processes (ProcessList()) and do a partial/fuzzy search against the array of processes that is returned to see if the target process exists Using COM, you can do a query against the Win32_Process object to see if your process exists. With WQL, you can do partial/fuzzy searches using the "LIKE" clause.1 point
-
Custom Grid with Desktop App fitin -Windows 10
seadoggie01 reacted to Nine for a topic
There is no need to draw a graphical grid on your screen as most Windows apps have a frame. Just divide your screen into identical areas, and use @seadoggie01 solution (or other similar functions, like WinMove for example) to display the application into the proper area. Start scripting some base code, and if you have trouble, come back with what you have done so far. We will then be in a better position to help you out.1 point -
1 point
-
(Just to give you a starter) When you enter AutoIt Hotkey in Google, the first link is : https://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm You don't have to be a rocket scientist for that. A little more self-initiative would be desirable if you really want to learn AutoIt .1 point
-
This is exactly the crucial point (in my opinion). @CYCho : The base definition of keywords in AutoIt will certainly not be sufficient for your project. Without the AutoIt functions it will hardly be possible to write a program. Therefore I would consider functions and possibly relevant constants as keywords. I would create my own list of keywords (as a file - one keyword per line). As a basis I would use the au3.keywords.properties, just as you have already planned yourself. You can then enhance this list with function names of non-standard UDF's if required. @CYCho EDIT : OK, you were faster BTW : If you analyze a script the following would be useful: #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/MO So all includes are contained in one file. Comments should also be ignored, because they may have keywords in them.1 point
-
I'm responsible to implement the GDPR in my company. The GDPR is a legal regulation of the EU to be implemented directly. This means that no implementation in national law is necessary. The GDPR is not a recommendation, but a law that you have to comply with since May 2018. The first question you have to ask yourself is not a technical question (do I use Excel ...), but the question of whether the GDPR is applicable at all. I.e. if you only process technical data, then the GDPR does not apply.1 point
-
CodeScanner will give you detailed lists of all functions, variables, and macros used in a script.1 point
-
How many keywords were used in my script?
CYCho reacted to JockoDundee for a topic
and yet the number of keywords in the entire language is around 50.1 point -
How to insert images in combobox
halbum2040 reacted to funkey for a topic
I thought you wanted to put large images into combobox? You never said something about resizing, but this can be done also. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.12 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 1000, 800) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 994, 500) $g_idMemo = GUICtrlCreateEdit("", 2, 332, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) _GDIPlus_Startup() InetGet("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/World_blank_map_countries.PNG/320px-World_blank_map_countries.PNG", "World.png") $hImage = _GUIImageList_Create(100, 50, 5, 3, 1) SetComboImage($hImage, @ScriptDir & "\World.png") SetComboImage($hImage, @ScriptDir & "\World.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 1 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Picture", $x + 1), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func SetComboImage($hImage, $iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_ImageResize($hPng, 100, 50) ;~ ConsoleWrite($hPng & @CRLF) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject($hPng) ;release GDI bitmap resource because not needed anymore ;~ ConsoleWrite($hBmp & @CRLF) ConsoleWrite(_GUIImageList_Add($hImage, $hBmp) & @CRLF) EndFunc ;==>SetComboImage1 point -
WebDriver UDF - Help & Support
Velislav reacted to PoojaKrishna for a topic
@Danp2, Thank you so much for testing the piece of code and finding that out. We have got a fix for that. Please refer the sixth answer here. ; #FUNCTION# =========================================================================================================== ; Name ..........: _WD_SetDropDownOption ; Description ...: Select a Drop down option by value, index or text ; Syntax ........: _WD_SetDropDownOption($sSession, $sElement, $svalue[, $iMethod = 1,]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sElement - Element ID from _WDFindElement ; $iMethod - [optional] an integer value. Default is 1. ; 1=Select option by value ; 2=Select option by index ; 3=Select option by text ; Return values .: Nil ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_SetDropDownOption($sSession, $sElement, $sValue, $iMethod = 1) Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}' Local $Query = "" Switch $iMethod Case 1 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].value == " & "'" & $sValue & "'" & "){ select.options[i].selected = true; arguments[0].onchange();return } }" Case 2 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].index == " & $sValue & "){ select.options[i].selected = true; arguments[0].onchange();return } }" Case 3 $Query = "var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].text == " & "'" & $sValue & "'" & "){ select.options[i].selected = true; arguments[0].onchange();return } }" EndSwitch If $Query <> "" Then Local $sResponse = _WD_ExecuteScript($sSession, $Query , $sJsonElement ) Return EndFunc ;==>_WD_SetDropDownOption1 point -
WebDriver UDF - Help & Support
duzers reacted to PoojaKrishna for a topic
Hi, I'm trying to get all information about a selected element on a chrome page using the UDF but for some elements the 'rect' command is not working with _WD_ElementAction when we call Get Element Rect. For working elements the response we receive looks like: {"value":{"height":96,"width":276,"x":545,"y":89}} And when it is an error it is like: {"value":{"error":"unknown error","message":"getting size failed to return y(Session infochrome=67.0.3396.99)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0135DF70+778096]\n\tOrdinal0 [0x0130B42D+439341]\n\tOrdinal0 [0x012E807F+295039]\n\tOrdinal0 [0x012B5D2D+89389]\n\tOrdinal0 [0x012C8349+164681]\n\tOrdinal0 [0x012B39C0+80320]\n\tOrdinal0 [0x012C8521+165153]\n\tOrdinal0 [0x012CF96B+194923]\n\tOrdinal0 [0x012C824F+164431]\n\tOrdinal0 [0x012B1B45+72517]\n\tOrdinal0 [0x012B2F2A+77610]\n\tOrdinal0 [0x012B2ECC+77516]\n\tGetHandleVerifier [0x013F9936+3478]\n\tOrdinal0 [0x013688C3+821443]\n\tOrdinal0 [0x01317066+487526]\n\tOrdinal0 [0x01317393+488339]\n\tOrdinal0 [0x013174A3+488611]\n\tOrdinal0 [0x0136AA67+830055]\n\tOrdinal0 [0x01316DAF+486831]\n\tOrdinal0 [0x013213FE+529406]\n\tOrdinal0 [0x0132C57B+574843]\n\tOrdinal0 [0x0132C6CD+575181]\n\tOrdinal0 [0x0132B92B+571691]\n\tBaseThreadInitThunk [0x76FC8484+36]\n\tRtlValidSecurityDescriptor [0x77E32FEA+282]\n\tRtlValidSecurityDescriptor [0x77E32FBA+234]\n"}} Any suggestion to solve this problem. My test code is attached below: #include "wd_core.au3" #include "wd_helper.au3" #include "misc.au3" #RequireAdmin $_WD_DEBUG = False _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Startup() $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}' Global $sSession = _WD_CreateSession($sDesiredCapabilities) If @Error Then msgbox(0,"Error", "Failed to create session." & @CRLF & "Select [Ok] to Exit") exit EndIf while (1) $sURL = InputBox("URL","Please enter the URL to navigate: ","https://w3c.github.io/webdriver/#dfn-getattribute") _WD_Navigate($sSession, $sURL) ;Navigate to URL ToolTip("Move mouse to the element and press Enter key") Local $hDLL = DllOpen("user32.dll") Do Sleep(100) Until _IsPressed("0D", $hDLL) ;Wait until user presses Enter key ToolTip("") $sElementId = _WD_GetMouseElement($sSession) ;Element id $sElementDetails = "ElementId: " & $sElementId & @CRLF If $sElementId Then __WD_HighlightElement($sSession, $sElementId, 1) $sCommand = 'name' $sRes = _WD_ElementAction($sSession, $sElementId, $sCommand, '') ;name If $sRes Then $sElementDetails = $sElementDetails & $sCommand & ": " & $sRes & @CRLF ;add to result $sCommand = 'text' $sRes = _WD_ElementAction($sSession, $sElementId, $sCommand, '');text If $sRes Then $sElementDetails = $sElementDetails & $sCommand & ": " & $sRes & @CRLF ;add to result $sCommand = 'rect' $sRes = _WD_ElementAction($sSession, $sElementId, $sCommand, '') ;rect If $sRes Then $sElementDetails = $sElementDetails & $sCommand & ": " & $sRes & @CRLF;add to result $Ret = Msgbox(1,"Result", $sElementDetails & @CRLF & "Select [Ok] to continue or [Cancel] to exit.") ;Display result If $Ret = 2 then ExitLoop Else Msgbox(0,"Not found", "Element id Not found") EndIf WEnd _WD_DeleteSession($sSession) _WD_Shutdown()1 point -
Here is just some usefull script analyzer: #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> ; just put a FileFullPath to one of your project _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3") _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3") _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\SciteConfig.au3" ) _UsedInclude_API() _GetAllDependencies(@ScriptFullPath) Func _GetAllDependencies($sFileToCheck) GUICreate("My GUI with treeview", 500, @DesktopHeight - 40) Local $idTreeview = GUICtrlCreateTreeView(6, 6, 488, @DesktopHeight - 40 - 12, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) Local $idDisplayitem = GUICtrlCreateTreeViewItem($sFileToCheck, $idTreeview) GUICtrlSetColor(-1, $COLOR_GREEN) __UsedIncludeToTreeView($sFileToCheck, $idDisplayitem) Local $hItem = GUICtrlGetHandle($idDisplayitem) GUICtrlSendMsg($idTreeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc ;==>_GetAllDependencies Func _GetUsedIncludeToArray($sAU3Content) Local $aIncludes = StringRegExp($sAU3Content, '(?im)^\s*#include\s?[''""<](.*)\.au3[''"">]', 3) If @error Then Return SetError(@error, @extended, '') Else Return SetError(0, 0, $aIncludes) EndIf EndFunc ;==>_GetUsedIncludeToArray Func __UsedIncludeToTreeView($sFileToCheck, $idTreeview_ref) $hFile = FileOpen($sFileToCheck, $FO_READ) $sAU3Content = FileRead($hFile) FileClose($hFile) Local $aIncludes = _GetUsedIncludeToArray($sAU3Content) If @error Then Return SetError(@error, @extended, '') Else Local $idDisplayitem, $iNumberOfOccurrences = 0 For $iInclude_Idx = 0 To UBound($aIncludes) - 1 $iNumberOfOccurrences = _UsedInclude_API($aIncludes[$iInclude_Idx]) If $iNumberOfOccurrences = 0 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx], $idTreeview_ref) __UsedIncludeToTreeView(_GetDir($sFileToCheck) & $aIncludes[$iInclude_Idx] & '.au3', $idDisplayitem) ElseIf $iNumberOfOccurrences = 1 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before: once)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_RED) ElseIf $iNumberOfOccurrences = 2 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before: twice)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_PURPLE) ElseIf $iNumberOfOccurrences > 2 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before more then twice)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_BLUE) EndIf Next EndIf EndFunc ;==>__UsedIncludeToTreeView Func _UsedInclude_API($sIncludeFileName = Default) Local Static $sIncludeAPI_Static = '|' ; reset If $sIncludeFileName = Default Then $sIncludeAPI_Static = '|' Return EndIf StringReplace($sIncludeAPI_Static, '|' & $sIncludeFileName & '|', '|' & $sIncludeFileName & '|') Local $iNumberOfReplacements = @extended $sIncludeAPI_Static &= $sIncludeFileName & '|' Return SetError(0, 0, $iNumberOfReplacements) EndFunc ;==>_UsedInclude_API Func _GetDir($sFileFullPath) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sFileFullPath, $sDrive, $sDir, $sFileName, $sExtension) Return $sDrive & $sDir EndFunc ;==>_GetDir Have fun. mLipok1 point
-
Thank you for the reply. When I pressed F6, typed the following path, and pressed OK, I got an error. $(sys.PROGRAMFILES)\AutoIt3\AutoIt3.exe $(FULL_CURRENT_PATH) AutoIt Error Line 0 (File "C:\Documents"): Error: Error opening the file. So, I tried the path to have quotation marks and it worked. Thank you so much. $(sys.PROGRAMFILES)\AutoIt3\AutoIt3.exe "$(FULL_CURRENT_PATH)" However, when I do it from F5, nothing happens. I tried the following four lines for F5, $(sys.PROGRAMFILES)\AutoIt3\AutoIt3.exe $(FULL_CURRENT_PATH) $(sys.PROGRAMFILES)\AutoIt3\AutoIt3.exe "$(FULL_CURRENT_PATH)" C:\Program Files\AutoIt3\AutoIt3.exe $(FULL_CURRENT_PATH) C:\Program Files\AutoIt3\AutoIt3.exe "$(FULL_CURRENT_PATH)" Just for now, I'll go with the F6 solution, but if anybody knows what I should do with F5 please let me know. Edit: the following line worked for F5. Thanks. "C:\Program Files\AutoIt3\AutoIt3.exe" "$(FULL_CURRENT_PATH)"1 point