[WDX] Autorun Plugin: Run commands/set envvars on TC start

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

KozakMak wrote: 2022-11-12, 09:33 UTCcan i use DisableMarkedMenuItems in Start menu ?
Yes. Why not?

Code: Select all

DisableMarkedMenuItems ' '
DisableMarkedMenuItems 'Ctrl+Alt+F12'
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

nice!
OS: Win10 | TC: latest x64
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

https://ibb.co/zN1mft9
Is it possible to completely replace ClockTC?
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

KozakMak wrote: 2023-04-03, 07:35 UTCIs it possible to completely replace ClockTC?
Approximately, but only at the expense of WMI, although I'm not sure about NET.

Code: Select all

LoadLibrary Plugins\Autorun_Sysinfo.dll
LoadLibrary Plugins\Autorun_Runtime.dll

Title = WinGetText()
RunThread InfoHeader

Func InfoHeader
   While 1
      Sleep 960
      GetWMIValue W DayOfWeek 'SELECT DayOfWeek FROM Win32_LocalTime'
      GetWMIValue D LocalDateTime 'SELECT LocalDateTime FROM Win32_OperatingSystem'
      GetWMIValue FM FreePhysicalMemory 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem'
      GetWMIValue TM TotalPhysicalMemory 'SELECT TotalPhysicalMemory FROM Win32_LogicalMemoryConfiguration'
      GetWMIValue CPU PercentProcessorTime 'SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor'
      WinSetText(Title & ' | ' & StrPart('Mon Tue Wed Thu Fri Sat Sun', ' ', W) & ' ' & Abs(StrMid(D,7,2)) & ' ' & _
      StrPart('Jan Feb Mar Apr May Yun Yul Aug Sep Oct Nov Dec', ' ', Abs(StrMid(D,5,2))) & ' ' & StrLeft(D,4) & ' ' & _
      StrMid(D,9,2) &  ':' & StrMid(D,11,2) & ':' & StrMid(D,13,2) & ' | RAM: ' & Round(100*(TM-FM)/TM) & '% | CPU: ' & CPU & '%')
   Wend
EndFunc
Last edited by Fla$her on 2023-04-05, 05:57 UTC, edited 5 times in total.
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

Report.wer

Code: Select all

