5 posts in this topic
I was looking for a way to find out how long my PC had been running a few weeks ago and had trouble finding something that satisfied my needs, I found a Visual Basic Script that worked but found it too long. But searching trough AutoIt WINAPI help found that it really was as simple as the following little script.
Local $Uptime = _WinAPI_StrFromTimeInterval(_WinAPI_GetTickCount())
MsgBox(0, '', "PC Uptime ==> " & $UpTime)
Hope it helps...
I have written a script which I want to start together with the booting operating system (Win7x64). Like proposed by wiki-FAQ (https://www.autoitscript.com/wiki/FAQ) I tried the following:
MsgBox(0,"TellMe",RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ATOSS-FavoritenManager", "REG_SZ", @ScriptFullPath)?"SUCCESS":"Error: " & @error) It worked, just like putting a link into the windows autostart directory.
Thing is, every other program in there needs some seconds to start after booting. However, my script takes 3-5 minutes for no obvious reason, with the process visible in the task-manager. I tried a a smaller Autoit.exe script and it was way faster than mine.
My script is 1.1MB in size and needs 17.6MB of RAM when running. (maybe that's the problem?)
I set up a MsgBox at the start of my script to have something simple as first visible effect, so in my opinion it's nothing in my code causing the problem (like a loop).
My includes are:
That's quite some but I need those.
Any ideas? (Here is some code, that my script starts with. Altogether it's about 3500 lines of code.)
Thanks and have a great weekend!
*Requires Win 8 or higher, unless there is someway to import the DISM module in lower versions I am unaware of.
As my last thread of powershell efforts was aimed at AD, so this one will be aimed at the DISM module available in Win 8 and above. Lets begin:
This is the DISM image info command, via powershell, returning an array.
#RequireAdmin #include <AutoItConstants.au3> #include <Array.au3> $sImagePath = 'C:\Users\username\Desktop\WIMs_2008\install.wim' $sCommands = "powershell get-WindowsImage -ImagePath " & $sImagePath $iPID = run($sCommands, "", @SW_HIDE , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOutput = stringsplit($sOutput , @CR , 2) For $i = ubound($aOutput) - 1 to 0 step - 1 If stringleft(stringstripws($aOutput[$i], 1) , 1) = "" Then _ArrayDelete($aOutput, $i) Next _ArrayDisplay($aOutput)
I'm using this startup example to allow the program menu to insert an option to "AutoStart" the script. What I'd like to do is update the checkbox of the menu item after they click it to then reflect the "AutoStart" state (on or off).
How do I update the menu on the event someone clicks the menu option? The registry is updating correctly, and if I close and re-run the script the menu is updated, but not in the same script execution. I wasn't sure with TrayItemSetState for my "Func AutoStart()" Function what the "controlID" was. I tried 0 through to 3 and "AutoStart" text. Perhaps this is where I'm going wrong?
; Add custom tray icon menu #NoTrayIcon #include <MsgBoxConstants.au3> #include <TrayConstants.au3> Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #include '_Startup.au3' TrayCreateItem("AutoStart") TrayItemSetOnEvent(-1, "AutoStart") If _StartupRegistry_Exists() Then TrayItemSetState(-1, $TRAY_CHECKED) Else TrayItemSetState(-1, $TRAY_UNCHECKED) EndIf TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "About") TraySetState($TRAY_ICONSTATE_SHOW) ; ################## ; ### OTHER CODE ### ; ################## Func About() MsgBox(0,"About","etc") EndFunc Func AutoStart() If _StartupRegistry_Exists() Then _StartupRegistry_Uninstall() TrayItemSetState("AutoStart", $TRAY_UNCHECKED) Else _StartupRegistry_Install() TrayItemSetState("AutoStart", $TRAY_CHECKED) EndIf EndFunc Func ExitScript() Exit EndFunc Thanks!
I want to switch from Windows 7 to Windows 8.1 ( x86 ) but I still want to code in AutoIt. Now I saw in the Description file that is only compatible upto Windows 7, but will it work also on 8 ? And yes Im referring to the latest Autoit version available !