Leaderboard
Popular Content
Showing content with the highest reputation on 03/14/2021 in all areas
-
If FileExists($aSubkey[1]) Then ;~ Should be If FileExists($aSubkey[0] & $aSubkey[1]) Then1 point
-
Can you post the output of $aSubkey[0] and $aSubkey[1] using the following code within the loop: This will check that there are no spaces in the directory or filename. ConsoleWrite("x" & $aSubkey[0] & "x" & @CRLF & "x" & $aSubkey[1] & "x" & @CRLF)1 point
-
Run_Wrapper.au3 UDF - support topic
argumentum reacted to mLipok for a topic
A new quick/small UDF. #include-once #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Global $RUN_WRAPPER_PID Global Enum _ $RUNWRAPPER_ERR_SUCCESS, _ $RUNWRAPPER_ERR_GENERAL, _ $RUNWRAPPER_ERR_COUNTER Global Enum _ $RUNWRAPPER_EXT_DEFAULT, _ $RUNWRAPPER_EXT_NOT_FINISHED_YET, _ $RUNWRAPPER_EXT_COUNTER If Not @Compiled And @ScriptName = 'Run_Wrapper.au3' Then _Example_for_Run_Wrapper() Func _Example_for_Run_Wrapper() _Run_Wrapper('ping 8.8.8.8') If @error then Return SetError(@error, @extended, 0) While $RUN_WRAPPER_PID Sleep(10) _Run_Wrapper_GetStdout() If @error Then _Run_Wrapper_GetStderr() If @error Then ExitLoop EndIf WEnd MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, 'Information #' & @ScriptLineNumber, _ _Run_Wrapper_GetStdout() & @CRLF & _ _Run_Wrapper_GetStderr() _ ) EndFunc ;==>_Example_for_Run_Wrapper Func _Run_Wrapper($sCommand) _Run_Wrapper_GetStdout(Null) _Run_Wrapper_GetStderr(Null) $RUN_WRAPPER_PID = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @error Then Return SetError($RUNWRAPPER_ERR_GENERAL, $RUNWRAPPER_EXT_DEFAULT, 0) Return $RUN_WRAPPER_PID EndFunc ;==>_Run_Wrapper Func _Run_Wrapper_GetStdout($v_Reset = Default) Local Static $s_StdOut = "" If IsKeyword($v_Reset) And $v_Reset = Null Then $s_StdOut = '' $s_StdOut &= StdoutRead($RUN_WRAPPER_PID) If @error Then Return SetError(@error, $RUNWRAPPER_EXT_DEFAULT, $s_StdOut) Return SetExtended($RUNWRAPPER_EXT_NOT_FINISHED_YET, $s_StdOut) EndFunc ;==>_Run_Wrapper_GetStdout Func _Run_Wrapper_GetStderr($v_Reset = Default) Local Static $s_StdErr = '' If IsKeyword($v_Reset) And $v_Reset = Null Then $s_StdErr = '' $s_StdErr &= StderrRead($RUN_WRAPPER_PID) If @error Then Return SetError(@error, $RUNWRAPPER_EXT_DEFAULT, $s_StdErr) Return SetExtended($RUNWRAPPER_EXT_NOT_FINISHED_YET, $s_StdErr) EndFunc ;==>_Run_Wrapper_GetStderr1 point -
Run_Wrapper.au3 UDF - support topic
mLipok reacted to argumentum for a topic
and now with errorlevel return #include-once #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Global $RUN_WRAPPER_PID, $RUN_WRAPPER_HANDLE, $RUN_WRAPPER_EXITCODE Global Enum _ $RUNWRAPPER_ERR_SUCCESS, _ $RUNWRAPPER_ERR_GENERAL, _ $RUNWRAPPER_ERR_COUNTER Global Enum _ $RUNWRAPPER_EXT_DEFAULT, _ $RUNWRAPPER_EXT_NOT_FINISHED_YET, _ $RUNWRAPPER_EXT_COUNTER If Not @Compiled And @ScriptName = 'Run_Wrapper.au3' Then _Example_for_Run_Wrapper() Func _Example_for_Run_Wrapper() ; https://www.autoitscript.com/forum/topic/204931-run_wrapperau3-udf-support-topic/ _Run_Wrapper('ping 8.8.8,8') If @error Then Return SetError(@error, @extended, 0) While $RUN_WRAPPER_PID Sleep(10) _Run_Wrapper_GetStdout() If @error Then _Run_Wrapper_GetStderr() If @error Then ExitLoop EndIf WEnd MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, 'Information #' & @ScriptLineNumber, _ _Run_Wrapper_GetStdout() & @CRLF & _ _Run_Wrapper_GetStderr() & @CRLF & _ 'ExitCode: ' & _Run_Wrapper_GetExitCode() _ ) EndFunc ;==>_Example_for_Run_Wrapper Func _Run_Wrapper($sCommand, $sWorkingDir = @TempDir, $iShowFlag = @SW_HIDE) $RUN_WRAPPER_HANDLE = 0 ; @TempDir is better than @SystemDir. "Echo text > here.txt" _Run_Wrapper_GetStdout(Null) _Run_Wrapper_GetStderr(Null) $RUN_WRAPPER_PID = Run(@ComSpec & " /c " & $sCommand, $sWorkingDir, $iShowFlag, $STDERR_CHILD + $STDOUT_CHILD) If @error Then Return SetError($RUNWRAPPER_ERR_GENERAL, $RUNWRAPPER_EXT_DEFAULT, 0) _Run_Wrapper_GetExitCode(Null) Return $RUN_WRAPPER_PID EndFunc ;==>_Run_Wrapper Func _Run_Wrapper_GetStdout($v_Reset = Default) Local Static $iError, $s_StdOut = "" If IsKeyword($v_Reset) And $v_Reset = Null Then $s_StdOut = '' $s_StdOut &= StdoutRead($RUN_WRAPPER_PID) $iError = @error If $iError Then _Run_Wrapper_GetExitCode() ; it will only close the OpenProcess if not STILL_ACTIVE Return SetError($iError, $RUNWRAPPER_EXT_DEFAULT, $s_StdOut) EndIf Return SetExtended($RUNWRAPPER_EXT_NOT_FINISHED_YET, $s_StdOut) EndFunc ;==>_Run_Wrapper_GetStdout Func _Run_Wrapper_GetStderr($v_Reset = Default) Local Static $iError, $s_StdErr = '' If IsKeyword($v_Reset) And $v_Reset = Null Then $s_StdErr = '' $s_StdErr &= StderrRead($RUN_WRAPPER_PID) $iError = @error If $iError Then _Run_Wrapper_GetExitCode() ; it will only close the OpenProcess if not STILL_ACTIVE Return SetError($iError, $RUNWRAPPER_EXT_DEFAULT, $s_StdErr) EndIf Return SetExtended($RUNWRAPPER_EXT_NOT_FINISHED_YET, $s_StdErr) EndFunc ;==>_Run_Wrapper_GetStderr Func _Run_Wrapper_GetExitCode($v_Do = Default) ; based on AutoIt3Wrapper If $v_Do = Null Then If IsArray($RUN_WRAPPER_HANDLE) Then __Run_Wrapper_ProcessCloseHandle($RUN_WRAPPER_HANDLE) $RUN_WRAPPER_HANDLE = 0 EndIf Local $aRet, $v_Placeholder If Not IsArray($RUN_WRAPPER_HANDLE) Then If $v_Do = Default Then Return $RUN_WRAPPER_EXITCODE $RUN_WRAPPER_EXITCODE = 0 ; Set/Return the process handle of a PID $RUN_WRAPPER_HANDLE = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', 0x400, 'int', 0, 'int', $RUN_WRAPPER_PID) If Not @error Then Return $RUN_WRAPPER_HANDLE Else $RUN_WRAPPER_HANDLE = 0 EndIf Else ; Set Process Exitcode of PID $aRet = DllCall('kernel32.dll', 'ptr', 'GetExitCodeProcess', 'ptr', $RUN_WRAPPER_HANDLE[0], 'int*', $v_Placeholder) If Not @error And UBound($aRet) > 2 Then $RUN_WRAPPER_EXITCODE = $aRet[2] ; https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess ; STILL_ACTIVE = 259 If $RUN_WRAPPER_EXITCODE <> 259 Then If __Run_Wrapper_ProcessCloseHandle($RUN_WRAPPER_HANDLE) Then $RUN_WRAPPER_PID = 0 $RUN_WRAPPER_HANDLE = 0 EndIf EndIf EndIf Return $RUN_WRAPPER_EXITCODE EndFunc ;==>_Run_Wrapper_GetExitCode Func __Run_Wrapper_ProcessCloseHandle($h_Process) ; from AutoIt3Wrapper DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $h_Process) If Not @error Then Return 1 ; Close the process handle of a PID Return 0 EndFunc ;==>__Run_Wrapper_ProcessCloseHandle1 point -
SSD Size & Longevity/Resilience/Speed
argumentum reacted to Dana86 for a topic
Thanks guys that answered all of my questions!1 point -
The code above will for both scenarios1 point
-
You are concatenating without adding an @CRLF to $found, so will just display one line $found &= $Replace ;Use: $found &= $Replace & @CRLF You also appear to have different format for MuiCache, I see values with .ApplicationCompany and .FriendlyAppName for example: C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe.ApplicationCompany C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe.FriendlyAppName To get the path and filename (with or without the .ApplicationCompany or .FriendlyAppName) you could use something like: $aSubkey = StringRegExp($sSubkey, "(.*\\(?:[^.]*$)?)(.*\.exe)", 3) If Not @error Then ConsoleWrite("Directory : " & $aSubkey[0] & @CRLF & "Filename : " & $aSubkey[1] & @CRLF) EndIf1 point
-
receive informetion from telegram messsage
FrancescoDiMuro reacted to Jos for a topic
You better use the telegram APIs and register a bot for that task.1 point -
Hello Sorry for de long delay for some reason I was not seeing forum's notifications. Could You open Regedit go to this key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\" and do a a search for "COM" or "COM3" or the one you're getting connected to, and show me the key value name, seems to be the the two used by the UDF does not match in your machine. Saludos1 point
-
FileReadToArray vs FileRead & StringSplit - unexpected results
argumentum reacted to jpm for a topic
Hi, the difference comes from the fact that the FileReadToArray is reading line by line as opposed to FileRead which read the whole file. Later on the splitting will work on the whole read buffer and act on it allocating entries of the array more quicker as the delimiter is just the @CRLF. In the case of FileReadToArray the delimiter can be @CR Or @LF or @CRLF which done char by char. That certainly the main overhead. If we want the same speed FileReadToArray will need a new parameter defining the delimiter. Cheers1 point -
View AutoIt Code When Program Is Compiled
bs27975 reacted to FrancescoDiMuro for a topic
@Skeletor FAQ #271 point -
Scoboose, Using a Boolean variable makes the toggle much simpler: #cs ---------------------------------------------------------------------------- Esc - Quits #ce ---------------------------------------------------------------------------- Global $fToggle = True HotKeySet("{ESC}", "Terminate") HotKeySet("n", "Toggle") While 1 While $fToggle ConsoleWrite("MouseClick " & @SEC & @CRLF); In place of MouseClick("Left") Sleep(1000) WEnd WEnd ; Toggle run/pause Func Toggle() $fToggle = Not $fToggle ; <<<<<<<<<<<< really simple syntax! EndFunc ;==>Toggle Func Terminate() Exit EndFunc ;==>Terminate M231 point
-
So on Windows 10 you would need to detect if that folder has already been found, you would also need to separate variables to hold Beta and Release directory Example: (Untested) #RequireAdmin Local $Enum = 0 Local $sSubkey Local $sBetaDir, $sReleaseDir Local $sKey = "HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" While 1 $Enum = $Enum + 1 $sSubkey = RegEnumVal($sKey, $Enum) If @error <> 0 Then ExitLoop Else If StringInStr($sSubkey, "my.exe") Then $aSubkey = StringRegExp($sSubkey, "(.*\\(?:[^.]*$)?)(.*\.exe)", 3) If Not @error Then If FileExists($aSubkey[1]) Then ConsoleWrite($aSubkey[1] & @CRLF) ;ConsoleWrite("Directory : " & $aSubkey[0] & @CRLF & "Filename : " & $aSubkey[1] & @CRLF) If FileExists($aSubkey[0] & "MyPlugin\plugin.pl") Then If StringInStr($aSubkey[0], "\GeneralPurposeAppz\Beta\") > 0 And $sBetaDir <> $aSubkey[0] Then $sBetaDir = $aSubkey[0] If StringInStr($aSubkey[0], "\GeneralPurposeAppz\Release\") > 0 And $sReleaseDir <> $aSubkey[0] Then $sReleaseDir = $aSubkey[0] EndIf EndIf EndIf EndIf EndIf WEnd If FileExists($sBetaDir) Then ShellExecute($sBetaDir) ElseIf FileExists($sReleaseDir) Then ShellExecute($sReleaseDir) Else MsgBox(48, "Not found", "Plugin not found") EndIf0 points