Version=1
EventType=BEX64
EventTime=133249989779573922
ReportType=2
Consent=1
UploadTime=133249989782229991
ReportStatus=268435456
ReportIdentifier=0e0bcacc-7f80-4b40-a84a-ab8b0c16f63d
IntegratorReportIdentifier=57da4896-6d88-408a-85e5-473ee9e92c2f
Wow64Host=34404
NsAppName=TOTALCMD64.EXE
OriginalFilename=totalcmd64.exe
AppSessionGuid=000021c8-0001-0009-17cb-d7de2866d901
TargetAppId=W:0006757703ecb7118b0e3d75614da504998e00000904!0000651697ada73e07da412fa67d5fbdd79d2e21fea8!TOTALCMD64.EXE
TargetAppVer=1970//01//01:00:00:00!99859c!TOTALCMD64.EXE
BootId=4294967295
TargetAsId=1562
UserImpactVector=808452880
IsFatal=1
EtwNonCollectReason=1
Response.BucketId=cad08a72aaed1361710a71358418632f
Response.BucketTable=5
Response.LegacyBucketId=1227918323075277615
Response.type=4
Sig[0].Name=Имя приложения
Sig[0].Value=TOTALCMD64.EXE
Sig[1].Name=Версия приложения
Sig[1].Value=10.52.0.0
Sig[2].Name=Отметка времени приложения
Sig[2].Value=00000000
Sig[3].Name=Имя модуля с ошибкой
Sig[3].Value=Autorun.wdx64_unloaded
Sig[4].Name=Версия модуля с ошибкой
Sig[4].Value=2.2.10.0
Sig[5].Name=Отметка времени модуля с ошибкой
Sig[5].Value=636137b4
Sig[6].Name=Смещение исключения
Sig[6].Value=00000000000188c5
Sig[7].Name=Код исключения
Sig[7].Value=c0000005
Sig[8].Name=Данные исключения
Sig[8].Value=0000000000000008
DynamicSig[1].Name=Версия ОС
DynamicSig[1].Value=10.0.19045.2.0.0.256.48
DynamicSig[2].Name=Код языка
DynamicSig[2].Value=1049
DynamicSig[22].Name=Дополнительные сведения 1
DynamicSig[22].Value=b4ee
DynamicSig[23].Name=Дополнительные сведения 2
DynamicSig[23].Value=b4ee5de6a2322745523997a782b35692
DynamicSig[24].Name=Дополнительные сведения 3
DynamicSig[24].Value=277e
DynamicSig[25].Name=Дополнительные сведения 4
DynamicSig[25].Value=277e19c30fbd5f6bb531ec9e027c37c3
UI[2]=D:\Program Files\Total Commander 64\TOTALCMD64.EXE
LoadedModule[0]=D:\Program Files\Total Commander 64\TOTALCMD64.EXE
LoadedModule[1]=C:\Windows\SYSTEM32\ntdll.dll
LoadedModule[2]=C:\Windows\System32\KERNEL32.DLL
LoadedModule[3]=C:\Windows\System32\KERNELBASE.dll
LoadedModule[4]=C:\Windows\System32\advapi32.dll
LoadedModule[5]=C:\Windows\System32\msvcrt.dll
LoadedModule[6]=C:\Windows\System32\sechost.dll
LoadedModule[7]=C:\Windows\System32\RPCRT4.dll
LoadedModule[8]=C:\Windows\System32\comdlg32.dll
LoadedModule[9]=C:\Windows\System32\combase.dll
LoadedModule[10]=C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e\comctl32.dll
LoadedModule[11]=C:\Windows\System32\ucrtbase.dll
LoadedModule[12]=C:\Windows\System32\GDI32.dll
LoadedModule[13]=C:\Windows\System32\win32u.dll
LoadedModule[14]=C:\Windows\System32\shcore.dll
LoadedModule[15]=C:\Windows\System32\gdi32full.dll
LoadedModule[16]=C:\Windows\System32\msvcp_win.dll
LoadedModule[17]=C:\Windows\System32\USER32.dll
LoadedModule[18]=C:\Windows\System32\SHLWAPI.dll
LoadedModule[19]=C:\Windows\System32\SHELL32.dll
LoadedModule[20]=C:\Windows\System32\imm32.dll
LoadedModule[21]=C:\Windows\System32\ole32.dll
LoadedModule[22]=C:\Windows\System32\oleaut32.dll
LoadedModule[23]=C:\Windows\system32\uxtheme.dll
LoadedModule[24]=C:\Windows\system32\winsta.dll
LoadedModule[25]=C:\Windows\system32\sspicli.dll
LoadedModule[26]=C:\Windows\system32\version.dll
LoadedModule[27]=C:\Windows\system32\winmm.dll
LoadedModule[28]=C:\Windows\system32\mpr.dll
LoadedModule[29]=C:\Windows\system32\dwmapi.DLL
LoadedModule[30]=C:\Windows\system32\WindowsCodecs.dll
LoadedModule[31]=C:\Windows\System32\bcrypt.dll
LoadedModule[32]=C:\Windows\system32\msimg32.dll
LoadedModule[33]=C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.19041.1110_none_792d1c772443f647\comctl32.dll
LoadedModule[34]=C:\Windows\system32\winspool.drv
LoadedModule[35]=C:\Windows\system32\profapi.dll
LoadedModule[36]=C:\Windows\system32\TextShaping.dll
LoadedModule[37]=C:\Windows\SYSTEM32\kernel.appcore.dll
LoadedModule[38]=C:\Windows\System32\bcryptPrimitives.dll
LoadedModule[39]=D:\Program Files\Punto Switcher\PSHook64.dll
LoadedModule[40]=C:\Windows\SYSTEM32\windows.storage.dll
LoadedModule[41]=C:\Windows\SYSTEM32\Wldp.dll
LoadedModule[42]=C:\Windows\SYSTEM32\PROPSYS.dll
LoadedModule[43]=C:\Windows\System32\clbcatq.dll
LoadedModule[44]=C:\Windows\System32\MSCTF.dll
LoadedModule[45]=C:\Windows\SYSTEM32\Uiautomationcore.dll
LoadedModule[46]=C:\Windows\System32\coml2.dll
LoadedModule[47]=C:\Windows\system32\wtsapi32.dll
LoadedModule[48]=C:\Windows\System32\oleacc.dll
LoadedModule[49]=C:\Windows\System32\cfgmgr32.dll
LoadedModule[50]=C:\Windows\system32\dataexchange.dll
LoadedModule[51]=C:\Windows\system32\dcomp.dll
LoadedModule[52]=C:\Windows\system32\d3d11.dll
LoadedModule[53]=C:\Windows\system32\dxgi.dll
LoadedModule[54]=C:\Windows\system32\twinapi.appcore.dll
LoadedModule[55]=C:\Windows\SYSTEM32\mscms.dll
LoadedModule[56]=C:\Windows\SYSTEM32\USERENV.dll
LoadedModule[57]=C:\Windows\SYSTEM32\ColorAdapterClient.dll
LoadedModule[58]=C:\Windows\System32\urlmon.dll
LoadedModule[59]=C:\Windows\System32\iertutil.dll
LoadedModule[60]=C:\Windows\System32\srvcli.dll
LoadedModule[61]=C:\Windows\System32\netutils.dll
LoadedModule[62]=C:\Windows\System32\thumbcache.dll
LoadedModule[63]=C:\Windows\SYSTEM32\policymanager.dll
LoadedModule[64]=C:\Windows\SYSTEM32\msvcp110_win.dll
LoadedModule[65]=C:\Windows\System32\drprov.dll
LoadedModule[66]=C:\Windows\System32\ntlanman.dll
LoadedModule[67]=C:\Windows\System32\davclnt.dll
LoadedModule[68]=C:\Windows\System32\DAVHLPR.dll
LoadedModule[69]=C:\Windows\System32\wkscli.dll
LoadedModule[70]=C:\Windows\SYSTEM32\cscapi.dll
LoadedModule[71]=C:\Windows\SYSTEM32\textinputframework.dll
LoadedModule[72]=C:\Windows\SYSTEM32\CoreUIComponents.dll
LoadedModule[73]=C:\Windows\SYSTEM32\CoreMessaging.dll
LoadedModule[74]=C:\Windows\System32\WS2_32.dll
LoadedModule[75]=C:\Windows\SYSTEM32\ntmarta.dll
LoadedModule[76]=C:\Windows\SYSTEM32\wintypes.dll
LoadedModule[77]=C:\Windows\SYSTEM32\apphelp.dll
LoadedModule[78]=C:\Windows\System32\dlnashext.dll
LoadedModule[79]=C:\Windows\System32\PlayToDevice.dll
LoadedModule[80]=C:\Windows\System32\DevDispItemProvider.dll
LoadedModule[81]=C:\Windows\System32\MMDevApi.dll
LoadedModule[82]=C:\Windows\System32\DEVOBJ.dll
LoadedModule[83]=C:\Windows\system32\wpdshext.dll
LoadedModule[84]=C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.2251_none_91a40448cc8846c1\gdiplus.dll
LoadedModule[85]=C:\Windows\System32\PortableDeviceApi.dll
LoadedModule[86]=C:\Windows\System32\SETUPAPI.dll
LoadedModule[87]=C:\Windows\System32\WINTRUST.dll
LoadedModule[88]=C:\Windows\System32\CRYPT32.dll
LoadedModule[89]=C:\Windows\System32\MSASN1.dll
LoadedModule[90]=C:\Windows\System32\PortableDeviceTypes.dll
LoadedModule[91]=C:\Windows\System32\EhStorAPI.dll
LoadedModule[92]=C:\Windows\system32\USP10.DLL
LoadedModule[93]=C:\Windows\system32\netapi32.dll
LoadedModule[94]=C:\Windows\System32\Windows.FileExplorer.Common.dll
LoadedModule[95]=C:\Users\admin\AppData\Local\Microsoft\OneDrive\23.054.0313.0001\FileSyncShell64.dll
LoadedModule[96]=C:\Windows\SYSTEM32\Secur32.dll
LoadedModule[97]=C:\Windows\SYSTEM32\WININET.dll
LoadedModule[98]=C:\Windows\SYSTEM32\CRYPTBASE.DLL
LoadedModule[99]=C:\Windows\System32\EhStorShell.dll
LoadedModule[100]=C:\PROGRA~1\MICROS~1\Office14\GROOVEEX.DLL
LoadedModule[101]=C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9625_none_08e1c10da83fbc83\MSVCR90.dll
LoadedModule[102]=C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9625_none_08e1c10da83fbc83\MSVCP90.dll
LoadedModule[103]=C:\Windows\WinSxS\amd64_microsoft.vc90.atl_1fc8b3b9a1e18e3b_9.0.30729.4148_none_0a1d2fcba76b3f00\ATL90.DLL
LoadedModule[104]=C:\Windows\System32\cscui.dll
LoadedModule[105]=C:\Windows\system32\wbem\wbemprox.dll
LoadedModule[106]=C:\Windows\SYSTEM32\wbemcomn.dll
LoadedModule[107]=C:\Windows\system32\wbem\wbemsvc.dll
LoadedModule[108]=C:\Windows\system32\wbem\fastprox.dll
LoadedModule[109]=C:\Windows\SYSTEM32\amsi.dll
LoadedModule[110]=C:\Program Files\Windows Defender\MpOav.dll
State[0].Key=Transport.DoneStage1
State[0].Value=1
OsInfo[0].Key=vermaj
OsInfo[0].Value=10
OsInfo[1].Key=vermin
OsInfo[1].Value=0
OsInfo[2].Key=verbld
OsInfo[2].Value=19045
OsInfo[3].Key=ubr
OsInfo[3].Value=2728
OsInfo[4].Key=versp
OsInfo[4].Value=0
OsInfo[5].Key=arch
OsInfo[5].Value=9
OsInfo[6].Key=lcid
OsInfo[6].Value=1049
OsInfo[7].Key=geoid
OsInfo[7].Value=244
OsInfo[8].Key=sku
OsInfo[8].Value=48
OsInfo[9].Key=domain
OsInfo[9].Value=0
OsInfo[10].Key=prodsuite
OsInfo[10].Value=256
OsInfo[11].Key=ntprodtype
OsInfo[11].Value=1
OsInfo[12].Key=platid
OsInfo[12].Value=10
OsInfo[13].Key=sr
OsInfo[13].Value=0
OsInfo[14].Key=tmsi
OsInfo[14].Value=10438
OsInfo[15].Key=osinsty
OsInfo[15].Value=2
OsInfo[16].Key=iever
OsInfo[16].Value=11.789.19041.0-11.0.1000
OsInfo[17].Key=portos
OsInfo[17].Value=0
OsInfo[18].Key=ram
OsInfo[18].Value=8097
OsInfo[19].Key=svolsz
OsInfo[19].Value=49
OsInfo[20].Key=wimbt
OsInfo[20].Value=0
OsInfo[21].Key=blddt
OsInfo[21].Value=191206
OsInfo[22].Key=bldtm
OsInfo[22].Value=1406
OsInfo[23].Key=bldbrch
OsInfo[23].Value=vb_release
OsInfo[24].Key=bldchk
OsInfo[24].Value=0
OsInfo[25].Key=wpvermaj
OsInfo[25].Value=0
OsInfo[26].Key=wpvermin
OsInfo[26].Value=0
OsInfo[27].Key=wpbuildmaj
OsInfo[27].Value=0
OsInfo[28].Key=wpbuildmin
OsInfo[28].Value=0
OsInfo[29].Key=osver
OsInfo[29].Value=10.0.19041.2728.amd64fre.vb_release.191206-1406
OsInfo[30].Key=buildflightid
OsInfo[31].Key=edition
OsInfo[31].Value=Professional
OsInfo[32].Key=ring
OsInfo[32].Value=Retail
OsInfo[33].Key=expid
OsInfo[34].Key=fconid
OsInfo[35].Key=containerid
OsInfo[36].Key=containertype
OsInfo[37].Key=edu
OsInfo[37].Value=0
FriendlyEventName=Остановка работы
ConsentKey=BEX64
AppName=Total Commander
AppPath=D:\Program Files\Total Commander 64\TOTALCMD64.EXE
NsPartner=windows
NsGroup=windows8
ApplicationIdentity=72BD22197102D2E4F6BDD94B431B3727
MetadataHash=-2007835573
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

