Leaderboard
Popular Content
Showing content with the highest reputation on 02/03/2021 in all areas
-
7/02/2021: Uploaded a new release candidate of the new SciTE4AutoIt3.exe v21.203.1500.3
pixelsearch and one other reacted to Jos for a topic
15-03-2021 Installer, SciTE, Tidy & au3stripper are all recompiled with the latest updates for PellesC/Visual Studio & NSIS to get rid of the false positives, and are now uploaded. 16-03-2021 uploaded the "Final" release candidate v21.316.1639.0 which will be move to production when there aren't any real issues in it.For those that downloaded the AV fixed installer uploaded yesterday evening: Make sure you reinstall with this one as that version created a wrong "SCITE_USERHOME" environment settings as the new NSIS used the "%ProgramData%" variable in stead of the "%LocalAppData%" variable! 4/02/2021: Uploaded a release candidate of the new SciTe4AutoIt3.exe installer. It has been over a year since the last update of the full SciTE4AutoIt3 installer which mainly had to do with the fact that Neil was moving toward v5 of SciTE and there weren't many functional changes in SciTE v4 other than to support the different setup of the Lexers to be used in V5. The included SciTE version is now v4.4.6 and the VC15 build was changed from "Win sdk 7 & Toolset v141_xp" to "Win sdk 8.1 & Toolset v141", So I am not sure if it will still run on the older WinXP version. The upcoming V5 version of SciTE will likely drop WinXP altogether. This v4.4.6 version wasn't available before so still needs proper testing for a couple of days to ensure everything works before I release it. Any help with testing this version before general release is appreciated. Also any feedback is welcome in case I missed something or suggestions for improvement before releasing. ==> SciTE4AutoIt3 v21.203.1500.1 UPDATE 4/02/2021: Changed back to "Win sdk 7 & Toolset v141_xp" to maintain WinXP compatibility for SciTE& Scilexer.dll Updates SciTE source to support v141_xp toolset. added check in NSIS installer to check for msvcp140.dll and point to Microsoft Downloads to install vc_redist.x86.exe or else SciTE won't run. UPDATE 6/02/2021: Restored fix for avoiding locking directory. Few other minor fixes in properties files. UPDATE 7/02/2021: AutoIt3Wrapper v19.1127.1402.28 Fixed regression creating duplicate resource entries. Enjoy, Jos -------------------------------------------------------------------------------------------------- 02-??-2021 *** Merged the SciTE v 4.4.6 by Neil Hodgson with our own version of SciTE. (Jos) - Change the workdir to the programdir to avoid locking up the last opened scriptfile directory. - Fixed Bom checking bug resulting to garbage characters in the editor for UTF encoded file other than UTF8 - Dropped support for WinXP (Compiled with vc15, Win sdk 8.1, Toolset v141) - Compiled with vc15 and changed SSE instruction set to ia86 compatible. *** Updated AutoIt3Wrapper v19.1127.1402.0 (Jos) - 19.1127.1402.1 added clear errors when Tidy is ran with Ctrl+T. - 19.1127.1402.2 Avoid running Tidy for a second time when script needs to be run with #RequireAdmin in elevated mode. - 19.1127.1402.5 Added work-around to support Unicode characters in filenames for: - au3check - Tidy - au3stripper - 19.1127.1402.6 Added Win10 build to info lines. (tnx argumentum) - 19.1127.1402.7 Fix for support of filenames containing special ascii characters too. - 19.1127.1402.8 Restored some Directives still used for versioning and fileversion. - 19.1127.1402.8 Fix for support of filenames containing special ascii characters too. - 19.1127.1402.9 Fix checking for "#AutoIt3Wrapper_Version"check till after the GUI is done. - 19.1127.1402.10 Fixed Versionupdate with /RunAfter option I use for AutoIt3Wrapper updates. - 19.1127.1402.11 Fixed issue with #include statements where the filename is enclosed in single quotes. - 19.1127.1402.13 Updated File prompt. - 19.1127.1402.18 added include filelist and their encoding when /debug is supplied - 19.1127.1402.19 Cosmetic update showing the ">Setting Program ExecutionLevel Manifest information to...." only when the directive is provided - 19.1127.1402.20 Fix for elevated scripts running from mapped drive - 19.1127.1402.21 again Fix for support of filenames containing special ascii characters. - 19.1127.1402.22 Fix invalid FileExist statement on line 550. - 19.1127.1402.26 Added #AutoIt3Wrapper_Res_Fileversion_Use_Template *** Updated Au3Stripper v19.1127.1402.0 (Jos) - 19.1127.1402.1 Option /rsln: Added replace for @ScriptLinenumber for #includes to contain source files and original linenumber. - Changed replace for @ScriptLinenumber to only replace none literal string occurrences. - 19.1127.1402.3 Changed replace for @ScriptLinenumber to only replace when not on FUNC line. - 19.1127.1402.5 Added directive "#Au3Stripper_Ignore_Errors_in_Func=", which will suppress any errors triggered within the defined Functions. - 19.1127.1402.7 Fix for Func names in FUNC parameters to avoid stripping the target function. *** Updated SciTEConfig v19.1127.1402.0 (Jos) - 19.1127.1402.1 - Fix bug in AbbrevMan.au3 when pipe symbol is used to set cursor position. (Melba23 *** Updated Tidy v19.1127.1402.0 (Jos) - v19.1127.1402.2 fixed some issues in the /gendoc option: - func reference lines weren't listed - only show variables starting with $ or @ - v19.1127.1402.5 Default Tabsize to SciTE-TabSize when not provided. - v19.1127.1402.6 Made the backp sequence number 2 digits. old filenames will be converted. - v19.1127.1402.10 Reversed the 2 digit sequence number as this will fail when there are more than 99 backup versions. --------------------------------------------------------------------------------------------------2 points -
Getting started example step 3: WebView window First AutoIt implementation. Tested on Windows 10/7, 32/64 bit. Execute WebView2.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> Global $hGui, $oCoreWebView2Environment, $oCoreWebView2Controller #include "..\Includes\WV2Interfaces.au3" WebView2() Func WebView2() $hGui = GUICreate( "WebView2 Sample", 1200, 900, -1, -1, $WS_OVERLAPPEDWINDOW ) _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate() ConsoleWrite( "$pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = " & $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler & @CRLF & @CRLF ) CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate() ConsoleWrite( "$pCoreWebView2CreateCoreWebView2ControllerCompletedHandler = " & $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler & @CRLF & @CRLF ) Local $hWebView2Loader = DllOpen( @AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll" ) Local $aRet = DllCall( $hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", "", _ "ptr", NULL, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ) If @error Or $aRet[0] Then Return ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF ) ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF ) GUISetState( @SW_SHOW ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() DllClose( $hWebView2Loader ) EndFunc Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke" & @CRLF ) $oCoreWebView2Environment = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Environment, $dtag_ICoreWebView2Environment ) ConsoleWrite( "IsObj( $oCoreWebView2Environment ) = " & IsObj( $oCoreWebView2Environment ) & @CRLF & @CRLF ) $oCoreWebView2Environment.CreateCoreWebView2Controller( $hGui, $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler ) Return 0 #forceref $pSelf, $long EndFunc Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke" & @CRLF ) $oCoreWebView2Controller = ObjCreateInterface( $ptr, $sIID_ICoreWebView2Controller, $dtag_ICoreWebView2Controller ) ConsoleWrite( "IsObj( $oCoreWebView2Controller ) = " & IsObj( $oCoreWebView2Controller ) & @CRLF ) $oCoreWebView2Controller.AddRef() $oCoreWebView2Controller.get_CoreWebView2( $pCoreWebView2 ) $oCoreWebView2 = ObjCreateInterface( $pCoreWebView2, $sIID_ICoreWebView2, $dtag_ICoreWebView2 ) ConsoleWrite( "IsObj( $oCoreWebView2 ) = " & IsObj( $oCoreWebView2 ) & @CRLF & @CRLF ) Local $tRect = _WinAPI_GetClientRect( $hGui ) $oCoreWebView2Controller.put_Bounds( $tRect ) $oCoreWebView2.Navigate( "https://www.bing.com/" ) Return 0 #forceref $pSelf, $long EndFunc The code is translated to AutoIt from the C++ code in the Getting started example step 3 and from the AutoHotkey code in WebView2.ahk. A slightly updated example is included in WebView2-1.au3 in the 7z-file at bottom of this post.2 points
-
Multiple user created hotkeys
seadoggie01 and one other reacted to JockoDundee for a topic
Unless you’re deflecting bullets in real-time, you might want to put a sleep(10) (or longer) in your loop While 1 Sleep(10) WEnd Your CPU will thank you...2 points -
This is a simple and practical way to start and manage many processes. I use it to quickly query many remote clients for varyous informations. For processes I mean external programs that can run autonomously and that allows I/O redirection. Here the advantage is that when you start a process, you can also determine which function in your main program should receive results when the external process finishes executing. So you can have different processes and different "callback" functions. The whole works nearly autonomously and asynchronously. While spawned processes works, you can perform other tasks in the main script and leave the worry of receiving and managing the results, to the pre-established functions. As I sayd, everything is almost completely automatic and the processes do their work asynchronously and independently of the flow of the main script. To check and manage processes status, you have only to call as often as possible the _TasksCheckStatus() function that will quickly handle the running processes. AdlibRegister() could be used for this ripetitive "polling". In short: 1) setup single commandlines that will "generate" your wanted result 2) establish wich function of your main script should receive the above result 3) an optional Timeout in seconds is allowed (task from point 1 will be killed at timeout) see function header for details. The provided example of use, needs to be executed in a network environment with preferably many clients, and you have to be administrator. Populate the $aIPList[] array with ClientNames (or ip addresses), and this example script will query all the clients about some informations by running many processes asincronously. Then it will collect results from the processes as soon as "answers" are available and will populate the ListView with that data. I used a ListView so that you can see that all the cells will fill (quite quickly) in an asynchronous way. If you are not in a network with many clients, then this example is nearly useless... (sorry) Hope it can be of use... (suggestions, bug reports and emrovements are welcome) MultiTask.udf #include-once ; #include "Array.au3" ; #INDEX# ======================================================================================================================= ; Title .........: Multi Task Management (tasks spawned by the user via the _TaskRun function of this udf) ; AutoIt Version : ; Language ......: ; Description ...: Functions that assists to execute and manage user's spawned tasks. ; Author(s) .....: Chimp ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _TaskRun Run a new task and stacks its references for later use ; _TasksCheckStatus Check the status of all running tasks and call the CallBack function when a task completed ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __TaskRemove frees task's stacked references ; __NOP No OPeration function ; =============================================================================================================================== Global $aTasks[1][7] = [[0]] ; Create and initialize the task reference stack to 0 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _TaskRun ; Description ...: Runs a new task as specified in $sCommand ; Syntax ........: _TaskRun($vIndex, $sCommand[, $sParser = "__NOP"[, $vTimeout = False]]) ; Parameters ....: $vIndex - A variant value passed by the caller as a reference to this task. ; this value will be returned to the callback function along with results. ; ; $sCommand - A string value containing the full command to be executed ; ; $sParser - [optional] The name of the function to be called at the end of this task. ; Default is __NOP that is a "do nothing" function. ; P.S. ; the $aParser function will be called by the _TasksCheckStatus() function when ; this task will finish to run: ; an 1D array with 4 elements will be passed to the called function: ; element [0] the caller's index reference of this task ; element [1] the StdOut result of this task ; element [2] the StdErr result of this task ; element [3] the time spent by this task ; ; $vTimeout - [optional] A variant value. Default is False. ; if specified is the number of seconds for the Timeout. ; After this amount of seconds, if this task is still running, it is killed ; ; Return values .: the total number of stacked tasks ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _TaskRun($vIndex, $sCommand, $sParser = "__NOP", $vTimeout = False) ; ; Stack structure: ; ; +-----+ ; 0 | nr. | <-- [0][0] number of running tasks ; +-----+-----+-----+-----+-----+-----+-----+ ; 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ; +-----+-----+-----+-----+-----+-----+-----+ ; n | * | * | * | * | * | * | * | ; | | | | | | | ; | | | | | | [n][6] setted with the TimerInit() value at the start of this task. ; | | | | | | ; | | | | | [n][5] contains the required Timeout in seconds (Default is set to False = no timeout) ; | | | | | ; | | | | [n][4] The CallBack function name that will receive the results of this task ; | | | | ; | | | [n][3] the error message returned by the StdErr stream of this task ; | | | ; | | [n][2] the result of the command returned by the StdOut stream of this task ; | | ; | [n][1] the reference of this task passed by the user (will be passed back to the caller along with results) ; | ; [n][0] the PID of this running task ; ReDim $aTasks[$aTasks[0][0] + 2][7] ; add a new element to the stack $aTasks[0][0] += 1 ; add 1 to the number of running tasks ; Run the passed command with the I/O streams redirected $aTasks[$aTasks[0][0]][0] = Run($sCommand, "", @SW_HIDE, 6) ; 6 -> $STDOUT_CHILD (0x2) + $STDERR_CHILD (0x4) ; store references of this task to the stack $aTasks[$aTasks[0][0]][1] = $vIndex $aTasks[$aTasks[0][0]][4] = $sParser $aTasks[$aTasks[0][0]][5] = $vTimeout ; can be False or the number of seconds for the timeout of this task $aTasks[$aTasks[0][0]][6] = TimerInit() ; store the TimerInit() value for this task Return $aTasks[0][0] ; return the total number of running tasks EndFunc ;==>_TaskRun ; #FUNCTION# ==================================================================================================================== ; Name ..........: _TasksCheckStatus ; Description ...: Scans the status of all active tasks and checks if some task has finished its job ; This function should be called as aften as possible ; Syntax ........: _TaskCheckStatus() ; Parameters ....: None ; Return values .: number of still running tasks; * see remarks ; Author ........: Chimp ; Modified ......: ; Remarks .......: When a task finish, it is removed from the stack and results are passed to the callback function. ; An 1D array with 4 elements will be passed to the called function: ; element [0] the caller's index reference of this task ; element [1] the StdOut result of this task ; element [2] the StdErr result of this task ; element [3] the time spent by this task (approximative time) ; is an approximate datum because it also includes the delay ; added by the main loop before calling _TasksCheckStatus() ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _TasksCheckStatus() If $aTasks[0][0] = 0 Then Return 0 ; if no tasks then return Local $bEndTask ; will be setted to True if the checked task has finished or is killed by timeout Local $iPointer = 1 ; start checking from first task in the stack Local $aResults[4] ; this Array will be loaded with the results of the task Local $sCallBack ; the name of the function to call when a task ends its job Local $aArgs[2] = ["CallArgArray", ""] ; "special" array will be loaded with parameters for the CallBack function While $iPointer <= $aTasks[0][0] $bEndTask = False $aTasks[$iPointer][2] &= StdoutRead($aTasks[$iPointer][0]) ; read and store the StdOut stream $aTasks[$iPointer][3] &= StderrRead($aTasks[$iPointer][0]) ; read and store the StdErr stream ; If @error Then ; if there is an @error is because this task has finished its job If Not ProcessExists($aTasks[$iPointer][0]) Then ; if this task has finished its job $bEndTask = True ; flag the end of the work ElseIf $aTasks[$iPointer][5] <> False Then ; if task is still running see if a Timeout check was rquired and if so if is been reached If Int(TimerDiff($aTasks[$iPointer][6]) / 1000) >= $aTasks[$iPointer][5] Then ; timeout reached or exceeded!! $aTasks[$iPointer][3] = "@error Timeout " & $aTasks[$iPointer][3] ; insert an error message at the beginning of the StdErr stream StdioClose($aTasks[$iPointer][0]) ; close I/O streams ProcessClose($aTasks[$iPointer][0]) ; kill this process $bEndTask = True ; flag the end of this task EndIf EndIf If $bEndTask Then ; if this task has finished, get its results and send to the CallBack function $aResults[0] = $aTasks[$iPointer][1] ; ............. Index (the caller reference) $aResults[1] = $aTasks[$iPointer][2] ; ............. the StdOut generated by this task $aResults[2] = $aTasks[$iPointer][3] ; ............. the StdErr generated by this task $aResults[3] = TimerDiff($aTasks[$iPointer][6]) ; .. time spent by this task $sCallBack = $aTasks[$iPointer][4] ; the name of the function to be called $aArgs[1] = $aResults ; second element of the "CallArgArray" special array contains the $aResults array ; loaded with the parameters to be send to the CallBack function. (array in array) ; (the CallBack function will receive only the 1D 4 elements array $aResults) __TaskRemove($iPointer) ; remove references of this task from the stack ; call the CallBack function and pass the results of this task. ; (CallBack function should return as soon as possible because it stops the CheckStatus for the other tasks) ; Call($sCallBack, $aArgs) ; Call CallBack function --->---+ ; | ; <--- and return here ---------------------------------+ EndIf $iPointer += 1 ; check next task WEnd Return $aTasks[0][0] EndFunc ;==>_TasksCheckStatus ; Internal use. Remove the task references from the stack Func __TaskRemove($iElement) #cs If $iElement > $aTasks[0][0] Or $iElement < 1 Then Return StdioClose($aTasks[$iElement][0]) _ArrayDelete($aTasks, $iElement) #ce ; - new -------------------------------------------------- ; remove element without the _Array* udf If $iElement > 0 And $iElement <= $aTasks[0][0] Then StdioClose($aTasks[$iElement][0]) If $aTasks[0][0] > 1 Then For $i = 0 To UBound($aTasks, 2) - 1 $aTasks[$iElement][$i] = $aTasks[$aTasks[0][0]][$i] Next EndIf Else Return ; queue is empty or the required element is out of bound EndIf $aTasks[0][0] -= 1 ReDim $aTasks[$aTasks[0][0] + 1][UBound($aTasks, 2)] Return $aTasks[0][0] ; returns the number of tasks still running EndFunc ;==>__TaskRemove ; Internal use. An empty function Func __NOP($aDummy) ; NOP (No OPeration) EndFunc ;==>__NOP Example of use ; #RequireAdmin #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include '.\MultiTask.au3' ; ; IMPORTANT following array should be populated with many real HostNames ; here are just nonsense items used as placeholders Global $aIPList[] = [@ComputerName, @IPAddress1, @ComputerName, @ComputerName, 'InexistentClient', @ComputerName] Global $hGrid ; The ListView Handle Global $ahGrid[1] ; An array to keep handles of any listview row Example() MsgBox(0, "Debug:", "Done" & @CRLF & "Hit OK to exit") Func Example() Local $Form1 = GUICreate("Clients status", 760, 400) ; ; Create the ListView $hGrid = GUICtrlCreateListView("HostName|IP|Info|Last reboot|CPU|Last logon|Current logon", 0, 0, 760, 400) _GUICtrlListView_SetColumnWidth($hGrid, 0, 140) ; HostName _GUICtrlListView_SetColumnWidth($hGrid, 1, 100) ; IP _GUICtrlListView_SetColumnWidth($hGrid, 2, 80) ; Ping info ms or Off or Unknown or Timeout) _GUICtrlListView_SetColumnWidth($hGrid, 3, 120) ; Last Reboot _GUICtrlListView_SetColumnWidth($hGrid, 4, 40) ; cpu load ; last 2 columns a mutually exclusive. If there is a user logged it's shown on the last column ; if there is not a user logged then the last user that was logged is shown on column 4 instead _GUICtrlListView_SetColumnWidth($hGrid, 5, 140) ; Last logged UserId (if nobody is logged now) _GUICtrlListView_SetColumnWidth($hGrid, 6, 140) ; Currently logged UserId _GUICtrlListView_SetExtendedListViewStyle($hGrid, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ; show grid; select whole row ; GUISetState(@SW_SHOW) ; following line is needed if you have to refill the listview ; _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hGrid)) ; empty the listview ReDim $ahGrid[UBound($aIPList)] ; this loop will run all needed tasks at once. ; The results of the tasks will be managed by the callback functions (nearly) autonomously and asynchronously For $i = 0 To UBound($aIPList) - 1 $ahGrid[$i] = _GUICtrlListView_AddItem($hGrid, "") ; create a listview row ; ; ... for each client ... ; ; spawn ping commands. result will be send to the _PingParse() function _TaskRun($i, "Ping -a -n 1 -4 " & $aIPList[$i], "_PingParse") ; spawn commands to recall LoggedOn User. Result will be send to the _LoggedOn() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " computersystem get username /value", "_LoggedOn", 5) ; 5 = timeout in 5 seconds ; spawn commands to recall Last reboot time. result will be send to the _LastReboot() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " os get lastbootuptime /value", "_LastReboot", 5) ; spawn commands to recall % of CPU load. result will be send to the _CPU_load() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " cpu get loadpercentage /value", "_CPU_load", 7) Next ; now, while all tasks are running ; we could perform other activities in the meantime ; or we can wait the end of all the tasks Do Sleep(250) ; you could perform other jobs here while waiting for the tasks to finish Until Not _TasksCheckStatus() ; <-- this function performs management of running tasks ; and should be called as often as possible EndFunc ;==>Example ; below are CallBack functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _PingParse (a callback function) ; Description ...: this function analize the output of a ping command and "extract" needed infos ; it fills columns 0 1 and 2 of the list view ($aTarget[0] is the line number of the listview to be filled) ; Syntax ........: _PingParse($aTarget[, $bDomain = True]) ; Parameters ....: $sTarget - An array with Ping results passed by the MultiTasks as soon as any ping task ends ; the passed array contains following data: ; $aTarget[0] Index for this task ; $aTarget[1] StdOut from ping (the whole output of the ping) ; $aTarget[2] StdErr from ping ; $aTarget[3] Time spent by this task to complete (is NOT the ping roundtrip time) ; $bDomain - [optional] A binary value. Default is True. (keep domain info in host name) ; ; Return values .: None. It Fills Listview columns 0, 1 and 2 ; column 0 : resolved HostName or "" ; column 1 : IP address or "" (this can contain last known IP even if now is offline) ; column 2 : roundtrip time or "Unknown" or "timeout" or "Off" ; ; Author ........: Chimp ; =============================================================================================================================== Func _PingParse($aTarget, $bDomain = True) ; $aTarget contains 4 elements: [0] Index, [1] StdOut, [2] StdErr, [3] time spent by this task Local $sOutput = $aTarget[1] ; stdout Local $0, $1, $2, $3, $aMs ; Local $iAnswer = -1, $iName = -1 Local $aResult[3] = ["", "", ""] ; [0]ms, [1]HostName, [2]IP $aMs = StringRegExp($sOutput, "([0-9]*)ms", 3) If Not @error Then ; Ping replayed $aResult[0] = $aMs[UBound($aMs) - 1] ; average ms Else ; $aResult[0] = "off" EndIf $0 = StringInStr($sOutput, "Ping") $1 = StringInStr($sOutput, "[") ; HostName decoded? If $1 Then ; HostName decoded $2 = StringInStr($sOutput, "]") $3 = StringInStr($sOutput, " ", 0, -2, $1) $aResult[1] = StringMid($sOutput, $3 + 1, $1 - $3 - 1) ; HostName $aResult[2] = StringMid($sOutput, $1 + 1, $2 - $1 - 1) ; IP Else If $0 Then ; pinging an IP address? ; $aResult[1] = "" ; no HostName Local $aFindIP = StringRegExp($sOutput, "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", 3) If Not @error Then $aResult[2] = $aFindIP[0] Else ; unknown HostName $aResult[0] = "Unknown" $aResult[1] = $aIPList[$aTarget[0]] ; retrieve HostName from the $aIPList array EndIf EndIf If $bDomain = False Then Local $aSplit = StringSplit($aResult[1], ".", 2) ; 2 = $STR_NOCOUNT $aResult[1] = $aSplit[0] ; romove .domain part from the HostName EndIf If StringLeft($aTarget[2], 14) = "@error Timeout" Then $aResult[0] = "Timeout" ; Now that we have the infos, we compile related cells in ListView ; grid row-handle data column _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[1], 0) ; first column "HostName" _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[2], 1) ; second column "IP address" _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[0], 2) ; third column "Infos about the ping" ; ConsoleWrite("Debug: " & "-> " & $aResult[0] & @TAB & $aResult[1] & @TAB & $aResult[2] & @CRLF) EndFunc ;==>_PingParse Func _LastReboot($aParameters) ; Last reboot DateTime $aParameters[1] = StringStripWS($aParameters[1], 8) Local $equal = StringInStr($aParameters[1], "=") If $equal Then _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], WMIDateStringToDate(StringMid($aParameters[1], $equal + 1)), 3) ; column 3 EndIf EndFunc ;==>_LastReboot Func _CPU_load($aParameters) ; % of CPU load $aParameters[1] = StringStripWS($aParameters[1], 8) Local $equal = StringInStr($aParameters[1], "=") If $equal Then _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], StringMid($aParameters[1], $equal + 1), 4) ; column 4 EndIf EndFunc ;==>_CPU_load Func _LoggedOn($aParameters) ; User now logged $aParameters[1] = StringStripWS($aParameters[1], 8) ; if none is logged, then find the user that was last logged (also using _TaskRun) If $aParameters[1] = "" Or $aParameters[1] = "UserName=" Then ; following syntax is by @iamtheky (thanks) ; https://www.autoitscript.com/forum/topic/189845-regexp-pattern-in-findstr-dos-command/?do=findComment&comment=1363106 Local $sCmd = 'cmd /c FOR /F "usebackq skip=2 tokens=1-3" %A IN (`REG QUERY ' & '"\\' & $aIPList[$aParameters[0]] & _ '\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /REG:64 /v LastLoggedOnUser 2^>nul`) Do @echo %C' _TaskRun($aParameters[0], $sCmd, "_LastLogged", 5) ; find last logged user and, when ready, send result to _LastLogged() Else ; if someone is logged then write username to column 6 Local $aUser = StringSplit($aParameters[1], "=", 2) ; 2 = $STR_NOCOUNT _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], $aUser[UBound($aUser) - 1], 6) ; column 6 EndIf EndFunc ;==>_LoggedOn Func _LastLogged($aParameters) _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], $aParameters[1], 5) ; column 5 EndFunc ;==>_LastLogged Func WMIDateStringToDate($dtmDate) ; thanks to @kylomas ; https://www.autoitscript.com/forum/topic/169252-wmi-password-age-issue/?do=findComment&comment=1236082 ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1') EndFunc ;==>WMIDateStringToDate1 point
-
Hi guys, I needed a simple function to download files and show the progress of the download. I commented a bit (don't know if i should have added more) You can provide the url to the file, the wanted file name, the visible name for in the download progress UI, where the file should be downloaded to, if the progressbar should be hidden at the end of the function or if it should remain visible, how long the last message (completed/failed) should show and last but not least, a title for the progress window. At the end of the function you either get the full path of the download file or false when it fails with @error set and @extended set with the error code of the download. #include <InetConstants.au3> Func _webDownloader($sSourceURL, $sTargetName, $sVisibleName, $sTargetDir = @TempDir, $bProgressOff = True, $iEndMsgTime = 2000, $sDownloaderTitle = "MyDownloader") ; Declare some general vars Local $iMBbytes = 1048576 ; If the target directory doesn't exist -> create the dir If Not FileExists($sTargetDir) Then DirCreate($sTargetDir) ; Get download and target info Local $sTargetPath = $sTargetDir & "\" & $sTargetName Local $iFileSize = InetGetSize($sSourceURL) Local $hFileDownload = InetGet($sSourceURL, $sTargetPath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND) ; Show progress UI ProgressOn($sDownloaderTitle, "Downloading " & $sVisibleName) ; Keep checking until download completed Do Sleep(250) ; Set vars Local $iDLPercentage = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) * 100 / $iFileSize, 0) Local $iDLBytes = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) / $iMBbytes, 2) Local $iDLTotalBytes = Round($iFileSize / $iMBbytes, 2) ; Update progress UI If IsNumber($iDLBytes) And $iDLBytes >= 0 Then ProgressSet($iDLPercentage, $iDLPercentage & "% - Downloaded " & $iDLBytes & " MB of " & $iDLTotalBytes & " MB") Else ProgressSet(0, "Downloading '" & $sVisibleName & "'") EndIf Until InetGetInfo($hFileDownload, $INET_DOWNLOADCOMPLETE) ; If the download was successfull, return the target location If InetGetInfo($hFileDownload, $INET_DOWNLOADSUCCESS) Then ProgressSet(100, "Downloading '" & $sVisibleName & "' completed") If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf Return $sTargetPath ; If the download failed, set @error and return False Else Local $errorCode = InetGetInfo($hFileDownload, $INET_DOWNLOADERROR) ProgressSet(0, "Downloading '" & $sVisibleName & "' failed." & @CRLF & "Error code: " & $errorCode) If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf SetError(1, $errorCode, False) EndIf EndFunc ;==>_webDownloaderLet me know what you think The test in my example is done with the installer for java 8 update 65 Example usage : $url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=111687" $file = "Java_8_Update_65.exe" $name = "Java 8 Update 65" $dir = @TempDir & "\MyDownloader" $installcommand = " /s STATIC=Disable AUTO_UPDATE=Disable WEB_JAVA=Enable WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=Disable EULA=Enable REBOOT=Disable SPONSORS=Disable" $test = _webDownloader($url, $file, $name, $dir, False) If $test Then ProgressSet(100, "Running silent installation...", "Installing " & $name) $exitCode = RunWait($test & $installcommand) If $exitCode = 0 Then ProgressSet(100, "Installation completed") If $exitCode <> 0 Then ProgressSet(0, "Installation failed" & @CRLF & "Exit code: " & $exitCode) Sleep(3000) ProgressOff() FileDelete($test) Else ProgressOff() EndIfGreetz _webDownloader.au31 point
-
That is indeed a way to handle this and will add that to the standard setup. Thanks!1 point
-
And this is the solution for Ctrl+B as well: function AutoItTools:OnChar(c) --~ print("Char:" .. c) if editor.Lexer == SCLEX_AU3 then -- set propercase if props['proper.case'] == '1' and string.find(c, "[ =(]") then self:ProperCase(c) end -- abbreviations logic will auto expand on space when SCE_AU3_EXPAND. written by Jos van der Zande (JdeB) local ls = editor.StyleAt[editor.CurrentPos-2] if ls == SCE_AU3_EXPAND and c == " " then self:Abbreviations(1) end end end -- OnChar() function AutoItTools:OnKey(code, shift, control, alt) if editor.Lexer == SCLEX_AU3 then local ls = editor.StyleAt[editor.CurrentPos-2] if ls == SCE_AU3_EXPAND and string.char(code):lower() == 'b' and control and not shift and not alt then self:Abbreviations(0) end end end ... function AutoItTools:Abbreviations(i) if i==1 then editor:DeleteBack() end local from = editor:WordStartPosition(editor.CurrentPos-i) local to = editor:WordEndPosition(from) local word = editor:textrange(from, to) editor.SelectionStart = editor.CurrentPos - #word editor:ReplaceSel(word:lower()) scite.MenuCommand(IDM_ABBREV) end1 point
-
@TheDcoder why are you so sour ? because of my wife ?1 point
-
Looks like it is working both ways for me. Do you have this settings set in your setup?: #restore last session when selecting Open file from Explorer - Only available in SciTE4AutoIt3 version save.session.advanced=1 Jos1 point
-
Thanks. I can't test today, as I will have cinema night with my wife But this is great news. Regards, mLipok1 point
-
Here is a fix for that: AutoItAbbrevExpand.lua AddEventHandler("OnChar", function(c) if IsLexer(SCLEX_AU3) then local style = editor.StyleAt[editor.CurrentPos - 2] if (style == SCE_AU3_EXPAND) and (c == " ") then editor:DeleteBack() local word = GetCurrentWord() editor.SelectionStart = editor.CurrentPos - #word editor:ReplaceSel(word:lower()) scite.MenuCommand(IDM_ABBREV) end end end) This works only if we use Space key to expand of course, i use only this method. It can be adapted to Ctrl+B as well i think, but this one is enough for me.1 point
-
@cappy2112 you are not clear on your question. To me it looks your mouse position is way off unless you really have a huge screen this works for me as you should calculate your location based on desktopwidth and desktopheight Local $loopCount = 0 Local $maxLoops = 4 consolewrite(@Desktopwidth & @CRLF) consolewrite(@DesktopHeight & @CRLF) While $loopCount < $maxLoops MouseMove(10, 100,0) ; Move the mouse cursor to the x, y position of 10, 100. Sleep(400) MouseMove(@Desktopwidth-100, 100, 0) ; Move the mouse cursor to the x, y position of 700, 700 and move instantly. $loopCount = $loopCount + 1 Sleep(400) WEnd1 point
-
for $x =1 to @Desktopwidth for $y = 1 to @DesktopHeight mouseMove ( $x, $y , 0 ) Next Next1 point
-
Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Moderation Team1 point
-
[Run] Manage Process Hidden
rmassip reacted to JockoDundee for a topic
Not that I’m aware of. What I do is this:1 point -
[Run] Manage Process Hidden
rmassip reacted to JLogan3o13 for a topic
Welcome to the forum. Take a look at the Control* Commands in the Help File. If you grab the element that you want to interact with on the GUI, and use ControlClick, ControlSend, etc. rather than just clicks and sends, it won't matter if the window is visible or not.1 point -
But if you still want to have a single button "Cancel", here how you could do it with MsgBox : #include <WindowsConstants.au3> #include <Constants.au3> #include <SendMessage.au3> #include <WinAPIError.au3> $sCommand = " /AutoIt3ExecuteLine ""MsgBox(0, 'Shutdown'," & _ "'In accordance with company power saving policies, your computer will be shutdown in 1 minute.' & @CRLF & @CRLF & " & _ "'If you wish to abort this process, click the Cancel button below.', 60)""" ConsoleWrite ($sCommand & @CRLF) Run(@AutoItExe & $sCommand) $hWnd = WinWait("Shutdown") $hCtrl = ControlGetHandle($hWnd, "", "Button1") ConsoleWrite ($hWnd & "/" & $hCtrl & @CRLF) $tString = DllStructCreate("char text[7]") $tString.text = "Cancel" _SendMessageA($hCtrl, $WM_SETTEXT, 0, DllStructGetPtr($tString)) ConsoleWrite (_WinAPI_GetLastError() & @CRLF)1 point
-
igana. With that code only pressing the "Cancel" button will prevent shutdown - closing the ExtMsgBox with [X] or allowing the timeout will run the shutdown code. If you want ONLY the timeout to shutdown then you need this: If $x = 9 Then MsgBox($MB_SYSTEMMODAL, 0, "Shutdown", "Shutting down") ; shutdown code Else MsgBox(0, "Shutdown Aborted", "Please remember to power off your computer when you are done.") EndIf M231 point
-
New UX Window in AutoIt v3
edgi reacted to Se7enstars for a topic
1 point -
New Modern UI Window in AutoIt v3
Nyl- reacted to Se7enstars for a topic
1 point -
I'd be happy to. Sorry it's kind of bulky, but it works. Please test the script without altering it for consistency. Once you have tested it please let me know if it crashed for you, so I know if it is just my system. #include <GUIConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ;includes. I wasn't sure which ones were required so I copied them from the original script. ; CREATE THE GUI $GUI = GUICreate("_GUICtrlListView_SortItems causes hard crash", 800, 500) $ListView = GUICtrlCreateListView("Item1|Item2|Item3|Item4|Item4|Item5|Item6|Item7", 0, 0, 800, 500) GUISetState(@SW_SHOW) $loop = 0 ;Set a loop variable to tell the script when to stop creating items $d = "|" ; set a divider variable which kind of serves no real purpose other than saving one keypress big woop. MsgBox(0, "Sort items crash", "Please wait until the list has finished being generated, after that, click a header to sort it.", 6) ;just some FYIs for you _GUICtrlListView_RegisterSortCallBack($ListView) Do $chr0 = Chr(Random(33, 126)) $chr1 = Chr(Random(33, 126)) $chr2 = Chr(Random(33, 126)) $chr3 = Chr(Random(33, 126)) $chr4 = Chr(Random(33, 126)) $chr5 = Chr(Random(33, 126)) $chr6 = Chr(Random(33, 126)) ;create random text for an entry $text = $chr0 & $d & $chr1 & $d & $chr2 & $d & $chr3 & $d & $chr4 & $d & $chr5 & $d & $chr6 ;put it all into one var GUICtrlCreateListViewItem($text, $ListView) ;create it Sleep(10) ;allow some cooldown time $loop = $loop + 1 ;add one to the loop (I hate FOR loops) WinSetTitle("_GUICtrlListView_SortItems causes hard crash", "", "_GUICtrlListView_SortItems causes hard crash - Creating list: " & $loop & "/500") ;tell the user how many entries are left Until $loop > 499 WinSetTitle("_GUICtrlListView_SortItems causes hard crash", "", "_GUICtrlListView_SortItems causes hard crash - Waiting for user input") ;more infoz While 1 Switch GUIGetMsg() ;wait for input Case $GUI_EVENT_CLOSE Exit Case $ListView _GUICtrlListView_SortItems($ListView, GUICtrlGetState($ListView)) ;BOOM! EndSwitch WEndList_View_sort.au31 point
-
ComboBox ReadOnly
Professor_Bernd reacted to xcal for a topic
Why GUICtrlSendMsg($Combo ,$EM_SETREADONLY,false, 0) and #include <GuiCombo.au3> ? #include <GUIConstants.au3> GUICreate('', 120, 40) GUICtrlCreateCombo('', 10, 10, 100, 200, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $WS_VSCROLL)) For $i = 1 To 50 GUICtrlSetData(-1, 'Entry ' & $i) Next GUICtrlSetData(-1, 'Entry 1') GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd1 point