Leaderboard
Popular Content
Showing content with the highest reputation on 12/21/2020 in all areas
-
Happy holidays to all p.s. It looks best on a solid, homogeneous background. To move the tree click on the colored balls and drag. To "turn off" the tree click on it (to set the focus) and then press esc Have fun #include <GUIConstants.au3> #include <WinAPISys.au3> HotKeySet("{ESC}", "_TheEnd") Global $AlphaKey = 0x000000, $hLayer[6], $iWidth = 310, $iHeight = 290, $sBall = '♥' Global Const $aColors[6] = [0x00FF00, 0XFF0000, 0X0040FF, 0XFFFF00, 0X00FFFF, 0XFF00FF] ; 0xRRGGBB Global $a[] = ['.', '~', "'", $sBall, "'", '~', '.', '*', ' '], $tree = $a[8] & $a[7] & @CRLF, _ $hTreeGUI, $ndx, $sGotString, $sGetString, $ChristmasBalls, $sRandomBalls, $iNrOfBalls, $vDummy $hTreeGUI = GUICreate('', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor($AlphaKey, $hTreeGUI) _WinAPI_SetLayeredWindowAttributes($hTreeGUI, $AlphaKey, 0, $LWA_COLORKEY) GUISetState() For $i = 0 To 14 $tree &= StringRight($a[8], 15 - ($i + 1)) For $x = 0 To ($i + 1) * 2 $tree &= $a[Mod($ndx, 7)] $ndx += 1 Next $tree &= @CRLF If $i < 6 Then $hLayer[$i] = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) $vDummy = GUICtrlSetFont(-1, 12, 800, 0, "Courier new") + GUICtrlSetColor(-1, $aColors[$i]) + GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) EndIf Next ; RegExp thanks to @seadoggie01 https://www.autoitscript.com/forum/topic/200770-how-to-clean-a-string-by-regexp/?do=findComment&comment=1440488 $ChristmasBalls = StringRegExpReplace($tree, "(*UCP)(?s)[^\Q" & $sBall & @CRLF & "\E]", " ") ; keep only balls StringReplace($ChristmasBalls, $sBall, $sBall) $iNrOfBalls = @extended GUICtrlSetData($hLayer[0], $tree) ; StringRegExpReplace($tree, "(*UCP)(?s)[\Q" & $a[7] & "\E]", " ")) While Sleep(2000) $sRandomBalls = $ChristmasBalls $RemainingBalls = $iNrOfBalls For $i = 1 To Random(5, $RemainingBalls - 5, 1) $sRandomBalls = StringReplace($sRandomBalls, StringInStr($sRandomBalls, $sBall, 0, Random(1, $RemainingBalls, 1)), " ") $RemainingBalls -= 1 Next For $i = 1 To 5 $sGetString = GUICtrlRead($hLayer[$i]) ; StringReplace(GUICtrlRead($hLayer[$i]), $a[7], " ") $sGotString = $sGetString For $ii = 1 To $RemainingBalls If StringMid($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), 1) = $sBall Then $sGetString = StringReplace($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), " ") EndIf Next If $sGotString <> $sGetString Then GUICtrlSetData($hLayer[$i], $sGetString) Next GUICtrlSetData($hLayer[Random(1, 5, 1)], $sRandomBalls) WEnd Func _TheEnd() If WinActive("[ACTIVE]") = $hTreeGUI Then Exit GUIDelete($hTreeGUI) EndFunc ;==>_TheEnd3 points
-
Map/Dictionary/HashTable - which hash algorithm is used?
Aelc and one other reacted to AspirinJunkie for a topic
I made some performance tests to get a rough indication of which data structure is most appropriate and when. For this, I measured the time needed for adding and reading out at different numbers of elements. These are the results (beware of the logarithmic scale for the axes): Especially the behavior of map is interesting: At small numbers of elements the map structure performs very well and scales quite linear with the number of elements. But then (here at 10,000 elements) there is some sort of cut and the results are getting bad. Scripting.dictionary also shows this behavior but only later a larger number of elements. Now for my question: I suspect, that the AutoIt-Map is internally implemented as hash-table and not with sorting trees. As far as I know the used hash-algorithm in a hash-table will reach the point where it start to produce a lot of collisions which leads to extra treatments. This would explain the showed behavior. But because there is a difference between AutoIt-Map, Scripting.Dictionary and System.Collections.HashTable i have to assume that these each use different hash algorithms. Does anybody know which exact hash algorithms are used internally for these? hashtable.au3 DataStructureComparison.zip2 points -
Version 2021.8.30.2
10,234 downloads
Use MouseClick() need: #RequireAdmin Dll is already integrated in UDF ! ; #INDEX# =============================================================== ; Title .........: ImageSearch ; AutoIt Version : 3.x ; Language ......: English ; Description ...: Check image Appears or Not and Return the position of an image on the desktop ; Author(s) .....: Dao Van Trong - TRONG.LIVE ; ======================================================================= ; #CURRENT# ============================================================= ; _ImageSearch ; _ImageSearch_Area ; _ImageSearch_Wait ; _ImageSearch_WaitArea ; ======================================================================== ;========================================================================= ; ; Author:...........: AutoIT VietNam : Dao Van Trong - TRONG.LIVE ; Description:......: Check image Appears or Not ; Find and return the position of an image on the desktop ; Syntax:........... _ImageSearch_Area, _ImageSearch ; Parameter(s):..... $_ImagePath: The image to locate on the desktop ; May be a list of image by delimited by "|" ; i.e: $_ImagePath = "image1.bmp|image2.bmp|image3.bmp" ; $P_x1 $P_y1: Position of 1st point ; $P_x2 $P_y2: Position of 2nd point - Default is last botton right of desktop ; $_Tolerance: 0 for no tolerance (0-255). Needed when colors of image differ from desktop. e.g GIF ; $_CenterPos: boolen. True will return $array[1] x $array[2] is center of image found. ; False will return top-left position ; Return Value(s):.. Return an array has 3 item ; On Success: $array[0] 1 ; On Failure: $array[0] 0 ; DLL not found or other error: $array[0] -1 ; $array[1] x $array[2]: position of image what found on desktop ; ; Note:............. Use _ImageSearch to search the entire desktop ; _ImageSearch_Area to specify a desktop region to search ; $_ImagePath with more item need more time appear on screen before function can detect. ; Decrease sleep time in the loop to detect faster. But less performance. I.e CPULoad increased ; ;======================================================================== EG 1: ;~ Opt("MustDeclareVars", 1) ;~ #AutoIt3Wrapper_UseX64=y ;~ #AutoIt3Wrapper_Change2CUI=y #RequireAdmin #include "_ImageSearch_UDF.au3" HotKeySet("{Esc}", "_Exit") ; Press ESC for exit Func _Exit() Exit 0 EndFunc ;==>_Exit Global Const $Ask_On_Found = 0 Global Const $Mouse_Move_On_Found = 1 Global Const $Mouse_Click_On_Found = 0 Global Const $iSleep_Time=500 Global $sCount = 0, $_Image_1 = @ScriptDir & "\example.bmp" ; First, use this function to create a file bmp, maybe a desktop icon for example') MsgBox(64 + 262144, 'ImageSearch', 'At first, create a file bmp,' & @CRLF & 'photos that will search on the screen!') _ImageSearch_Create_BMP($_Image_1) ConsoleWrite("! Search for images: " & $_Image_1 & @CRLF & '! Searching on the screen ...' & @CRLF) While 1 ToolTip('(Press ESC for EXIT) Searching ...', 1, 1) Sleep($iSleep_Time) $sCount += 1 Local $return = _ImageSearch($_Image_1) If $return[0] = 1 Then ConsoleWrite('- [' & $sCount & '] Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF) If $Mouse_Move_On_Found Then MouseMove($return[1], $return[2]) Sleep($iSleep_Time) EndIf If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2]) ToolTip('(Press ESC for EXIT) - [' & $sCount & "] Image found:" & " X=" & $return[1] & " Y=" & $return[2], 1, 1) If $Ask_On_Found Then Local $ask = MsgBox(6 + 262144, 'Success [' & $sCount & ']', 'Image found:' & " X=" & $return[1] & " Y=" & $return[2]) If $ask = 2 Or $ask = 3 Or $ask = 5 Or $ask = 7 Then Exit ;No, Abort, Cancel, and Ignore If $ask = 10 Then _ImageSearch_Create_BMP($_Image_1) ; Continue ;Try Again EndIf EndIf Sleep(200) WEnd Video demo: [+] When any problem or error occurs, please make sure that:- Downloaded and used the latest version.- Set screen Screen Scale and layout = 100%- Installed display driver.- Tried turning off the antivirus- Full installation: Microsoft Visual C++ Redistributable 2005->2022 [+] You can download the AIO version of the Visual C++ Redistributable here: -> https://www.mediafire.com/file/0ak8dcj9mdn7nyq/VisualCppRedist_AIO_2005-2022_x86_x64_%5Btrong.live%5D.zip/file -> FOR Windows XP: https://www.mediafire.com/file/5m5lnr1kfg73tc9/VisualCppRedist_AIO_2005-2019_x86_XP_%5Btrong.live%5D.zip/file <!> Password for Extract: trong.live [+] The last full version of SCITE4AutoIT supports windows XP: https://www.autoitscript.com/autoit3/scite/download/archive/v19.1127.1402.0-SciTE4AutoIt3.exe1 point -
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
-
; disable "www.facebook.com" #RequireAdmin $sURL = "www.facebook.com" $sHostsFile = @WindowsDir & "\system32\drivers\etc\hosts" If Not StringInStr(FileRead($sHostsFile), $sURL) Then FileWrite($sHostsFile, @CRLF & "127.0.0.1" & @TAB & @TAB & $sURL & @CRLF) ShellExecute("Notepad.exe", $sHostsFile)1 point
-
Try : _WinAPI_Wow64EnableWow64FsRedirection (False) Before you attempt modifying the file.1 point
-
Thank you. I just didn't read properly the Function InputBox .... It's clearly written ... Maybe I need another pair of glasses : Return Value Success: the string that was entered. Failure: "" (empty string) and sets the @error flag to non-zero. @error: 1 = The Cancel button was pushed. 2 = The Timeout time was reached. 3 = The InputBox failed to open. This is usually caused by bad arguments. 4 = The InputBox cannot be displayed on any monitor. 5 = Invalid parameters width without height or left without top. Thank you very much for the info. Couldn't find it. Regards, Solchael1 point
-
1 point
-
I just had to edit the below lines to get it to work. Dim $s_FileInputPath = @SystemDir & "\drivers\etc\hosts" Dim $s_FileOutputPath = @SystemDir & "\drivers\etc\hosts"1 point
-
(Solved) Blocking Address via Hosts file
PHAK reacted to JLogan3o13 for a topic
You still didn't answer my question. Is the problem that it does not add the address to the Hosts file at all? Or does it add to the file and you can still get to the address?1 point -
(Solved) Blocking Address via Hosts file
PHAK reacted to JLogan3o13 for a topic
"did not help" doesn't give us much to go on, right? Does it not write to the file? Does it write to the file but not block the address? Do you get an error? Also, as there thread you mention has several suggestions in it, how about posting the code you are using specifically, so we can test?1 point -
Yes i have that but now that works good here, thanks alot for your help and you fixed this version, mary cristmas to you.1 point
-
Executing Object Methods through VBScriptIn IPC Techniques through ROT Objects (Data types section) the AutoIt data types have been tested based on the example for the VarGetType() function in the help file. The data types are sent from Sender to Receiver with these results: $aArray : Array variable type. $dBinary : Binary variable type. $bBoolean : Bool variable type. $pPtr : Int32 variable type. $hWnd : Int32 variable type. $iInt : Int32 variable type. $fFloat : Double variable type. $oObject : Object variable type. $sString : String variable type. $tStruct : Not recognized as a valid variable type. $vKeyword : Keyword variable type. fuMsgBox : Not recognized as a valid variable type. $fuFunc : Not recognized as a valid variable type. $fuUserFunc : Not recognized as a valid variable type. Note that an AutoIt object is a data type that is sent correctly from one process to another through a ROT Object. What does it mean that an object is sent correctly from one process to another? This means that the object instance (the specific representation of the object) of the receiving process is exactly the same as the object instance of the sending process. The object of receiver and sender is simply the same object. It's the implementation of the ROT Object that ensures that the object of receiver and sender is the same. If an object $oHexEdit is sent from AutoIt code to VBScript code in this way: Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit and received in the VBScript code in this way: Dim oROTobj, oHexEdit Set oROTobj = GetObject( "DictionaryData" ) Set oHexEdit = oROTobj( "oHexEdit" ) then the $oHexEdit object in the AutoIt code and oHexEdit object in the VBScript code is the same object. Type mismatch errorWhat can all this be used for? This is an example of a Hex Editor ActiveX control based on this CodeProject article. A simple AutoIt implementation can look like this (HexEdit0.au3) #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY $oHexEdit.SetData( $dBinary, 0 ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc The HexEdit ActiveX control must be registered in an elevated Command Prompt with HexEditorOcx\register.bat included in the 7z-file below. HexEditDlg.exe is the test file that is loaded into the ActiveX control. Also contained in the 7z-file. You can also download it all directly from the CodeProject article. HexEditDlg.exe is the demo project. When you run the script in SciTE with F5 you'll see the following COM error in the console: $oHexEdit OK HexEdit0.au3 (30) : ==> COM Error intercepted ! err.number is: 0x80020005 err.windescription: Type mismatch. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 30 err.retcode is: 0x00000000 Line 30 is this line: $oHexEdit.SetData( $dBinary, 0 ) The error is due to the binary data in $dBinary not being transferred correctly to the SetData() method. The first lines of the implementation of the SetData() method in HexEditCtl.cpp (not included in the 7z-file but can be downloaded from the article) looks like this: SCODE CHexEditCtrl::SetData(VARIANT FAR* pData, long dwStartAddr) { if ( ( pData->vt != (VT_ARRAY | VT_UI1) && pData->vt != (VT_ARRAY | VT_I1) ) || ::SafeArrayGetDim(pData->parray) != 1) VARIANT FAR* pData and pData->vt == (VT_ARRAY | VT_UI1) means that the first parameter in Setdata() must be a pointer to a variant, where the data field in the variant can contain a pointer to a safearray of bytes. A safearray of bytes is also referred to as a bytearray. In AutoIt, a bytearray is represented by the Binary data type. Since there are no other data types in AutoIt that correspond to a bytearray, there is actually not really anything to do about the error. The internal AutoIt code is capable of transferring the vast majority of parameter data types to an object method in the correct way. However, there are still several examples of parameter data types being passed incorrectly resulting in a data type mismatch error. And here the VBScript code comes into play. The VBScript language is coded by Microsoft, and Microsoft obviously knows how to pass data to an object method. The idea is to transfer both the $oHexEdit object and the binary data in $dBinary to a VBScript through a ROT Object and then execute the SetData() method directly in the VBScript. Executing VBScript codeHexEdit1.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "IRunningObjectTable.au3" Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary RunWait( 'wscript.exe "HexEdit1.vbs"' ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc HexEdit1.vbs: Dim oROTobj, oHexEdit, dBinary Set oROTobj = GetObject( "DictionaryData" ) Set oHexEdit = oROTobj( "oHexEdit" ) dBinary = oROTobj( "dBinary" ) oHexEdit.SetData dBinary, 0 The ActiveX control in the AutoIt GUI is updated directly through the code in the VBScript: Hopefully someone will take up the challenge and implement a more complete Hex Editor. This is just a Hex Viewer. 7z-fileThe 7z-file contains all the necessary code and data. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. HexEdit is a 32 bit control. The code only runs as 32 bit code. Comments are welcome. Let me know if there are any issues. ObjectMethods.7z1 point
-
Can you guess what is wrong? The variable should be $iIdleTimer but the MsgBox talks about $idleTimer1 point
-
Fixed the error in my post above. BTW: Wasn't too hard to find1 point
-
I would start with something like this: #include <Timers.au3> Global $iIdleTimer, $bStarted = False While 1 Sleep(10) $iIdleTimer = _Timer_GetIdleTime() ; Start service if idle and service not already started If $iIdleTimer > 10000 And $bStarted = False Then RunWait(@ComSpec & " /c " & 'net start ServiceName', "", @SW_HIDE) $bStarted = True EndIf ; Stop service if not idle and service already running If $iIdleTimer < 10 And $bStarted = True Then RunWait(@ComSpec & " /c " & 'net stop ServiceName', "", @SW_HIDE) $bStarted = False EndIf WEnd1 point
-
No the backspace will always be performed on the opened Chrome session no matter what window has the focus.1 point
-
To send a backspace try this : $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE003"}, {"type": "keyUp", "value": "\uE003"}]}]}' _WD_Action($sSession, "actions", $sAction)1 point
-
I'm sure it can be done, but not with the limited information supplied. I would need access to the website or details on the library that implements the element.1 point
-
As I have stated in the PM you've sent me I will reply on the forum. Did you search the forum? I'm sure you'll get a lot of hits when searching for "start service" or something similar.1 point
-
As an elderly man nearing 80 I am still in the notion that a music on line is not mine. If there is a music I want to listen to more than once, I feel I must have it on my hard disk. In old good times right after my retirement, I collected pleny of favorite old pops and classics. I used to use Windows Media Player but I wanted to make a simple music player of my own. In fact that was why I learned coding and it happened to be AutoIt. zPlayer has become my life-time project and I use it all the time when I am home.1 point
-
Hi @mLipok, I'm happy for that! as regards the effect to be obtained, that is the variable transparency and giving a title to the window, it is necessary to modify both the style of the GUI and the method to make the entire window transparent; also I see that you have also parameterized the window width and height values, and so I think you would like to be able to vary the window size at will, but this cannot be done this way because the window size depends on the font size used. . So what would be better to parameterize is the font size. However, finding the size of the window based on the font, size and the "string" it must contain is not an easy thing. Luckily there is a nice UDF created by @Melba23 that does just that. (thank You Melba) So I tweaked your 'fork' a bit to get those effects. Obviously you need to download Melba's StringSize UDF and save it along with the script (https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/) I hope the result is what you wanted to achieve .... have fun #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstants.au3> ; #include <WinAPISys.au3> #include <StringSize.au3> Global $g_hGUI_ChristmasTree ; title Font Size, Delay, BckClr, Transparency (the low the more transp) _Christmas_Tree_Create('Merry Christmas', 18, 500, 0x000000, 200) Func _Christmas_Tree_Create($sInfo, $iFontSize = 12, $iSleep = 2000, $iBackgroundColor = 0x000000, $iTransparencyLevel = 255) HotKeySet("{ESC}", _Christmas_Tree_End) Local $iWidth = 310, $iHeight = 290 Local Const $aColors[6] = [0x00FF00, 0XFF0000, 0X0040FF, 0XFFFF00, 0X00FFFF, 0XFF00FF] ; 0xRRGGBB Local Const $sBall = '♥' Local $hLayer[6] Local $a[] = ['.', '~', "'", $sBall, "'", '~', '.', '*', ' '] Local $tree = $a[8] & $a[7] & @CRLF Local $ndx, $sGotString, $sGetString, $ChristmasBalls, $sRandomBalls, $iNrOfBalls Local $vDummy #forceref $vDummy $g_hGUI_ChristmasTree = GUICreate($sInfo, $iWidth, $iHeight, Default, Default, 0, BitOR(0, $WS_EX_TOPMOST)) ;$WS_EX_LAYERED GUISetBkColor($iBackgroundColor, $g_hGUI_ChristmasTree) ;_WinAPI_SetLayeredWindowAttributes($g_hGUI_ChristmasTree, $iTransparencyColor, $iTransparencyLevel, $LWA_COLORKEY) WinSetTrans($g_hGUI_ChristmasTree, "", $iTransparencyLevel) GUISetState() For $i = 0 To 14 $tree &= StringRight($a[8], 15 - ($i + 1)) For $x = 0 To ($i + 1) * 2 $tree &= $a[Mod($ndx, 7)] $ndx += 1 Next $tree &= @CRLF If $i < 6 Then $hLayer[$i] = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) $vDummy = GUICtrlSetFont(-1, $iFontSize, 800, 0, "Courier new") + GUICtrlSetColor(-1, $aColors[$i]) + GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) EndIf Next ; RegExp thanks to @seadoggie01 https://www.autoitscript.com/forum/topic/200770-how-to-clean-a-string-by-regexp/?do=findComment&comment=1440488 $ChristmasBalls = StringRegExpReplace($tree, "(*UCP)(?s)[^\Q" & $sBall & @CRLF & "\E]", " ") ; keep only balls StringReplace($ChristmasBalls, $sBall, $sBall) $iNrOfBalls = @extended ;---- _StringSize() by Melba23 ---- Local $aDims = _StringSize($tree, $iFontSize, 800, 0, "Courier new") WinMove($g_hGUI_ChristmasTree, '', Default, Default, $aDims[2], $aDims[3]) ;---------------------------------- GUICtrlSetData($hLayer[0], $tree) ; StringRegExpReplace($tree, "(*UCP)(?s)[\Q" & $a[7] & "\E]", " ")) Local $RemainingBalls While Sleep($iSleep) $sRandomBalls = $ChristmasBalls $RemainingBalls = $iNrOfBalls For $i = 1 To Random(5, $RemainingBalls - 5, 1) $sRandomBalls = StringReplace($sRandomBalls, StringInStr($sRandomBalls, $sBall, 0, Random(1, $RemainingBalls, 1)), " ") $RemainingBalls -= 1 Next For $i = 1 To 5 $sGetString = GUICtrlRead($hLayer[$i]) ; StringReplace(GUICtrlRead($hLayer[$i]), $a[7], " ") $sGotString = $sGetString For $ii = 1 To $RemainingBalls If StringMid($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), 1) = $sBall Then $sGetString = StringReplace($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), " ") EndIf Next If $sGotString <> $sGetString Then GUICtrlSetData($hLayer[$i], $sGetString) Next GUICtrlSetData($hLayer[Random(1, 5, 1)], $sRandomBalls) WEnd EndFunc ;==>_Christmas_Tree_Create Func _Christmas_Tree_End() If WinActive("[ACTIVE]") = $g_hGUI_ChristmasTree Then Exit GUIDelete($g_hGUI_ChristmasTree) EndFunc ;==>_Christmas_Tree_End1 point
-
Detecting mouse click other than clicking defined button
FrancescoDiMuro reacted to Melba23 for a topic
NassauSky, The Exit button firing event is sent when the mouse button is released, so you always get the "Button pressed" case firing first. I suggest testing for the location of the cursor like this: #include <GUIConstantsEx.au3> #include <Misc.au3> ; For _IsPressed Global $hGUI = GUICreate("Mouse Click") Global $btnEXIT = GUICtrlCreateButton("EXIT", 0, 0, 70, 40) GUISetState() Local $UserDLL = DllOpen("user32.dll") ;Enable mouse click checking While 1 Switch GUIGetMsg() Case $btnEXIT, $GUI_EVENT_CLOSE DllClose($UserDLL) Exit Case Else Local $cInfo = GUIGetCursorInfo() If _IsPressed("01", $UserDLL) And $cInfo[4] <> $btnEXIT Then ; Check if over button <<<<<<<<<<<<<<<<<<<<<< SplashTextOn("Notice", "Left Button Clicked", 650, 350, -1, 150, 1, -1, 20, 600) Sleep(1000) SplashOff() EndIf EndSwitch WEnd M231 point -
Same issue with error but only on a fresh Win10 machine. ! Dll not found or Call Dll error ! The script works just fine on an existing Win10 computer but if you run this on a fresh installed Win10 machine 32 or 64bit this is the error you get. Same script, same files, same locations. There is clearly some kind of pre-requisite to use the DLL Call. If there is any debug method I can provide this information.1 point
-
Hi guys, I use 7za.exe (7zip’s command line utility) for most of my backups, and use batch files to do the job. But I found that if I want to password protect the archive things gets complex. You can put the password in the cmd line but don't think that is secure. e.g. 7za.exe a test.7z *.au3 -ptest The other option is to enter the password in the command prompt window when prompted for it. e.g. 7za.exe a test.7z *.au3 -p But it only prompt the password once and not twice like most programs do, and that itself is a risk. So I build something with my limited knowledge of Windows and Autoit and would like if you can give me some tips on improving the code, and see if my idea is reasonably safe. Lets say I want to run this on my work computer, will this be secure enough from someone with admin rights snooping on my laptop. I have a small flash drive I keep my personal files on and use this code to make a backup. Basically it will check that a correct password is used and use this password when 7za prompted for it. By testing the password against the hash I would know when prompted for a password and only once, the correct one will be entered. #include <Crypt.au3> ;Password hash = test $hs = '0xEE26B0DD4AF7E749AA1A8EE3C10AE9923F618980772E473F8819A5D4940E0DB27AC185F8A0E1D5F84F88BC887FD67B143732C304CC5FA9AD8E6F57F50028A8FF' ;7za command, basicly update the archive with new files and delete files not found in the flashdrive $cm = @scriptdir & '\7za.exe u "' & @scriptdir & '\FlashBackup.7z" "d:\*" -mhe -ms- -mx3 -ssw -uq0p0 -r -p -y' $tm = 0 $pw = StringToBinary(InputBox("PW"," ","","*",-1,100)); password = test if _Crypt_HashData(BinaryToString($pw), 0x0000800e) = $hs Then $pi = Run(@ComSpec & ' /c ' & $cm, "", @SW_HIDE, 9) $Data_Out='' do $Data_Out &= StdoutRead($pi) if $Data_Out <> @CRLF and $Data_Out <> '' then ConsoleWrite('!> $Data_Out' & $Data_Out & @CRLF) ;Read $Data_Out for specific words to exit or interact If StringInStr($Data_Out, 'Everything is Ok') > 0 Then ExitLoop If StringInStr($Data_Out, 'WARNING') > 0 or StringInStr($Data_Out, 'ERROR') > 0 Then ExitLoop If StringInStr($Data_Out, 'Add new data to archive: 0 files, 0 bytes') > 0 and StringInStr($Data_Out, 'Delete data from archive:') = 0 Then ExitLoop If StringInStr($Data_Out, 'Enter password') > 0 Then StdinWrite($pi, BinaryToString($pw) & @CRLF) If StringInStr($Data_Out, 'Updating archive:') > 0 or StringInStr($Data_Out, 'Creating archive') > 0 Then $pw='' ;clear password $tm = TimerInit() ConsoleWrite('!> Running ...' & @CRLF) endif $Data_Out='' EndIf endif sleep(100) Until @error $pw = '' ProcessClose($pi) if $tm > 0 then ConsoleWrite('!> ' & TimerDiff($tm)/1000 & ' sec' & @CRLF) _DebugOut(TimerDiff($tm)/1000 & ' sec') endif else $pw = '' MsgBox(0,'','Check PW!') exit endif1 point
-
Looks good but a few suggestions. 1) Try using 7za.exe (Command line version) 2) Change ;folder \ fix If StringRight($goutputfolder, 1) = "\" Then ; Else $goutputfolder = $goutputfolder & "\" EndIfoÝ÷ Ù:ºÚ"µÍYÝ[ÔYÚ ÌÍÙÛÝ]]ÛJH ÉÝÈ ][ÝÉÌLÉ][ÝÈ[ ÌÍÙÛÝ]]Û [ÏH ][ÝÉÌLÉ][ÝoÝ÷ Ûp¡jxjëh×6 ;check to make sure delete and recycle is not selected at the same time $del = GUICtrlRead($delete) $rec = GUICtrlRead($recycle) If $del = "1" And $rec = "1" Then MsgBox(48, "Wrong options", "You can't both delete and move to recycle bin") GUICtrlSetState($delete, $GUI_UNCHECKED) GUICtrlSetState($recycle, $GUI_UNCHECKED) EndIf1 point