I forgot Runtime.dll add from above. Done. Your autorun.cfg should already have this line.
In the Autorun\Plugins folder, which versions have Autorun_Runtime.dll64 and Autorun_Sysinfo.dll64?
Is there the same problem on TC x32? Is the third-party tool disabled?
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

Fla$her wrote: 2023-04-03, 15:52 UTC I forgot Runtime.dll add from above. Done. Your autorun.cfg should already have this line.
already have 8)
Fla$her wrote: 2023-04-03, 15:52 UTC In the Autorun\Plugins folder, which versions have Autorun_Runtime.dll64 and Autorun_Sysinfo.dll64?
Is there the same problem on TC x32? Is the third-party tool disabled?
dll
third-party tool is disabled
not tested yet on x32

...and it start normally but fail on exit
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

KozakMak wrote: 2023-04-04, 05:27 UTC...and it start normally but fail on exit
Well, it was worth writing about it right away. How do I know at what point the problem arises?
I am not surprised that multiple access to WMI can cause a conflict at the moment when an interrupt attempt occurs during the execution of yet another request.
1. What is the method of closing TC used in this case?
2. There is a suspicion of a separate thread. What if we remove the lines RunThread InfoHeader, Func InfoHeader, EndFunc and put the inside of the function at the end (before Pragma AutorunFinalizeSection, if any)?
3. And I would like to know about the result of the work itself. Satisfied?
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

