Jump to content

Shutdown GUI - How i can create it ?


DjDiabolik
 Share

Recommended Posts

I want to make a little Shutdown commands prompt gui....... for example:

I want to restart my PC in a planned 5 minutes...... i need to execute "shutdown /t 300 /r" right ?

If it's possibly i want to make this generation of commands from a gui... like i can set the hours... minutes or seconds manually (i need also after this to convert all 3 value in a only seconds value... for example if i put 10 minutes i need to convert this value to 600 seconds) and from some checkpoint i can set if i want a complete shutdown or a restart of a lot of option from shutdown /?

 

After all i want setted i can press a button to launch this commands........ at this point it's windows say to me it's my pc has been setted to restart like if i have manually launched the shutdown commands from prompt of dos......

Link to comment
Share on other sites

Can you please post what you have tried so far?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

On 29/10/2016 at 5:06 PM, water said:

Can you please post what you have tried so far?

I have tryed to create a little gui.... a simply windows for autocreate the prompt command and launch it from it...

On 31/10/2016 at 3:41 PM, spudw2k said:
shutdown -i

not a working option for you?

mmmmmmmmm... shutdown -i ? I never tryed this........... but apparently on shutdown -i it's not possibly to set the /t or other similar value..........

 

For now boys..... in this days i'm so littly busy....... i need to obtain a skinny little gui... when i complete i post some screenshot here :)

 

 

*EDIT*

This is a little example how i want to create :):

iNymZW9.png?1

A simple gui..... whit 3 value settable......... a string whit command preview... and a button to execute it.

The execute button.. before to run it it's be need to convert the 3 value (hours, minutes and seconds) in a only seconds value (example 1 minutes it's 60 seconds) and the two checkpoint if i want to set a shutdown or a restart of my pc........

Very simply gui.......

 

 

 

 

*EDIT after about 30 minutes of code*

