Jump to content

argumentum

MVPs
  • Posts

    5,030
  • Joined

  • Last visited

  • Days Won

    156

argumentum last won the day on August 27

argumentum had the most liked content!

About argumentum

Profile Information

  • Member Title
    ✨Universalist ✨
  • Location
    I'm in your browser now =)
  • WWW
    https://www.youtube.com/watch?v=SjwX-zMRxO0&t=5s
  • Interests
    Relax

Recent Profile Visitors

13,272 profile views

argumentum's Achievements

  1. Yes it did. Fun demo, moving the button around ;That last line of the func should be: (Line 37 in WinRT_WinUI3.au3) ;Return SetError($aCall[0], 0, $aCall[0] = $S_OK) ;So _WinUI3_Startup() should return False on failure, and spit out an error code. ... ... _WinRT_Startup() _WinUI3_Startup() If @error Then ConsoleWrite('! install "https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads" to run this.' & @CRLF) Exit 4 EndIf ... ...
  2. That's not a "q". That's a pitchfork !
  3. Ok. Here to test and report !>14:51:01 AutoIt3 ended. rc:-1073741819 ( running "WindowTest Grid.au3" ) I added a bunch of ConsoleWrite('@@(' & @ScriptLineNumber & ') : ..passed this line...' & @CRLF) ..just to see how far it got and it crashes at: IButtonBase_AddHdlrClick($pButton, $pBtnClick)
  4. GUICtrlSetFont(-1, 24, 600, 0, 'Consolas') ; <<-- This font shows better superscript --<< ...these people ain't gonna show up, but I liked the post
  5. ..I see..., I screwed up. It was never gonna do a thing. Ok, here is the patch. look for the hints and amend with the changes: ... Global $g__Context_Autoit = 0, $g__iShowMenuRet = 0 ; <<<<<<< look for this line ... If $g__iShowMenuRet Then $Msg = $g__iShowMenuRet $g__iShowMenuRet = 0 EndIf If $g__Context_Autoit Then ; <<<<<<< look for this line ... Case $g_ctrl_CloneGui[0] ; <<<<<<< look for this line GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_DISABLE) $g__iShowMenuRet = ShowMenu($hForm, $g_ctrl_CloneGui[0], $g_ctrl_CloneGui[2]) GUICtrlSetState($g_ctrl_CloneGui[0], $GUI_ENABLE) ... ShowMenu() used to return value to .... wait for it ..., no one/no thing ...so it now has a new and shiny $g__iShowMenuRet = ShowMenu() to receive the user choice. I'll upload the changes next week
  6. lol, thanks I'm busy with time sensitive matters. I have a script that needs to be done before tomorrow, and 2 more before Friday. So I'll look at it right after am done with those 3 scripts
  7. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta ; optional #AutoIt3Wrapper_UseX64=Y ; optional #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPIMisc.au3> #include <array.au3> _ArrayDisplay(_WinAPI_GetEnvironmentStrings(), 'Error: ' & @error & ', Extended: ' & @extended) ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetEnvironmentStrings ; Description....: Retrieves environment strings using the Windows API. ; Syntax.........: _WinAPI_GetEnvironmentStrings($bUnicode = True) ; Parameters.....: $bUnicode - [optional] Whether to use Unicode or ANSI. (Default is True/Unicode) ; Return values .: Success: Returns an array of environment variables and their values. ; Failure: Sets the @error flag and returns an empty array. Sets @extended to: ; @extended = 0: There are no environment variables ; @extended = -1: An error occurred while calling the WinAPI function. ; @extended = -2: An error occurred while freeing the environment strings. ; Author ........: MattyD, argumentum ; Modified ......: ; Remarks .......: It retrieves all environment variables and their values. The returned array is structured as follows: ; $aArray[0][0] = Total number of environment variables ; $aArray[n][0] = Name of the variable (string) ; $aArray[n][1] = Value of the variable (string) ; Related .......: ; Link ..........: ; Example .......: _ArrayDisplay(_WinAPI_GetEnvironmentStrings(), 'Error: ' & @error & ', Extended: ' & @extended) ; =============================================================================================================================== Func _WinAPI_GetEnvironmentStrings($bUnicode = True) Local $sFunc, $sType, $iCharLen, $pStr, $iStrLen, $tStr, $sStr, $aStr[1][2] = [[0]], $iIdx = 0 If $bUnicode Then $sFunc = "GetEnvironmentStringsW" $sType = "wchar" $iCharLen = 2 Else $sFunc = "GetEnvironmentStringsA" $sType = "char" $iCharLen = 1 EndIf Local $aCall = DllCall("Kernel32.dll", "ptr", $sFunc) If @error Then Return SetError(@error, -1, $aStr) $pStr = $aCall[0] While 1 $iStrLen = _WinAPI_StrLen($pStr, $bUnicode) + 1 If $iStrLen = 1 Then ExitLoop $tStr = DllStructCreate(StringFormat("%s[%d]", $sType, $iStrLen), $pStr) $pStr = Ptr($pStr + ($iCharLen * $iStrLen)) $sStr = DllStructGetData($tStr, 1) If Not $bUnicode Then $sStr = _WinAPI_OemToChar($sStr) If StringLeft($sStr, 1) = "=" Then ContinueLoop $iIdx += 1 If $iIdx = UBound($aStr) Then ReDim $aStr[Int(10 * $iIdx)][2] $aStr[$iIdx][0] = StringLeft($sStr, StringInStr($sStr, "=") - 1) $aStr[$iIdx][1] = StringTrimLeft($sStr, StringLen($aStr[$iIdx][0]) + 1) WEnd ReDim $aStr[$iIdx + 1][2] $aStr[0][0] = $iIdx __WinAPI_FreeEnvironmentStrings($aCall[0], $bUnicode) If @error Then Return SetError(@error, -2, $aStr) Return SetError(Int(Not $iIdx), $iIdx, $aStr) EndFunc ;==>_WinAPI_GetEnvironmentStrings ; #FUNCTION# =============== internal =========================================================================================== ; Name...........: __WinAPI_FreeEnvironmentStrings ; Description....: Frees memory allocated by the Windows API function GetEnvironmentStringsW or GetEnvironmentStringsA ; Syntax.........: __WinAPI_FreeEnvironmentStrings($pStrings, [$bUnicode = True]) ; Parameters.....: $pStrings - A pointer to a buffer containing environment variables strings. ; $bUnicode - [optional] A boolean indicating Unicode or ANSI (Default is True/Unicode). ; Return values .: Success: Returns True if memory was successfully freed. ; Failure: Sets @error and returns False with @error flag: ; @error = 1: Invalid parameter type or value. ; Author ........: MattyD ; Modified ......: ; Remarks .......: ; Related .......: _WinAPI_GetEnvironmentStrings() ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-FreeEnvironmentStringsA ; Example .......: ; $result = __WinAPI_FreeEnvironmentStrings($pStrings, True) ; =============================================================================================================================== Func __WinAPI_FreeEnvironmentStrings($pStrings, $bUnicode = True) Local $aCall = DllCall("Kernel32.dll", "bool", ($bUnicode ? "FreeEnvironmentStringsW" : "FreeEnvironmentStringsA"), "ptr", $pStrings) If @error Then Return SetError(@error, @extended, False) Return $aCall[0] EndFunc ;==>__WinAPI_FreeEnvironmentStrings This is what am going to use based on @MattyD's Am using this with PHP to run as CUI in "cgi-bin". ...that to go a bit off-topic, this would be a nice addition to the <WinAPISys.au3> UDF ...that to go a bit more off-topic, _WinAPI_ExpandEnvironmentStrings() is limited to 4k ( to stick with the ANSI return in Win9x I guess ) but is a Unicode so, ... it'd be nice to make a revision based on what M$ claims to be a max of 32k on WinXP. But that'd take to DWORD ExpandEnvironmentStringsW( [in] LPCWSTR lpSrc, [out, optional] LPWSTR lpDst, [in] DWORD nSize ); well above of what I know about PC stuff. ( hint ) Thanks
  8. Once I did the _WinApi_FreeEnvironmentStringsA($aRet[0]) AspirinJunkie said, it all worked just fine. Actually it was all fine other than the "FreeEnvironmentStringsA". Never understood why wakillon did the ANSI instead the Unicode but since it worked ( and I don't know anything about any of these ), ok. Thanks for the code Your version works just as well. Then again am working with English right now. I'll have to look at other languages to know what'd be best to use. One thing that pop in my view is that he _WinAPI_StringLenA() the string but you 'wchar[1024]' it. I did change the string split $aSplit[0] = StringLeft($sEnvString, StringInStr($sEnvString, "=") - 1) $aSplit[1] = StringTrimLeft($sEnvString, StringLen($aSplit[0]) + 1) just in case there is another "=" after that. lol. The more the merrier Time for me to catch some ZZzzz
  9. Am using this script and running in x64 and the part of _WinApi_GetEnvironmentStringsA() does not like it on x64, and I don't see why. @wakillon, could you take a look at it ? Works fine as x86. Edit: ..I see that is FreeEnvironmentStringsA that fails.
  10. #RequireAdmin #include <WinAPIProc.au3> ShellExecute("ShowKeyPlus.exe", "", @ScriptDir, "Open") ; load it WinActivate_GuiAndExeToHandle("ShowKeyPlus", "ShowKeyPlus.exe", 5000) ; WinActivate() it Func WinActivate_GuiAndExeToHandle($sTitle, $sExe, $iTimeoutMs = 5000) Local $hWin, $hTimer = TimerInit() Do If TimerDiff($hTimer) > $iTimeoutMs Then ExitLoop $hWin = GuiAndExeToHandle($sTitle, $sExe) If Not $hWin Then Sleep(300) Until $hWin If $hWin Then WinActivate($hWin) Return SetError(Int(Not $hWin), 0, $hWin) EndFunc ;==>WinActivate_GuiAndExeToHandle Func GuiAndExeToHandle($sTitle, $sExe) Local $n, $iPID, $sProcessFileName, $aWinList = WinList($sTitle) For $n = 1 To UBound($aWinList) - 1 $iPID = WinGetProcess($aWinList[$n][1]) If $iPID Then $sProcessFileName = _WinAPI_GetProcessFileName($iPID) ConsoleWrite($sProcessFileName & @CRLF) If StringInStr($sProcessFileName, $sExe) Then Return $aWinList[$n][1] EndIf Next Return 0 EndFunc ;==>GuiAndExeToHandle ;~ Run(@ComSpec & ' /c ShowKeyPlus.exe ShowKeyPlus.txt') ; this works too @MattHiggs: Born 2015 (to the forum), met his demise due to a M$ windows class PS: try Downloads - ShareX for a nice "screen to gif" thingy, without marketing ( it's free too )
  11. Thanks for testing @water. Glad to see that it works on your side too
  12. I want to load the GUI and walk to the folder I make for my stuff. I add a basic entry ( in the code ) and later, add the user/password manually for it to run on its own. I looked at your UDF before reinventing the wheel but did not see a "treeview crawler". It didn't. I updated it. Try it now
  13. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPIProc.au3> ConsoleWrite("Did it work: " & (TaskSchedFolder_GotoFolder("\Microsoft\Windows") ? "YES" : "NO") & " - Error: " & @error & @CRLF) Func TaskSchedFolder_GotoFolder($sFolder = "\Microsoft", $iLoadTaskschdMaxWait_mSec = 5000, $iSelectMaxWait_mSec = 3000) If _IsStartedByScheduler() Then Return SetError(4, 0, 0) ; needs to be interactive If Not IsAdmin() Then Return SetError(3, 0, 0) ; needs Admin rights If @StartupDir = "" Or Not FileExists(@StartupDir) Then Return SetError(2, 0, 0) ; can not run as SYSTEM Local $hTimer, $hWin = TaskSchedFolder_WinGetHandle() If Not WinExists($hWin) Then ShellExecute(@WindowsDir & "\system32\taskschd.msc", "/s") TaskSchedFolder_SleepOnlySoMuch() ; init the func Do $hTimer = TimerInit() If Not TaskSchedFolder_SleepOnlySoMuch(250, $iLoadTaskschdMaxWait_mSec) Then ExitLoop $hWin = TaskSchedFolder_WinGetHandle() Until $hWin EndIf If Not WinExists($hWin) Then Return SetError(1, 0, 0) ; GUI not found WinActivate($hWin) $sFolder = StringReplace($sFolder, "\", "|") If StringLeft($sFolder, 1) = "|" Then $sFolder = StringTrimLeft($sFolder, 1) Local $iSelectedLoopCount, $aFolder = StringSplit("#0|#0|" & $sFolder, "|", 0) $sFolder = "" For $n = 1 To $aFolder[0] $hTimer = TimerInit() $iSelectedLoopCount = 0 ; reset the anti-infinite-loop If $n > 1 Then $sFolder &= "|" $sFolder &= $aFolder[$n] Do $iSelectedLoopCount += 1 If $iSelectedLoopCount > 100 Then ExitLoop 2 If $n < $aFolder[0] Then ControlTreeView($hWin, "", "SysTreeView321", "Expand", $sFolder) ControlTreeView($hWin, "", "SysTreeView321", "Select", $sFolder) ; if not Expanded, is just not there. Sleep(50 * $iSelectedLoopCount) ; wait longer if taking longer If TimerDiff($hTimer) > $iSelectMaxWait_mSec Then ExitLoop 2 Until TaskSchedFolder_SameLevel($sFolder, ControlTreeView($hWin, "", "SysTreeView321", "GetSelected", 1)) Next Return Int($n > $aFolder[0]) EndFunc ;==>TaskSchedFolder_GotoFolder Func TaskSchedFolder_SameLevel($sOne, $sTwo) Local $aOne = StringSplit($sOne, "|") Local $aTwo = StringSplit($sTwo, "|") Return Int($aOne[0] = $aTwo[0]) EndFunc ;==>TaskSchedFolder_SameLevel Func TaskSchedFolder_SleepOnlySoMuch($iSleep = Default, $iMaxSleep = 5000) Local Static $hTimer = TimerInit() If $iSleep = Default Then $hTimer = TimerInit() Return EndIf If TimerDiff($hTimer) > $iMaxSleep Then $hTimer = TimerInit() ; just in case the user don't use it as coded, Return SetError(0, 1, 0) ; keep the sleep going. EndIf ; @extended flag shows that it timed out, and not a sleep() failure. If $iSleep > 2147483647 Then $iSleep = 2147483647 ; max 24 days, after that, sleep fails to sleep. If $iSleep < 10 Then $iSleep = 10 ; min 10 mSec, but even at 10, it may be X mSec longer. Return Sleep($iSleep) EndFunc ;==>TaskSchedFolder_SleepOnlySoMuch Func TaskSchedFolder_WinGetHandle() Local $iWinProcess, $sCmdLine, $aWinList = WinList("[CLASS:MMCMainFrame;]") For $n = 1 To UBound($aWinList) - 1 $iWinProcess = WinGetProcess($aWinList[$n][1]) $sCmdLine = _WinAPI_GetProcessCommandLine($iWinProcess) If StringInStr($sCmdLine, "\taskschd.msc") Then Return $aWinList[$n][1] Next EndFunc ;==>TaskSchedFolder_WinGetHandle Func _IsStartedByScheduler() ; https://www.autoitscript.com/forum/topic/184867-check-if-script-is-running-from-taskscheduler/ Local $iPID1 = _WinAPI_GetParentProcess() Local $iPID2 = _WinAPI_GetParentProcess($iPID1) Return StringRegExp(_WinAPI_GetProcessName($iPID1), "taskeng|svchost") And StringRegExp(_WinAPI_GetProcessName($iPID2), "svchost|services") EndFunc ;==>_IsStartedByScheduler Solved
  14. ... Removed the code. The solution has code. ( I was ashamed of the code ) lol ... I want to get this going not just in English but I can't get the info I need for an international version of it. And using _GUICtrlTreeView_* crashes the Task Scheduler GUI. Help
×
×
  • Create New...