Fla$her wrote: 2023-04-04, 08:16 UTC 1. What is the method of closing TC used in this case?
standard X button
Fla$her wrote: 2023-04-04, 08:16 UTC 2. There is a suspicion of a separate thread. What if we remove the lines RunThread InfoHeader, Func InfoHeader, EndFunc and put the inside of the function at the end (before Pragma AutorunFinalizeSection, if any)?
AutorunFinalizeSection?? pls post all code, I don't get it
Fla$her wrote: 2023-04-04, 08:16 UTC 3. And I would like to know about the result of the work itself. Satisfied?
i don't see internet speed at all
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

KozakMak wrote: 2023-04-04, 10:35 UTC AutorunFinalizeSection??
>>>
Fla$her wrote: 2023-04-04, 08:16 UTC before Pragma AutorunFinalizeSection, if any
KozakMak wrote: 2023-04-04, 10:35 UTCi don't see internet speed at all
I assumed so. Then it's better to remove it altogether:

Code: Select all

LoadLibrary Plugins\Autorun_Sysinfo.dll
LoadLibrary Plugins\Autorun_Runtime.dll

Title = WinGetText()

While 1
   Sleep 960
   GetWMIValue D LocalDateTime 'SELECT LocalDateTime FROM Win32_OperatingSystem'
   GetWMIValue FM FreePhysicalMemory 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem'
   GetWMIValue TM TotalVisibleMemorySize 'SELECT TotalVisibleMemorySize FROM Win32_OperatingSystem'
   GetWMIValue CPU PercentProcessorTime  'SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor'
   WinSetText(Title & ' | ' & StrMid(D,7,2) & '.' & StrMid(D,5,2) & '.' & StrLeft(D,4) & ' ' & StrMid(D,9,2) & _
   ':' & StrMid(D,11,2) & ':' & StrMid(D,13,2) & ' | RAM: ' & Ceil(100*(TM-FM)/TM) & '% | CPU: ' & CPU & '%')
