topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 13, 2024, 3:10 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: FastShutdown  (Read 12442 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
FastShutdown
« on: April 26, 2009, 12:17 PM »
;-- Fast Shutdown -- by Nod5
;-- v090426
;-- does a onestep windows shutdown unless there are scheduled tasks later the same day
;-- default hotkeys: (middle click on Start button) OR (Right Shift + Escape)
fast.png
A quick script for Win XP that I needed myself. ahk & exe in attached zip. I'll package it nicer later.

b48b1bb31a479ac4a3467f5f9297c77f *FastShutdown.ahk
e388781005816e81f7e4d92086a9d2e6 *FastShutdown.exe

;-- Fast Shutdown -- by Nod5
;-- v090426
;-- does a onestep windows shutdown unless there are scheduled tasks later the same day
;-- default hotkeys: (middle click on Start button) OR (Right Shift + Escape)

#singleinstance, force
~Mbutton::

MouseGetPos,,,xxid, xxcontr
WinGetClass, xxstart, ahk_id %xxid%
if xxstart = Shell_TrayWnd ;-- if mouse over start button
 if xxcontr = Button1
   goto fastshutdown
return

RShift & Esc::
fastshutdown:
xout =
xvar =
x = %A_Temp%\%A_now%.txt
RunWait %comspec% /c "schtasks > "%x%"",,Hide
FileRead, xvar, %x%
FileDelete, %x%
Loop, Parse, xvar, `n, `r
{
if A_LoopField contains %A_YYYY%-%A_MM%-%A_DD%
 xout = %xout%`n%A_Loopfield%
}
if xout !=
{
MsgBox, 1, Fast Shutdown, %xout%`n`nReally shutdown?
IfMsgBox, OK
 Shutdown, 1
}
else
{
MsgBox, 1, Fast Shutdown, Shutdown in 5 seconds...,5
IfMsgBox, OK
 Shutdown, 1
IfMsgbox, Timeout
 Shutdown, 1
}
return
« Last Edit: April 26, 2009, 12:19 PM by Nod5 »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: FastShutdown
« Reply #1 on: April 27, 2009, 12:35 PM »
FastShutdown uses the "schtasks" command to output a list of scheduled tasks and then searches for the current date in it. Can someone with english XP installed please check if you have the save date format as my non-english install i.e. YYYY-MM-DD. Just do this: run > cmd > schtasks    and the list will show itself.  :Thmbsup:

rgdot

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2,193
    • View Profile
    • Donate to Member
Re: FastShutdown
« Reply #2 on: April 27, 2009, 01:13 PM »
English (Canada)

TaskName                             Next Run Time
==================================== =====================
Ad-Aware Update (Weekly)             18:23:00, 27/04/2009

pencoe

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 21
    • View Profile
    • Donate to Member
Re: FastShutdown
« Reply #3 on: May 06, 2009, 01:18 AM »
German XP SP2(! SP3 will not install on this machine, time to change...  ;) ):

Taskname                             Nächste Ausführungszeit
==================================== ========================
SampleTask              09:15:00, 06.05.2009

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: FastShutdown
« Reply #4 on: May 06, 2009, 11:15 AM »
Ok, so I need to query the local date format from within the AHK script. I'll try to sort it out tonight.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: FastShutdown
« Reply #5 on: May 10, 2009, 04:29 AM »
Found a relevant registry entry:
[HKEY_USERS\.DEFAULT\Control Panel\International]
"sShortDate"="yyyy-MM-dd"

So for a complete solution I need to add:
1. code to read that on the local computer:
RegRead, dateformat, HKEY_USERS, .DEFAULT\Control Panel\International, sShortDate
2. modify the script based on the format there. There might be a lot of different such formats so it is hard to cover them all.

Here's a non-complete quick fix that at least might satisfy Canadians, Swedes and Germans (as a rule, world domination is best achieved incrementally ;D )
But sometimes, just sometimes, it can be had straight away, muaHAHAHAHA  :P :

;-- Fast Shutdown -- by Nod5
;-- v090510b
;-- does a onestep windows shutdown unless there are scheduled tasks later the same day
;-- default hotkeys: (middle click on Start button) OR (Right Shift + Escape)

#singleinstance, force
~Mbutton::

MouseGetPos,,,xxid, xxcontr
WinGetClass, xxstart, ahk_id %xxid%
if xxstart = Shell_TrayWnd ;-- if mouse over start button
 if xxcontr = Button1
   goto fastshutdown
return

RShift & Esc::
fastshutdown:
xout =
xvar =
x = %A_Temp%\%A_now%.txt
RunWait %comspec% /c "schtasks > "%x%"",,Hide
FileRead, xvar, %x%
FileDelete, %x%
FormatTime, today, A_Now, ShortDate
Loop, Parse, xvar, `n, `r
{
if A_LoopField contains %today%
 xout = %xout%`n%A_Loopfield%
}
if xout !=
{
MsgBox, 1, Fast Shutdown, %xout%`n`nReally shutdown?
IfMsgBox, OK
 Shutdown, 1
}
else
{
MsgBox, 1, Fast Shutdown, Shutdown in 5 seconds...,5
IfMsgBox, OK
 Shutdown, 1
IfMsgbox, Timeout
 Shutdown, 1
}
return

(FormatTime in Autohotkey had a ShortDate option)
« Last Edit: May 10, 2009, 04:43 AM by Nod5 »