All Activity
- Past hour
-
You need some loop to keep it alive, try something similar to: ; ----------------------------------------------- #include <array.au3> #include <AutoItConstants.au3> #include <file.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ListBackupFolders1() While 1 Sleep(10) WEnd ; ----------------------------------------------- Func ListBackupFolders1() Switch MsgBox(68, "Notice!", "List the backup folders?!") Case 6 Local $sBackupFolderPath = "E:\Text\Native Instruments\Guitar Rig 5\Presets" Local $ArrayFolders = _FileListToArrayRec($sBackupFolderPath, "*", $FLTAR_FOLDERS) _ArrayDisplay($ArrayFolders, "Folder Listing", Default, 64) Case 7 MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled. Exiting!", 1) EndSwitch EndFunc ;==>ListBackupFolders1
- Today
-
Latest update now available, see the first post. If I had only realized, there was so little to do, I would have included the changes in my last update. But I was too tired to investigate anything more yesterday. Anyway, I checked today, and determined I needed to do very little, to get the FIX COVERS button code up-to-speed. I've not changed anything substantial in the way it works, just some of the record keeping aspect. See the following details. Please be advised though, that I haven't tested the process yet ... not since I last tested at least 10 months ago. It should work like it did previously, just with extra records. Some related stuff follows. This will hopefully be the last update, at least for a while, unless I find a bug. So I am now seeing my program as version 1, and essentially as a full version, some incomplete aspects aside, which are not a requirement to use the program successfully. As I have stated previously, I probably won't ever complete those lesser aspects ... not unless I find I need to for something. I now intend to use my program in earnest, which will test all the major elements, including the FIX COVERS button code. Enjoy!
-
Exit Function...but not script!
mr-es335 replied to mr-es335's topic in AutoIt General Help and Support
argumentum, Tried that...no success! ; ----------------------------------------------- #include <array.au3> #include <AutoItConstants.au3> #include <file.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- ListBackupFolders1() ; ----------------------------------------------- Func ListBackupFolders1() Local $sBackupFolderPath = "E:\Text\Native Instruments\Guitar Rig 5\Presets" ; ----------------- Local $ArrayFolders = _FileListToArrayRec($sBackupFolderPath, "*", $FLTAR_FOLDERS) ; ----------------- Local $verify = MsgBox(68, "Notice!", "List the backup folders?!") ; ----------------------------------------------- Select Case $verify = 6 _ArrayDisplay($ArrayFolders, "Folder Listing", Default, 64) Case $verify = 7 MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled. Exiting!", 1) ;~ Exit Return EndSelect ; ----------------------------------------------- EnterSoundFolderName1() EndFunc ;==>ListBackupFolders1 ; ----------------------------------------------- -
ioa747 reacted to a post in a topic: App Control Tray & Policy Manager (App Control for Business)
-
SOLVE-SMART reacted to a post in a topic: App Control Tray & Policy Manager (App Control for Business)
-
argumentum reacted to a post in a topic: App Control Tray & Policy Manager (App Control for Business)
-
App Control Tray & Policy Manager (WildByDesign/WDACTrayTool: System Tray Tool for WDAC) This is likely my most powerful and featured creation with AutoIt. As always, I want to share and give back anything that I create in case it may benefit others. Features: system tray tool for managing App Control for Business (WDAC) policies GUI for managing App Control for Business (WDAC) policies scheduled tasks notifications auto dark-light mode for GUI and system tray built on GitHub Actions Screenshots: Includes: DarkMode UDF originally by @NoNameCode, updated by @argumentum libNotif by @matwachich ExtMsgBox by @Melba23 GUIListViewEx by @Melba23 TaskScheduler by @water XML by mLipok, Eltorro, Weaponx, drlava, Lukasz Suleja, oblique, Mike Rerick, Tom Hohmann, guinness, GMK
- Yesterday
-
Gianni reacted to a post in a topic: Microsoft Edge - WebView2, embed web code in your native application
-
Exit Function...but not script!
argumentum replied to mr-es335's topic in AutoIt General Help and Support
Replace the Exit with a Return. -
Good day, I have the following script: ; ----------------------------------------------- #include <array.au3> #include <AutoItConstants.au3> #inaclude <file.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- ListBackupFolders1() ; ----------------------------------------------- Func ListBackupFolders1() Local $sBackupFolderPath = "E:\Text\Native Instruments\Guitar Rig 5\Presets" ; ----------------- Local $ArrayFolders = _FileListToArrayRec($sBackupFolderPath, "*", $FLTAR_FOLDERS) ; ----------------- Local $verify = MsgBox(68, "Notice!", "List the backup folders?!") ; ----------------------------------------------- Select Case $verify = 6 _ArrayDisplay($ArrayFolders, "Folder Listing", Default, 64) Case $verify = 7 MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled. Exiting!", 1) Exit EndSelect ; ----------------------------------------------- EnterSoundFolderName1() EndFunc ;==>ListBackupFolders1 ; ----------------------------------------------- Func EnterSoundFolderName1() Local $sRootPath = "E:\Text\Native Instruments\Guitar Rig 5\Presets\" Local $sSoundsFolderName = "" ; ----------------------------------------------- While $sSoundsFolderName = "" $sSoundsFolderName = InputBox("NOTICE!", "Enter the Sounds Folder Name...", "", "", 150, 130) ; ----------------- If @error Then MsgBox($MB_ICONWARNING, "Notice!", "The operation was cancelled. Exiting!") Exit Else Local $sBackupPath = DirCreate($sRootPath & $sSoundsFolderName) $sBackupPath = $sRootPath & $sSoundsFolderName DoesFolderExist($sBackupPath) EndIf WEnd EndFunc ;==>EnterSoundFolderName1 ; ----------------------------------------------- Func DoesFolderExist($sBackupPath) Local $sDoesFolderExist = FileExists($sBackupPath) ; ----------------------------------------------- If $sDoesFolderExist Then BackupSoundData($sBackupPath) Else CreateBackupFolder($sBackupPath) EndIf EndFunc ;==>DoesFolderExist ; ----------------------------------------------- Func CreateBackupFolder($sBackupPath) Local $iStart = 2, $iEnd = 1 Local $sSrcPath[$iStart] = [$iEnd] $sSrcPath[1] = $sBackupPath ; ----------------- Local $sMessage = "Create Backup Folder..." & @CRLF & @CRLF, $iWidth = 450, $iHeight = 135 Local $iOpt = 5, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14 ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) ; ----------------------------------------------- For $i = 1 To $sSrcPath[0] Local $sResult = DirCreate($sSrcPath[$i]) $sBackupPath = $sSrcPath[$i] ; ----------------------------------------------- Switch $sResult Case 0 $sResult = "The Backup Folder DOES NOT exist!" Case 1 $sResult = "The Backup Folder WAS created successfully!" EndSwitch ; ----------------------------------------------- $sMessage &= $sResult & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Creating Backup Folder is now completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) Sleep(2000) SplashOff() ; ----------------------------------------------- BackupSoundData($sBackupPath) EndFunc ;==>CreateBackupFolder ; ----------------------------------------------- Func BackupSoundData($sBackupPath) Local $iStart = 2, $iEnd = 1 Local $sSrcPath[$iStart] = [$iEnd] $sSrcPath[1] = "E:\Text\Native Instruments\Guitar Rig 5\Sounds\*.ngrr" ; ----------------- Local $sDstPath[$iStart] = [$iEnd] $sDstPath[1] = $sBackupPath ; ----------------- Local $sMessage = "Backup All Sound File data..." & @CRLF & @CRLF, $iWidth = 450, $iHeight = 135 Local $iOpt = 5, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14 ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) ; ----------------------------------------------- For $i = 1 To $sSrcPath[0] Local $sResult = FileCopy($sSrcPath[$i], $sDstPath[$i], $FC_OVERWRITE) ; ----------------------------------------------- Switch $sResult Case 0 $sResult = "The Sound file data DOES NOT exist!" Case 1 $sResult = "The Sound file data WAS backed-up successfully!" EndSwitch ; ----------------------------------------------- $sMessage &= $sResult & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Backup All Sound File data is now completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) Sleep(2000) SplashOff() EndFunc ;==>BackupSoundData ; ----------------------------------------------- In ListBackupFolders1(), when cancelling the listing,, upon selecting "Exit" the entire script is terminated! Is there any way to exit a function and not the entire script? As always...any assistance in this matter would be greatly appreciated!
-
MattyD reacted to a post in a topic: Create Interface Object on Tag - UDF
-
Object joined the community
-
TheDcoder reacted to a post in a topic: Kobo Cover Fixer
-
Latest update now available, see the first post. I did a stack of work today on the program .... then did a stack more. I started off with some improvements that had occurred to me since yesterday, then discovered a couple of bugs, then thought of some more improvements. Then I discovered my Kobo device was almost flat, so a good time to work with it and test a bunch of things. That led to me finding things weren't as good as I wanted them to be, and that I hadn't completed some stuff that needed to be. So implemented a bunch of things and kept testing, and decided I needed to do a few more, and before you knew it most of the day had disappeared. Eventually my Kobo device was fully charged and so kept connecting and disconnecting, so no more testing, though I still had a bunch of things to code and test without needing my device. Latest Changes While not a huge list, it was a lot of work. I'm pretty sure I still need to do more, especially as I haven't looked at the FIX COVERS code again, yet ... not for 10 months at least. I imagine the process still works okay, just needs some additional Log file recording (perhaps). and some visual updating to the list etc, and perhaps some other records. Anyway, I am pleased to say that the many covers created on my Kobo device today, did the job and worked well. Only a few hundred left to do. Those Fuschia colored rows are successful images copied to my Kobo device. Mostly it was three images per each ebook, but sometimes only one was required. If you look back at a previous screenshot, you can see what has changed.
-
CPU architecture changes and that I think is the difference. So I guess that is the answer to my question. Nope, not it. Edit2: playing around with the script: I got to see what is what ( to a degree ) Intel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | Entry: "copilot" | Count: 15 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.151 | 1 | 0.039 | 0.004 | 1.102 | 1.281 | 0.179 | JsonC-UDF | 2.664 | 2.31 | 0.919 | 0.092 | 2.157 | 8.052 | 5.894 | jq UDF | 46.975 | 40.81 | 2.475 | 0.248 | 44.542 | 55.569 | 11.027 | pure AutoIt JSON-UDF | 217.143 | 188.66 | 4.757 | 0.476 | 206.448 | 236.374 | 29.926 | JSMN-based JSON-UDF | 237.231 | 206.11 | 7.779 | 0.778 | 228.528 | 279.891 | 51.364 | Intel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | Entry: "actions" | Count: 5061 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.585 | 1 | 0.205 | 0.021 | 3.261 | 4.168 | 0.907 | jq UDF | 52.809 | 14.73 | 1.572 | 0.157 | 50.744 | 58.847 | 8.104 | JsonC-UDF | 116.794 | 32.58 | 5.827 | 0.583 | 112.52 | 158.619 | 46.099 | pure AutoIt JSON-UDF | 221.849 | 61.88 | 3.665 | 0.367 | 216.139 | 239.11 | 22.971 | JSMN-based JSON-UDF | 235.16 | 65.6 | 4.233 | 0.423 | 227.894 | 251.581 | 23.687 | 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | Entry: "copilot" | Count: 15 | WinVer: 11 pro name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 0.692 | 1 | 0.17 | 0.017 | 0.547 | 1.215 | 0.668 | JsonC-UDF | 1.098 | 1.59 | 0.203 | 0.02 | 0.882 | 1.88 | 0.998 | jq UDF | 30.073 | 43.46 | 2.542 | 0.254 | 26.073 | 36.233 | 10.161 | pure AutoIt JSON-UDF | 98.456 | 142.28 | 5.62 | 0.562 | 87.521 | 116.823 | 29.301 | JSMN-based JSON-UDF | 107.644 | 155.55 | 6.317 | 0.632 | 94.134 | 125.391 | 31.257 | 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | Entry: "actions" | Count: 5061 | WinVer: 11 pro name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.852 | 1 | 0.403 | 0.04 | 1.364 | 3.101 | 1.738 | jq UDF | 34.722 | 18.75 | 2.798 | 0.28 | 29.726 | 42.913 | 13.187 | JsonC-UDF | 52.277 | 28.23 | 3.896 | 0.39 | 45.481 | 64.209 | 18.728 | pure AutoIt JSON-UDF | 101.908 | 55.03 | 5.282 | 0.528 | 92.217 | 121.343 | 29.127 | JSMN-based JSON-UDF | 111.208 | 60.05 | 6.03 | 0.603 | 101.079 | 133.279 | 32.201 | and ... I should learn RegEx ( nah, too hard. I'll keep shamelessly copy'n'pasteing ). But am satisfied with the results, and it now makes sense to me how a 61 kb DLL vs 962 kb EXE fare against each other given the conditions. ( understood that one is a general purpose library/DLL while the other a highly optimized program for it )
-
In my "coding life", I rarely use JSON and when I do is infrequent and a small string, so speed/efficiency is not a big deal for me in my cases. Having a prettified output is quite important to me because I use it a lot to discern how to go about a JSON when I have to deal with one. .,.back to topic. The "N6000" is a Server 2016 VM but the others are hardware. In my trend of thought, build in ( all AutoIt ) is preferable than having an external file but if is an external file a DLL would be a faster data exchange, but that EXE is kicking other methods ass "from here to China town" as they say. I just don't understand why/how. Also don't get the inconsistencies between one PC and another. And that is my "hmm" moment 🤔
-
Are your tests being run on virtual machines or physical machines?
-
;~ _ArrayDisplay($a_Results, "Results over " & $i_Runs & " loops", "", 16 + 64, Default, "name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range") ;~ #include <SQLite.au3> ConsoleWriteResult() Func ConsoleWriteResult() ConsoleWrite(@CRLF & RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString") & _ " | Runs: " & $i_Runs & " | WinVer: " & FileGetVersion("WinVer.exe") & @CRLF & @CRLF) Local $aHead = StringSplit("name|time[ms]|factor|Std. Dev|Std. Err.|min|max|range", "|", 2) ; header from _ArrayDisplay() ReDim $a_Results[UBound($a_Results) + 2][UBound($a_Results, 2)] For $n = UBound($a_Results) - 3 To 0 Step -1 For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[$n + 2][$m] = $a_Results[$n][$m] Next Next For $m = 0 To UBound($a_Results, 2) - 1 $a_Results[0][$m] = $aHead[$m] $a_Results[1][$m] = "------" Next _SQLite_Display2DResult($a_Results, 0, False, "|", "|" & @CRLF) EndFunc ;==>ConsoleWriteResult Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz | Runs: 100 | WinVer: 10.0.22621.1 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 2.807 | 1 | 0.225 | 0.022 | 2.638 | 3.65 | 1.012 | JsonC-UDF | 90.724 | 32.32 | 2.622 | 0.262 | 87.264 | 104.752 | 17.487 | jq UDF | 163.349 | 58.19 | 8.394 | 0.839 | 135.862 | 182.644 | 46.783 | pure AutoIt JSON-UDF | 171.625 | 61.14 | 3.261 | 0.326 | 164.824 | 184.02 | 19.196 | JSMN-based JSON-UDF | 190.401 | 67.83 | 3.561 | 0.356 | 184.436 | 203.804 | 19.369 | Since sharing pictures ( due to forum user max file(s) space ) gets expensive, sharing the data as text is better for us. This is running @TheXman's test file. Am still wondering on why Win7 is so different from Win11/10 results. Or is it HDD vs NVMe. Or ... 🤔 Edit: another PC: 12th Gen Intel(R) Core(TM) i9-12900H | Runs: 100 | WinVer: 24H2 (26100) name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 | jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 | JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 | pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 | JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 | Intel(R) Pentium(R) Silver N6000 @ 1.10GHz | Runs: 100 | WinVer: 10.0.14393.0 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.255 | 1 | 0.198 | 0.02 | 3.076 | 4.043 | 0.967 | jq UDF | 50.396 | 15.48 | 1.756 | 0.176 | 47.438 | 59.49 | 12.052 | JsonC-UDF | 112.045 | 34.42 | 8.776 | 0.878 | 106.967 | 181.859 | 74.892 | pure AutoIt JSON-UDF | 199.033 | 61.15 | 3.439 | 0.344 | 194.587 | 211.019 | 16.432 | JSMN-based JSON-UDF | 222.099 | 68.23 | 3.823 | 0.382 | 216.491 | 239.937 | 23.446 | Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz | Runs: 100 | WinVer: 10.0.26100.1 name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | StringRegExp only | 3.15 | 1 | 0.15 | 0.015 | 3.002 | 3.628 | 0.626 | jq UDF | 65.22 | 20.7 | 1.928 | 0.193 | 63.274 | 74.064 | 10.791 | JsonC-UDF | 110.34 | 35.03 | 3.961 | 0.396 | 106.711 | 137.913 | 31.202 | pure AutoIt JSON-UDF | 209.692 | 66.57 | 4.29 | 0.429 | 203.294 | 225.663 | 22.368 | JSMN-based JSON-UDF | 226.071 | 71.77 | 4.477 | 0.448 | 218.189 | 247.016 | 28.827 |
-
Understand. I think I will leave it like that, feel it is less prone to bug if user misspelled by error the method-function. However, I could make it clearer to the user if a method-function does not exist. DllCallbackRegister will return an error but it is not obvious what is the reason.
-
I added your UDF to the wiki
-
Just wanted to clarify, the purpose was to remove the requirement. So if you don't define a function for a particular method, you (or something else) can still call it, but you'll actually be executing _NoMthd() so nothing will happen. But yeah, requiring funcs to be provided is an entirely reasonable position too!
-
Remarkably true - I have updated it.
-
@Gianni Apparently if you read through the documentation there are more dependencies needed ... https://www.vbforums.com/showthread.php?899415-OrdoWebview2-ActiveX-WebView2-Browser-Control-(Replacement-of-the-MS-browser-control) They have built a custom vbRichClient based on the RC6, that is built with VB6 and has a few DLL's to download first https://www.vbrichclient.com/#/en/Downloads.htm Next you need to register a few COM components from the downloaded DLL's. It also has to the WebView2Loader.dll in there that is needed... For more info best go to the VB forum to see some example scripts to do some trial and error...
-
Your updated zip file includes jq code in the SpeedComparison.au3 script, but it does not include the required jq.udf and jq-win64.exe files.
-
New version available.
-
@MattyD Thanks. Since we already need to provide a prefixed function for each of the method, we can left its content blank if we do not plan to use it. No reason to call another empty function. Also, if we have unused methods, we can leave their parameters blank, and simply use $pSelf in the callback function as a single parameter.
-
Please help with Run PowerShell Command 'quotes"
SOLVE-SMART replied to Trong's topic in AutoIt General Help and Support
Understood, thanks for the explanation @AspirinJunkie 🤝 . Usually, when I run PS1 snippets or scripts from AutoIt, I simply call powershell with the *.ps1 script file as argument. Then all of these struggles aren't relevant. A very old example, but as showcase okay, can be found here. Best regards Sven -
Please help with Run PowerShell Command 'quotes"
AspirinJunkie replied to Trong's topic in AutoIt General Help and Support
Exactly - it is not escaping for Powershell code. But we're not at that level yet (as I said before: escaping with such nested interpreters is quite annoying...) Escaping per \" is not intended for powershell.exe but for the Windows API function CreateProcessA/W (which is the basis for the AutoIt function Run()). This function must ensure that the parameters are passed correctly to powershell.exe and the syntax is such that double quotation marks are escaped via \". A little clearer with the example: If you execute the following via Run (or from the command line): powershell.exe -Command "Write-Host \"This is a \"\"short\"\" test with multiple \"\"quotes\"\".\"" Then powershell.exe receives the following code as a parameter: Write-Host "This is a ""short"" test with multiple ""quotes""." And your double quotation marks for the powershell are correct again! This is exactly what the _prc_runPS() function does here. -
Please help with Run PowerShell Command 'quotes"
SOLVE-SMART replied to Trong's topic in AutoIt General Help and Support
Hi @AspirinJunkie 👋 , I believe I understood your statement and also the code, but I am a bit confused by the escaping character \ (backslash) which is not a escaping character for powershell - at least as I know so far. In my understanding you have to escape by the same char which you want to escape, in general, or for special chars you have to use ` (backtick). Am I am wrong by this 🤔 ? I personally did always usw "" or `" in the last years which works great. I am sure you will open my eyes with an explanation 🤭 . Best regards Sven -
Please help with Run PowerShell Command 'quotes"
AspirinJunkie replied to Trong's topic in AutoIt General Help and Support
Yes, the escaping of the quotation marks within the commands can be quite annoying. So you have to escape the quotation marks in the command. This is a bit easier if you swap the double quotation marks with the single ones. Something like this: Local $command_r = 'PowerShell -Command "' & StringReplace($powerShellCommand, '"', '\"') & '"' Why you are using @ComSpec (i.e. the cmd.exe) although you want to call the powershell instead is not clear to me. I have written the following function myself. Maybe it will help you here: #include <WinAPIConv.au3> ; Get the list of running processes and filter for processes named "notepad" Local $commandToRun = "Get-Process | Where-Object {$_.ProcessName -eq 'notepad'} | Format-List Name, Id, MainWindowTitle" Local $powerShellResult = _prc_runPS($commandToRun) If @error Then MsgBox(16, "Error", "Could not get results from PowerShell.") Else If $powerShellResult Then MsgBox(64, "PowerShell Result", "Result returned from PowerShell: " & $powerShellResult) Else MsgBox(64, "Information", "No processes match the criteria.") EndIf EndIf ; Another example: Get the PowerShell version Local $versionCommand = "$PSVersionTable.PSVersion" Local $powerShellVersion = _prc_runPS($versionCommand) If Not @error Then MsgBox(64, "PowerShell Version", "PowerShell Version: " & $powerShellVersion) EndIf ; #FUNCTION# ====================================================================================== ; Name ..........: _prc_runPS() ; Description ...: Executes a Powershell command and returns its output as a string ; Syntax ........: _prc_runPS($sCmd, [$nFlags = 0x8, [$sWorkDir = '', [$sOptions = '-NoProfile -ExecutionPolicy Bypass', [$nTimeOut = 0, $bLoopRead = False]]]]]) ; Parameters ....: $sCmd - the powershell command to be executed as you would use it directly in the powershell ; you can also use line breaks ; $nFlags - [optional] flags that control the handling of the two streams stdout and stderr: ; 0x2: [Default] Return a string with the content of stdout ; 0x4: [Default] Return a string with the content of stderr ; 0x6: Return a array with the content of stdout in $Array[0] and stderr in $Array[1] ; 0x8: Return a string with the combined content of stdout and stderr ; $sWorkDir - [optional] the working directory like in Run() ; $sOptions - [String] additional parameters to be passed to powershell.exe ; $nTimeOut - [optional] the maximum time to wait for the process to be completed (see @error return) ; default = 0: infinite; every other number: wait time in seconds ; $bLoopRead - if true: stdout and stderr are read in a loop; if false: they are read in one go ; Return values .: Success: String with powershell output or if $nFlags = 0x6: array with cmdline outputs and set ; @extended = return code of the process ; Failure: "" and set @error to: ; | 1: error during run; @extended = @error of Run() ; | 2: ProcessWaitClose reaches timeout before completion ; | 3: content written in stderr - indicates error messages of the program (not a real error) ; Author ........: AspirinJunkie ; Modified ......: 2025-03-10 ; Related .......: _WinAPI_OemToChar() ; Example .......: Yes ; $x = _prc_runPS('$obj = New-Object -ComObject "Shell.Application"' & @CRLF & _ ; '$obj | Get-Member') ; ConsoleWrite($x & @CRLF) ; ================================================================================================= Func _prc_runPS($sCmd, $nFlags = 0x8, $sWorkDir = '', $sOptions = '-NoProfile -ExecutionPolicy Bypass', $nTimeOut = 0, $bLoopRead = False) ; handling Default keyword word for the parameters If IsKeyWord($nFlags) = 1 Then $nFlags = 0x8 If IsKeyWord($sWorkDir) = 1 Then $sWorkDir = "" If IsKeyWord($sOptions) = 1 Then $sOptions = '-NoProfile -ExecutionPolicy Bypass' ; format command as call parameter, passed to powershell.exe $sCmd = StringFormat('powershell.exe %s -Command "%s"', $sOptions, StringReplace($sCmd, '"', '\"',0,1)) ; start the cmd/process Local $iPID = Run($sCmd, $sWorkDir, @SW_Hide, $nFlags) If @error Then Return SetError(1, @error, "") Local $iExit, $sStdOut = "", $sStdErr = "" If $bLoopRead Then ; fill stdout and/or stderr over a loop Do If BitAND($nFlags, 0x4) Then $sStdErr &= StderrRead($iPID) $sStdOut &= StdoutRead($iPID) If @error Then ExitLoop Until 0 ; determine the exit code $iExit = ProcessWaitClose($iPID, 0) ElseIf ProcessWaitClose($iPID, $nTimeOut) = 0 Then ; wait until process ends Return SetError(2, 0, "") Else ; read out the process results in one go $iExit = @extended $sStdOut = StdoutRead($iPID) $sStdErr = BitAND($nFlags, 0x4) ? StderrRead($iPID) : "" EndIf ; return only stderr If $nFlags = 0x4 Then Return SetExtended($iExit, _WinAPI_OemToChar($sStdErr)) ; return array if stdout and stderr should be read separately ElseIf $nFlags = 0x6 Then Local $aRet[2] = [_WinAPI_OemToChar($sStdOut), _WinAPI_OemToChar($sStdErr)] Return SetError($sStdErr = "" ? 0 : 3, $iExit, $aRet) EndIf ; return a string Return SetExtended($iExit, _WinAPI_OemToChar($sStdOut)) EndFunc -
Hey mate - great work! just a suggestion - take or leave it This *should* add a placeholder for methods we don't care about, and don't want to wrap. (probably requires some more testing) #include <WinAPIConv.au3> #include <WinAPIConstants.au3> ; #ObjFromTag# ================================================================================================================= ; Name ..........: ObjFromTag UDF.au3 ; Description ...: Create COM interface object based on tag instead of CLSID ; Author ........: Nine ; Created .......: 2020-04-14 ; Modified ......: ; Remark ........: Inspired by MattyD, trancexx ; Links .........: https://www.autoitscript.com/forum/topic/212828-byo-com-object/ ; : https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/page/6/#findComment-1143566 ; Example .......: Yes ; =============================================================================================================================== ; #Functions# =================================================================================================================== ; ObjCreateFromTag($sPrefix, $tagInterface, ByRef $tInterface, $sIID = Default, $bIsUnknown = Default) ; _QueryInterface($pSelf, $pRIID, $pObj) ; _AddRef($pSelf) ; _Release($pSelf) ; ObjDeleteFromTag(ByRef $tInterface) ; =============================================================================================================================== Global Const $sIID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}" Global Const $tagIUNKNOWN = _ "QueryInterface hresult(ptr; ptr*);" & _ "AddRef ulong();" & _ "Release ulong();" Global Const $tagIHEADER = "align 4;ptr pObject;long iRefCnt;char sIID[" & StringLen($sIID_IUNKNOWN) + 1 & "];" Global Const $tagIINTERFACE = $tagIHEADER & "int iSize;ptr pVTable[%i];ptr pCallback[%i];" Global $hQueryInterface = DllCallbackRegister("_QueryInterface", "long", "ptr;ptr;ptr*") Global $hAddRef = DllCallbackRegister("_AddRef", "int", "ptr") Global $hRelease = DllCallbackRegister("_Release", "int", "ptr") Global $hNoMethod = DllCallbackRegister("_NoMthd", "int64", "ptr;int64;int64;int64;int64;int64;int64;int64;int64;int64;int64;int64;int64") Func ObjCreateFromTag($sPrefix, $tagInterface, ByRef $tInterface, $sIID = Default, $bIsUnknown = Default) If $sIID = Default Then $sIID = $sIID_IUNKNOWN If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = ($bIsUnknown ? $tagIUNKNOWN : "") & $tagInterface Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($sInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3) Local $iUbound = UBound($aMethods), $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback $tInterface = DllStructCreate(StringFormat($tagIINTERFACE, $iUbound, $iUbound)) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sPrefix & $sNamePart $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringStripWS("ptr" & StringReplace($sTagPart, $sRet, "", 1), $STR_STRIPALL) $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) If @error Then ConsoleWrite( $sMethod & "/" & $sRet & "/" & $sParams & " = " & @error & @CRLF) $hCallback = $hNoMethod If $bIsUnknown Then Switch $i Case 0 $hCallback = $hQueryInterface Case 1 $hCallback = $hAddRef Case 2 $hCallback = $hRelease EndSwitch EndIf EndIf DllStructSetData($tInterface, "pVTable", DllCallbackGetPtr($hCallback), $i + 1) DllStructSetData($tInterface, "pCallback", $hCallback, $i + 1) Next $tInterface.iRefCnt = 1 ; start ref at 1 since creation is completed $tInterface.iSize = $iUbound $tInterface.pObject = DllStructGetPtr($tInterface, "pVTable") $tInterface.sIID = $sIID Return ObjCreateInterface(DllStructGetPtr($tInterface), $sIID, $tagInterface, $bIsUnknown) EndFunc ;==>ObjFromTag Func _QueryInterface($pSelf, $pRIID, $pObj) If Not $pObj Then Return $E_POINTER Local $sIID = _WinAPI_StringFromGUID($pRIID) Local $tInter = DllStructCreate($tagIHEADER, $pSelf) If $sIID = $tInter.sIID Or $sIID = $sIID_IUNKNOWN Then DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) _AddRef($pSelf) Return $S_OK EndIf Return $E_NOINTERFACE EndFunc ;==>_QueryInterface Func _AddRef($pSelf) Local $tInter = DllStructCreate($tagIHEADER, $pSelf) $tInter.iRefCnt += 1 Return $tInter.iRefCnt EndFunc ;==>_AddRef Func _Release($pSelf) Local $tInter = DllStructCreate($tagIHEADER, $pSelf) $tInter.iRefCnt -= 1 Return $tInter.iRefCnt EndFunc ;==>_Release Func _NoMthd($pThis, $vP1, $vP2, $vP3, $vP4, $vP5, $vP6, $vP7, $vP8, $vP9, $vP10, $vP11, $vP12) EndFunc
-
Awesome - that's great @Nine. Just trying to do a bit of a tidy up before moving forward, so I've added a header to post #1 which is basically everything in defined "mfmediaengine.h". None of the other headers included in that file are wrapped - we probably don't need them all anyway to be fair! Any constants in there outside of mfmediaengine.h have only been defined so the include works! I've been at one project or another for last few weeks - so I'll take a few days off, and will be back after a bit of a refresh!