Wend
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *KozakMak »

its working! :D
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

Good. Maybe it was about getting 'Speed'. I removed it from the first code. Check him too. After all, it's more practical and correct to use loops in a separate thread. In addition, I added abbreviations of the day of the week and month there. If desired, you can localize them in the first parameter of two StrPart.

Although it is possible to get traffic speed by outputting netstat -e, but then this utility will be cyclically run in a hidden state, it seems to me that this is even worse than using a third-party program.
Overquoting is evil! 👎
User avatar
funkymonk
Senior Member
Senior Member
Posts: 410
Joined: 2013-12-04, 09:56 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *funkymonk »

The Autorun_Runtime.dll in combination with GetWMIValue and WinSetText is exactly what I was searching for in a long time.
See https://www.ghisler.ch/board/viewtopic.php?p=415982&hilit=title#p415982

Many thanks to the author of the plugin!

Yet, I have two questions:
  1. GetWMIValue seems to be quite slow. While this might be a problem with querying WMI in general, it is much slower than other tools using WMI queries. On my systems, most queries on system performance information take 100-200ms when using GetWMIValue.
    Do others have the same problem? Does the author of the plugin see a way to speed GetWMIValue up?
  2. WMI queries return information in the form of a table. It seems that GetWMIValue can only return the requested value from the first row.
    Example:

    Code: Select all

    GetWMIValue("PercentProcessorTime", "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor")
    
    Is there any way to get the entire table and iterate through it?
