I have good news. Among the many useful novelties (see history), Autorun implements the WMIQuery object, with which you can get data from a collection on request (example in the help), which is significantly faster for the second and subsequent elements than using GetWMIValue.
Both functions now have the ability to specify a namespace, get the items count, and select an item by index.
The functions I requested for fast and resource-saving receipt of various information for threading operations are also implemented.
Try an analog of the above example with localization of dynamically output data:
Code: Select all
LoadLibrary Plugins\Autorun_Tweaks.dll
LoadLibrary Plugins\Autorun_Sysinfo.dll
LoadLibrary Plugins\Autorun_Runtime.dll
###################################### HOTKEYS ######################################
# Ctrl+Shift+R — restart script
SetHotkeyAction /H:R /K:C /K:S RestartScript
# Shift+F11 — show/hide header with updated stats by starting and stopping the thread
SetHotkeyAction /H:F11 /K:S ToggleCaption
#####################################################################################
Global Units, sUnit, WS_CAPTION = 0x00C00000
If Not AUTORUN_RESTARTCOUNT Then SetEnv('Title', WinGetText())
If AUTORUN_TCLANG = 'eng' Then
sUnit = ' kB/s'
Else
Units = StrFormat('LU:%s,%s,%s,%s,%s', LngRead(1450, _
COMMANDER_PATH & '\Language\' & IniRead('~/R', _
COMMANDER_INI, 'Configuration', 'LanguageIni')), _
LngRead(1451), LngRead(1452), LngRead(1453), LngRead(1449))
EndIf
If WinHasStyle(WS_CAPTION) Then RunThread AutoUpdateHeaderStats
Func ToggleCaption
WinSetStyle(WS_CAPTION, 8)
WinRedraw
If WinHasStyle(WS_CAPTION) Then RunThread AutoUpdateHeaderStats
EndFunc
Func AutoUpdateHeaderStats
Local RSpeed, NSpeed
While 1
If Not WinHasStyle(WS_CAPTION) Then Return
GetNetSpeed RSpeed NSpeed
WinSetText(Title & ' | ' & Date('d MMMM') & ' ' & Time() & ' | Free system drive space: ' & _
SizeFormat(GetDriveSpace(SystemDrive, 2), 1, 'G', 2, '', Units) & ' | RAM: ' & GetMemstats() & _
'% | CPU: ' & GetCPUUsage() & '% | Net in: ' & RSpeed & ' | Net out: ' & NSpeed)
Sleep 1000
Wend
EndFunc
Func GetNetSpeed(ByRef RSpeed, ByRef NSpeed)
Static ITF_Id = GetNetInterface()
If ITF_Id = -1 Then Return
Static nPrevRecv = GetNetInterfaceInfo(ITF_Id, 'Recv'), nPrevSend = GetNetInterfaceInfo(ITF_Id, 'Sent')
Local nRecv = GetNetInterfaceInfo(ITF_Id, 'Recv'), nSend = GetNetInterfaceInfo(ITF_Id, 'Sent')
RSpeed = SizeFormat(nRecv - nPrevRecv, 0, '', 2, 0) & sUnit
NSpeed = SizeFormat(nSend - nPrevSend, 0, '', 2, 0) & sUnit
nPrevRecv = nRecv
nPrevSend = nSend
EndFunc
With the script restart hotkey, you can test changes and additions without having to restart TC and apply cm_UnloadPlugins, which may cause a hang (not due to Autorun).
In this case, the AUTORUN_RESTARTCOUNT counter serves as an auxiliary variable for this. In the example, it is used for the Title environment variable.
cm_UnloadPlugins should no longer cause TC crashes when threads are running. Check it out.funkymonk wrote: 2023-04-27, 10:18 UTC As long as this thread (and *only* this one) runs, TC crashes when cm_UnloadPlugins is called.
Download Autorun 2.2.13 beta