i have obtained this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)
$Input2 = GUICtrlCreateInput("0", 56, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownOre = GUICtrlCreateUpdown($Input2)
$Input3 = GUICtrlCreateInput("0", 208, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownMinuti = GUICtrlCreateUpdown($Input3)
GUICtrlSetLimit(-1, 59, 0)
$Input4 = GUICtrlCreateInput("0", 344, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownSecondi = GUICtrlCreateUpdown($Input4)
GUICtrlSetLimit(-1, 59, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$MainCommand = "shutdown "

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            $Opt1 = "/r "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            $Opt1 = "/s "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 )
        Case $Esegui
        Case $UpdownOre
        Case $UpdownMinuti
        Case $UpdownSecondi
        
$Input1 = shutdown + $Opt1
    EndSwitch
WEnd

 

I need to continue to work..... i need also to edit the input1 for /t value.....

Every help as been accepted or suggestion......

Edited by DjDiabolik
Link to comment
Share on other sites

Apparently the works it's complete............. i have my "first" GUI:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)
$Input2 = GUICtrlCreateInput("0", 56, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownOre = GUICtrlCreateUpdown($Input2)
$Input3 = GUICtrlCreateInput("0", 208, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownMinuti = GUICtrlCreateUpdown($Input3)
GUICtrlSetLimit(-1, 59, 0)
$Input4 = GUICtrlCreateInput("0", 344, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownSecondi = GUICtrlCreateUpdown($Input4)
GUICtrlSetLimit(-1, 59, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$MainCommand = "shutdown "
$Opt1 = "/r "
$Opt2 = ""
$OreInSecondi = 0
$MinutiInSecondi = 0
$Secondi = 0
$TotaleSecondi = 0
GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            $Opt1 = "/r "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            $Opt1 = "/s "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Esegui
            $Comando = $MainCommand & $Opt1 & $Opt2
            Run ($Comando)
        Case $UpdownOre
            $OreInSecondi = GuiCtrlRead ($Input2) * 3600
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            if $TotaleSecondi = 0 then
                $Opt2 = ""
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $UpdownMinuti
            $MinutiInSecondi = GuiCtrlRead ($Input3) * 60
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            if $TotaleSecondi = 0 then
                $Opt2 = ""
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $UpdownSecondi
            $Secondi = GuiCtrlRead ($Input4)
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            if $TotaleSecondi = 0 then
                $Opt2 = ""
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )            
    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • 2 weeks later...

An update................finally a full working (but i thinks no perfect) GUI!!

I have also obtain already a 2.0 :

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI 2.0", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)
$Input2 = GUICtrlCreateInput("0", 56, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownOre = GUICtrlCreateUpdown($Input2)
$Input3 = GUICtrlCreateInput("1", 208, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownMinuti = GUICtrlCreateUpdown($Input3)
GUICtrlSetLimit(-1, 59, 0)
$Input4 = GUICtrlCreateInput("0", 344, 48, 73, 54)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
$UpdownSecondi = GUICtrlCreateUpdown($Input4)
GUICtrlSetLimit(-1, 59, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run ("shutdown /a")
$MainCommand = "shutdown "
$Opt1 = "/r "
$OreInSecondi = GuiCtrlRead ($Input2)
$MinutiInSecondi = GuiCtrlRead ($Input3)
$Secondi = GuiCtrlRead ($Input4)
$TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
$Opt2 = "/t " & $TotaleSecondi
GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            $Opt1 = "/r "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            $Opt1 = "/s "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Esegui
            $Comando = $MainCommand & $Opt1 & $Opt2
            Run ($Comando)
            Exit
        Case $UpdownOre
            $OreInSecondi = GuiCtrlRead ($Input2) * 3600
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            ;if $TotaleSecondi = 0 then
            ;   $Opt2 = ""
            ;EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $UpdownMinuti
            $MinutiInSecondi = GuiCtrlRead ($Input3) * 60
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            ;if $TotaleSecondi = 0 then
            ;   $Opt2 = ""
            ;EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $UpdownSecondi
            $Secondi = GuiCtrlRead ($Input4)
            $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
            $Opt2 = "/t " & $TotaleSecondi
            ;if $TotaleSecondi = 0 then
            ;   $Opt2 = ""
            ;EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )            
    EndSwitch
WEnd

 

Link to comment
Share on other sites

A little optimization on my 2.0 stupid gui:

#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI 2.0", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21,$ES_READONLY)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)

$SetOre = GUICtrlCreateInput("0", 56, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)


$SetMinuti = GUICtrlCreateInput("1", 208, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

$SetSecondi = GUICtrlCreateInput("0", 344, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run ("shutdown /a")
Global $MainCommand = "shutdown "
Global $Opt1 = "/r "
Converti()

Global $Opt2 = "/t " & $TotaleSecondi
GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            Global $Opt1 = "/r "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            Global $Opt1 = "/s "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Esegui
            $Comando = $MainCommand & $Opt1 & $Opt2
            Run ($Comando)
            Exit
        Case $SetOre
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetMinuti
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetSecondi
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )            
    EndSwitch
WEnd

Func Converti()
    Global $OreInSecondi = GUICtrlRead ($SetOre) * 3600
    Global $MinutiInSecondi = GUICtrlRead ($SetMinuti) * 60
    Global $Secondi = GUICtrlRead ($SetSecondi)
    Global $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
EndFunc

I only want to share only for fun at this point............. i know.. i'm very noob :)

 

*Changelog*

- Now all input it's only on read and you can't modify the previes of command or the number manually but you can only use the arrow for increase or decrease value.

- The converting timers in now out on a func

 

Edited by DjDiabolik
Link to comment
Share on other sites

If for someone it's usefull.......... i have make exited from my head the 3.0:

#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

;Legge Variabili dal file .ini
Global $SettingsFile = @ScriptDir & "\ShutdownGUI_settings.ini"
ReadIniFile()


#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI 3.0", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
If $ValCheckbox = 0 then 
    GUICtrlSetState($Checkbox1, $GUI_CHECKED)
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
Else
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2, $GUI_CHECKED)
EndIf

$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21,$ES_READONLY)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)

$SetOre = GUICtrlCreateInput($ValOre, 56, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

$SetMinuti = GUICtrlCreateInput($ValMinuti, 208, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

$SetSecondi = GUICtrlCreateInput($ValSecondi, 344, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run ("shutdown /a")
Global $MainCommand = "shutdown "
Global $Opt1 = "/r "
Converti()

Global $Opt2 = "/t " & $TotaleSecondi
GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            WriteIniFile()
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            Global $ValCheckbox = 0
            Global $Opt1 = "/r "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            Global $ValCheckbox = 1
            Global $Opt1 = "/s "
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Esegui
            WriteIniFile()
            $Comando = $MainCommand & $Opt1 & $Opt2
            Run ($Comando)
            Exit
        Case $SetOre
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetMinuti
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetSecondi
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )            
    EndSwitch
WEnd

Func Converti()
    Global $OreInSecondi = GUICtrlRead ($SetOre) * 3600
    Global $MinutiInSecondi = GUICtrlRead ($SetMinuti) * 60
    Global $Secondi = GUICtrlRead ($SetSecondi)
    Global $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
EndFunc

Func ReadIniFile()
    Global $ValOre = IniRead($SettingsFile, "LastUsage", "LastOre", "0")
    Global $ValMinuti = IniRead($SettingsFile, "LastUsage", "LastMinuti", "1")
    Global $ValSecondi = IniRead($SettingsFile, "LastUsage", "LastSecondi", "0")
    Global $ValCheckbox = IniRead($SettingsFile, "LastUsage", "LastCheckbox", "0")
EndFunc

Func WriteIniFile()
    IniWrite($SettingsFile, "LastUsage", "LastOre", GUICtrlRead ($SetOre))
    IniWrite($SettingsFile, "LastUsage", "LastMinuti", GUICtrlRead ($SetMinuti))
    IniWrite($SettingsFile, "LastUsage", "LastSecondi", GUICtrlRead ($SetSecondi))
    IniWrite($SettingsFile, "LastUsage", "LastCheckbox", $ValCheckbox)
EndFunc

Now every time you launch the command or close the gui all value has been stored in a file .ini in same folder where's the .au3 or the .exe..... usefull it's you don't want every time reset last value from beginning and for remember last value you use.

On next 4.0 i have an idea:

Make a "Shutdown /a" running and executed only if there's a real plannet reboot/shutdown present.... i don't know of i can do to obtain this for this moment, i need to study how it's placed the planned reboot in windows...

Link to comment
Share on other sites

  • 3 weeks later...

one or two fixed bug related /s or /r option every run the app............... and a newest option in this 3.2. Now the /f option it's used (force the close of runnig app) when /t it's setted to 0!

All Right in this 3.2:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=exit.ico
#AutoIt3Wrapper_Outfile_x64=ShutdownGUI x64 3.2.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

;Legge Variabili dal file .ini
Global $SettingsFile = @ScriptDir & "\ShutdownGUI_settings.ini"
ReadIniFile()


#Region ### START Koda GUI section ### Form=D:\AutoIT\Miei Progetti\Shutdown GUI\ShutdownGUI.kxf
$Main = GUICreate("Shutdown GUI 3.2", 508, 205, 192, 124)
$Label1 = GUICtrlCreateLabel("Ore", 72, 24, 21, 17)
$Label2 = GUICtrlCreateLabel("Minuti", 208, 24, 32, 17)
$Label3 = GUICtrlCreateLabel("Secondi", 344, 24, 43, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Riavvia PC", 64, 112, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Spegni PC", 168, 112, 97, 17)
If $ValCheckbox = 0 then 
    GUICtrlSetState($Checkbox1, $GUI_CHECKED)
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    Global $Opt1 = "/r "
Else
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2, $GUI_CHECKED)
    Global $Opt1 = "/s "
EndIf

$Input1 = GUICtrlCreateInput("", 8, 168, 361, 21,$ES_READONLY)
$Label4 = GUICtrlCreateLabel("Preview Comando:", 8, 144, 93, 17)
$Esegui = GUICtrlCreateButton("Esegui", 376, 128, 113, 65)

$SetOre = GUICtrlCreateInput($ValOre, 56, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

$SetMinuti = GUICtrlCreateInput($ValMinuti, 208, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

$SetSecondi = GUICtrlCreateInput($ValSecondi, 344, 48, 73, 54, $ES_READONLY)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xE3E3E3)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 59, 0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run ("shutdown /a")
Global $MainCommand = "shutdown "
;Global $Opt1 = "/r "
Converti()

Global $Opt2 = "/t " & $TotaleSecondi
If $TotaleSecondi = 0 then
    Global $Opt2 = "/t " & $TotaleSecondi & " /f"
EndIf
GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            WriteIniFile()
            Exit

        Case $Checkbox1
            GUICtrlSetState ( $Checkbox2 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox1 , $GUI_CHECKED )
            Global $ValCheckbox = 0
            Global $Opt1 = "/r "
            If $TotaleSecondi = 0 then
                Global $Opt2 = "/t " & $TotaleSecondi & " /f"
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Checkbox2
            GUICtrlSetState ( $Checkbox1 , $GUI_UNCHECKED )
            GUICtrlSetState ( $Checkbox2 , $GUI_CHECKED )
            Global $ValCheckbox = 1
            Global $Opt1 = "/s "
            If $TotaleSecondi = 0 then
                Global $Opt2 = "/t " & $TotaleSecondi & " /f"
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $Esegui
            WriteIniFile()
            $Comando = $MainCommand & $Opt1 & $Opt2
            Run ($Comando)
            Exit
        Case $SetOre
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            If $TotaleSecondi = 0 then
                Global $Opt2 = "/t " & $TotaleSecondi & " /f"
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetMinuti
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            If $TotaleSecondi = 0 then
                Global $Opt2 = "/t " & $TotaleSecondi & " /f"
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )
        Case $SetSecondi
            Converti()
            Global $Opt2 = "/t " & $TotaleSecondi
            If $TotaleSecondi = 0 then
                Global $Opt2 = "/t " & $TotaleSecondi & " /f"
            EndIf
            GUICtrlSetData ( $Input1, $MainCommand & $Opt1 & $Opt2 )            
    EndSwitch
WEnd

Func Converti()
    Global $OreInSecondi = GUICtrlRead ($SetOre) * 3600
    Global $MinutiInSecondi = GUICtrlRead ($SetMinuti) * 60
    Global $Secondi = GUICtrlRead ($SetSecondi)
    Global $TotaleSecondi = $OreInSecondi + $MinutiInSecondi + $Secondi
EndFunc

Func ReadIniFile()
    Global $ValOre = IniRead($SettingsFile, "LastUsage", "LastOre", "0")
    Global $ValMinuti = IniRead($SettingsFile, "LastUsage", "LastMinuti", "1")
    Global $ValSecondi = IniRead($SettingsFile, "LastUsage", "LastSecondi", "0")
    Global $ValCheckbox = IniRead($SettingsFile, "LastUsage", "LastCheckbox", "0")
EndFunc

Func WriteIniFile()
    IniWrite($SettingsFile, "LastUsage", "LastOre", GUICtrlRead ($SetOre))
    IniWrite($SettingsFile, "LastUsage", "LastMinuti", GUICtrlRead ($SetMinuti))
    IniWrite($SettingsFile, "LastUsage", "LastSecondi", GUICtrlRead ($SetSecondi))
    IniWrite($SettingsFile, "LastUsage", "LastCheckbox", $ValCheckbox)
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...