Thank you!
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *Fla$her »

2funkymonk
Some easy-to-implement functions for obtaining dynamic data through the API are still being considered.
GetWMIValue appeared long before the idea to add a window title setting. I don't think anything can be accelerated here.
I don't know what other tools you are writing about. But on the example of wmic, I see the opposite pattern in favor of GetWMIValue. Check it yourself:

Code: Select all

# Show CPU by Ctrl + Win + C:
SetHotkeyAction /H:C /K:W /K:C TestCPU

Func TestCPU
   UT1 = GetUptime()
   GetWMIValue CPU1 PercentProcessorTime 'SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name=0'
   UT2 = GetUptime()
   ProcessExecGetOutput CPU2 %ComSpec% '/q/c wmic path Win32_PerfFormattedData_PerfOS_Processor where Name^=0 get PercentProcessorTime|findstr [0-9]'
   MsgBox('CPU1: ' & CPU1 & ' | Elapsed time: ' & Round(UT2 - UT1) & ' ms' & auLF & _
          'CPU2: ' & CPU2 & ' | Elapsed time: ' & Round(GetUptime() - UT2) & ' ms')
EndFunc
funkymonk wrote: 2023-04-08, 17:18 UTCIt seems that GetWMIValue can only return the requested value from the first row.
What kind of first line are you talking about? How is the line number related to filtering? :?
Overquoting is evil! 👎
User avatar
funkymonk
Senior Member
Senior Member
Posts: 410
Joined: 2013-12-04, 09:56 UTC

Re: [WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *funkymonk »

Fla$her wrote: 2023-04-09, 05:34 UTC 2funkymonk
GetWMIValue appeared long before the idea to add a window title setting. I don't think anything can be accelerated here.
I don't know what other tools you are writing about. But on the example of wmic, I see the opposite picture in favor of GetWMIValue. Check it yourself:
True, with your code on my current system GetWMIValue takes ~260ms and wmic takes ~340ms.
(With other tools I just refer to various apps and scripts that I uses regularly.)

Here is why I'm asking: I find it very convenient to use autorun to
  • query some (constant) system information *once* on TC start. E.g. CPU/GPU name, etc...
    With around 10 calls to GetWMIValue this can easily take ~3s (once).
  • periodically query some (variable) system information. E.g. CPU load, mem usage, network setup, etc...
    The title bar is then updated with the constant and variable information.
    With around 10 calls to GetWMIValue this can easily take ~3s (repeatedly).
>>> I was just wondering whether GetWMIValue can be sped up to improve the update rate (to let's say 1-2s or the like in my use case).

---
Fla$her wrote: 2023-04-09, 05:34 UTC What kind of first line are you talking about? How is the line number related to filtering? :?
Your example

Code: Select all

GetWMIValue CPU1 PercentProcessorTime 'SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name=0'
GetWMIValue CPU1 PercentProcessorTime 'SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor'
is great to explain.
The 1st SELECT statement returns PercentProcessorTime for the entire CPU (Name = _Total) and all the cores (name = 0...n).
This can be shown as a table like:

Code: Select all

Name    PercentProcessorTime  
0       0                     
1       0                     
10      0                     
11      5                     
12      0                     
13      5                     
14      0                     
15      5                     
2       0                     
3       0                     
4       0                     
5       5                     
6       0                     
7       0                     
8       0                     
9       5                     
_Total  0                     
As long as you know in which Name you are interested in, you can simply filter by WHERE as in the 2nd SELECT statement.
However, for other queries you might not know a value for filtering or even need the information from several rows. Then it is very helpful to iterate over the available rows.

>>> Can this be done in autorun?

BTW: This could *implicitly* speed up the WMI queries through GetWMIValue, as one call would be sufficient (instead of 16 calls to get PercentProcessorTime for each core individually).
Post Reply