Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/07/2021 in all areas

  1. The F1 key in SciTE displays the documentation for the word on which the cursor is located. Up to now this was only available for AutoIt. But times change and we change with them With the "Simple Library Docs Generator" created by MrCreatoR and customized by me, any CHM help file (Compressed HTML Help) can be created (more about this later in a separate thread). The only prerequisite: All function names have to start with the same identifier (like _AD_, _OL_ etc.). We have already created CHM help files for the following UDFs: Active Directory AD-CHM.zip Outlook OutlookEX-CHM.zip TaskScheduler TaskScheduler-CHM.zip WebDriver Webdriver-CHM.zip Preliminary release of the WebDriver help file. This release is for you to play with. Please tell us what you like, what is missing or just what you think about it. For download please see the top of this post. Other CHM help files come with existing UDFs: WinHTTP The integration of these help files in SciTE is now done with the tool presented here. Advanced.Help This tool, created by BugFix from the german forum, allows custom CHM help files to be included in SciTE. The existing help key is used to call either the AutoIt help or the corresponding custom help. Depending on which keyword the cursor is currently on. For unknown keywords the AutoIt help is called. For AutoIt a separate window is opened and for the user-defined UDFs another window is opened, so you can work with both helps at the same time. The ZIP file contains an installation guide in German (Install_Deutsch.txt) and English (Install_English.txt) in which the installation and configuration is described in detail. For download please check the download forum.
    2 points
  2. No. It was only as TODO in advanced example: #TODO check how to use 'binary' # _WD_Capabilities_Add('binary', 'c:\Program Files (x86)\Mozilla Firefox\firefox.exe') already added in: https://github.com/Danp2/WebDriver/pull/104 take a look also on Wiki: https://www.autoitscript.com/wiki/WebDriver#Creating_Capabilities_string
    1 point
  3. ad777

    RegExp assistance please

    maybe this help's: #include <File.au3> #include <WinAPISysWin.au3> Global $GText Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Global $g_iCount = 0 Local $iTimerID = _WinAPI_SetTimer(0, 0, 1000, DllCallbackGetPtr($hTimerProc)) $title = "File Rename" $sFileSelect = FileOpenDialog($title, "F:\", "Images (*.jpg)|Videos (*.mp4)", $FD_MULTISELECT, "", 0) $aDirContent_New = StringSplit($GText, "''", 2) _ArrayDisplay($aDirContent_New) For $i = UBound($aDirContent_New) - 1 To 0 Step - 1 ConsoleWrite($i & "'" & $aDirContent_New[$i] & "'" & @CRLF) If StringRegExp($aDirContent_New[$i], "^\d{4}(-\d{2}){2}_\d{6}_[PV]$") Then ConsoleWrite("> " & $i & @CRLF) _ArrayDelete($aDirContent_New, $i) ContinueLoop EndIf ;$aDirContent_New[$i] = $aDirContent_New[0] & "\" & $aDirContent_New[$i] Next _ArrayDisplay($aDirContent_New) Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime) $GText = ControlGetText($title, "", "Edit1") EndFunc ;==>_TimerProc
    1 point
  4. I have added the preliminary release of the WebDriver help file to post #1.
    1 point
  5. Code should read like a book 😉 if it doesn't most likely a few weeks later you will not understand your own code. Some minor observations (but the last script I would consider final and readable) The underscore is not needed and depends on coding style but in general I would use that more in UDF functions Prep most likely means prepare I would write that _prepareMBR (so the first time you read this you do not spend any second on interpreting what it means) _MBRPressed I probably would only put in calls to 2 functions (basically rule of thumb split GUI related functions from the actual algorithm functions) and then your 2nd functionname is only executing the algorithm so you can easily replace your gui with a different one if needed or make your tool a cmdline version of it validateGUI --> There I would validate all things user did in the GUI to be correct Instead of switch I would just use: if $areYouSure=$IDYES then <functionname> read this page https://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm $IDYES (6)
    1 point
  6. @TheDcoderYes, that is definitely needed. I could have sworn that this was working in an earlier revision. I'm going to open an issue on the GH repo.
    1 point
  7. Subz

    Test calculator app in Win10

    For Windows Apps you would need to use IUIAutomation MS Framework
    1 point
  8. So I should review, rewrite, correct, suplement each function headers, which are part of _wd_capabilities.au3 UDF, as there is still many things to do.
    1 point
  9. Next thing to come will be the WebDriver help file
    1 point
  10. Now I understand a little more from your script rename _writeInfoToFile to _createDiskPartScriptFile as thats what you are actually doing Some example of more refactoring with multidimensional array you have to uncomment the runwait command and the percentage calculation you can improve by (%i/ubound($aarray) * 100) The more you split and refactor the easier it becomes for debugging and testing besides the benefit of readability and maintainability _formatGPT() Func _FormatGPT() GUISetState(@SW_HIDE) local $aArray[9][3] = [ _ ["Cleaning Drive" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'clean.dat' & '"'], _ ["Cleaning Drive" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'scrub.dat' & '"'], _ ["Cleaning Drive" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'clean.dat' & '"'], _ ["Resetting Disk Attributes" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'attrib.dat' & '"'], _ ["Converting Disk to GPT" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'convert.dat' & '"'], _ ["Formatting System Partition" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'formatsystem.dat' & '"'], _ ["Formatting Windows Partition" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'createmsr.dat' & '"'], _ ["Formatting WinRE Partition" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'formatmain.dat' & '"'], _ ["Formatting WinRE Partition" , 'cmd /c diskpart /s ' & '"' & $CachePath & 'formatwinre.dat' & '"'] _ ] ProgressOn("Getting UEFI (GPT) Ready...", "Preparing Disk: ", "0%") for $i=0 to ubound($aArray)-1 consolewrite($aArray[$i][1] & @CRLF) ProgressSet($i*10 & "%", $aArray[$i][0]) ; RunWait($aArray[$i][1], @WorkingDir, @SW_HIDE) Sleep(500) Next ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc Example to put your GUI in event mode will clean up even more Opt("GUIOnEventMode", 1) myGui() func myGui() GUICreate('Prep/Format Disk v1.3', 300, 298) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetIcon(@WorkingDir & '\PrepareDiskNT.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('1: Select a disk to prepare for WinNTSetup5', 20, 10, 280) $DiskList = GUICtrlCreateList('', 20, 30, 260, 150) GUICtrlSetData(-1, _DiskList()) $Refresh = GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetOnEvent(-1, "RefreshPressed") GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('2: Select your desired layout...', 20, 214, 280, 30) $MBR = GUICtrlCreateButton('BIOS (MBR) Boot', 20, 232, 120, 40) GUICtrlSetOnEvent(-1, "MBRPressed") $GPT = GUICtrlCreateButton('UEFI (GPT) Boot', 160, 232, 120, 40) GUICtrlSetOnEvent(-1, "GFTPressed") GUICtrlCreateLabel('( * ) Disk is Currently GPT', 160, 278, 130, 30) GUISetState() ; Just idle around While 1 Sleep(10) WEnd EndFunc Func RefreshPressed() MsgBox($MB_SYSTEMMODAL, "RefreshPressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>OKPressed Func MBRPressed() MsgBox($MB_SYSTEMMODAL, "MBRPressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>OKPressed Func GFTPressed() MsgBox($MB_SYSTEMMODAL, "GFTPressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>CancelPressed Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox($MB_SYSTEMMODAL, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE MsgBox($MB_SYSTEMMODAL, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Case @GUI_CtrlId = $GUI_EVENT_RESTORE MsgBox($MB_SYSTEMMODAL, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents
    1 point
  11. digrom

    OpenJson UDF Library

    OpenJson is a library that allows the extraction of data from text encoded in JSON format in a simple way. #include "OpenJson.au3" $json_text = FileRead('json.txt') $dict = _OJParse($json_text) ; #GET COUNT OF ITEMS# =========================================================================================================== ConsoleWrite('GET COUNT OF ITEMS' & @CRLF) $count = $dict.Item('rows').Item(1).Item('elements').Count ConsoleWrite('Items count: ' & $count & @CRLF & @CRLF) ; #SHOW SINGLE VALUES# =========================================================================================================== ConsoleWrite('SHOW SINGLE VALUES' & @CRLF) For $i = 1 To $count ConsoleWrite($dict.Item('rows').Item(1).Item('elements').Item($i).Item('duration').Item('text') & @CRLF) Next ConsoleWrite(@CRLF) ; #SHOW ALL KEYS# =========================================================================================================== ConsoleWrite('SHOW ALL KEYS' & @CRLF) $keys = $dict.Keys For $k In $keys ConsoleWrite($k & @CRLF) Next ConsoleWrite(@CRLF) ; #SHOW ALL VALUES# =========================================================================================================== ConsoleWrite('SHOW ALL VALUES' & @CRLF) $items = $dict.Item('destination_addresses').Items For $i In $items ConsoleWrite($i & @CRLF) Next ConsoleWrite(@CRLF) ; #CHECK IF KEY EXISTS# =========================================================================================================== ConsoleWrite('CHECK IF KEY EXISTS' & @CRLF) $exists = $dict.Item('rows').Item(1).Exists('elements') ConsoleWrite("Exists key 'elements'?: " & $exists & @CRLF) ; #OUTPUT# =========================================================================================================== ;~ GET COUNT OF ITEMS ;~ Items count: 6 ;~ SHOW SINGLE VALUES ;~ 3 hours 54 mins ;~ 1 hour 44 mins ;~ 1 day 18 hours ;~ 18 hours 43 mins ;~ 1 day 2 hours ;~ 1 day 18 hours ;~ SHOW ALL KEYS ;~ destination_addresses ;~ origin_addresses ;~ rows ;~ status ;~ SHOW ALL VALUES ;~ Washington, DC, USA ;~ Philadelphia, PA, USA ;~ Santa Barbara, CA, USA ;~ Miami, FL, USA ;~ Austin, TX, USA ;~ Napa County, CA, USA ;~ CHECK IF KEY EXISTS ;~ Exists key 'elements'?: True ; #OUTPUT# =========================================================================================================== ;================================================================== The object returned by the _OJParse function contains 5 methods for extracting the information: Count: returns the number of items contained within an element Item('key') or Item(index): returns a specific item Keys: gets the list of keys for a specific element Items: gets the list of items of a specific element Exists('key'): or Exists(index): check if an element exists ;================================================================== Elements must be chained to get sub elements: Example: File example.txt { "persons":[ {"name":"Diego","age":27}, {"name":"Juan","age":19}, {"name":"Andres","age":43}, {"name":"Emilio","age":35} ] } Autoit code: #include "OpenJson.au3" $json_text = FileRead('example.txt') $dict = _OJParse($json_text) $name = $dict.Item('persons').Item(3).Item('name') ConsoleWrite($name) OUTPUT: Andres ;================================================================== ;There are three considerations that must be taken when using this library 1.- You should not to use double quotes within the texts. Double quotes within a text should be avoided, otherwise the library will throw an error. For example double quotes should not be in any of the following ways: "Hello" world" "hello "world"" But single quotes are allowed within the text: "Hello 'world' " 2.- Be careful with the structure of the text in JSON format Although it is obvious, it is worth remembering that if the provided JSON text structure has an error, the library will throw an error or return incomplete or empty data. This library uses the recursion process to build a tree of data in memory, so it is very sensitive to the quality of the JSON text that is processed. Please make sure that the JSON text to be processed is correct. None of the following five special characters must be missing or excess: [] {} " Otherwise the library will throw an error, but be sure that if the text in JSON format is syntactically correct, the library will work correctly. 3.- Keys are case sensitive Make sure the keys have the exact same name as supplied in the JSON-formatted text. $dict.Item('name') is not the same as $dict.Item('Name') ;================================================================== Three files are included in the attached archive: OpenJson.au3 - The UDF Library OJTest.au3 - Contains examples of the five functions available for manipulating JSON data json.txt - Contains sample text in JSON format OpenJson_v1.2.zip
    1 point
×
×
  • Create New...