Update 12.03.098 10:24
Wichtig: Script läuft nur als EXE
Pause-Funktion läuft nun richtig
Das Tool soll den PC zeitgesteuert Runterfahren/ Rebooten oder den User ausloggen. Der Zeitraum kann in Sek, Min, Std oder zu einer bestimmten Uhrzeit erfolgen. Es wird eine transparente Nachricht angezeigt, wo enthalten ist, welche Aktion ausgeführt wird, zu welcher Uhrzeit dies geschieht und wie lange es bis dahin noch dauert.
Das Fenster kann über das Tray-Menü in jede beliebige Ecke verschoben und die Transparenz bestimmt werden. Das Fenster ist standardmäßig On Top, jedoch Ressistent gegen Eingaben, was bedeutet, dass man hindurchklicken kann. Damit sollte es nicht stören.
On Top und Ressistenz können auch jeweils über das Tray-Menü ein-/ausgeschaltet werden.
Das Script kann über das Tray-Menü oder über Hotkey END(E) beendet werden, oder über PAUSE pausiert.
Zusätzlich lassen sich versteckte Einstellungen in einer Ini vornehmen, die die Standard-Einstellungen beeinflussen. Die Namen sollten selbsterklärend sein, sonst testen oder fragen
Name: SD_Settings.ini
Sektion: Settings
Schlüssel und Werte:
No_Tray: 1, 0 (default) 1 = Yes, 0 = No
Hide_Window: 1, 0 (default)
On_Top: 1 (default), 0
Resisstant: 1 (default), 0
Corner: 1 (links oben), 2 (rechts oben), 3 (rechts unten), 4 (links unten)
Transparence: 0 - 100
Zur Zeit lässt sich das Tool nur über die CMD bedienen, ich bastel aber noch ein MiniGui, was ich die Tage Online stellen werde.
EDIT:
Gui ist integriert
Alle erweiterten Einstellungen die über das Tray-Menü aufgerufen werden können, können nun auch direkt im GUI am Anfang eingestellt werden.
Man kann nun auch alle Einstellungen, die über das Tray-Menü oder Gui vorgenommen werden können, über die CMD steuern. Zu beachten ist, das Parameter 1 - 3 immer gleich und vorhanden sein müssen. dahinter können die verschieden parameter, die genutzt werden sollen, angehängt werden.
Possible Commands are...
Parameter 1:
-l = Logoff
-r = Reboot
-s = Shutdown
Parameter 2:
-s = Seconds
-m = Minutes
-h = Hours
-t = Time
Parameter 3:
0 - 9 (or a time 09:30)
Parameter 4 - n
-notray (versteckt das Tray-Icon, wird standardmäßig angezeigt)
-hide (versteckt das "Zeitfenster", wird standardmäßig angezeigt)
-notop (Fenster ist NICHT on Top, standardmäßig on Top)
-noresist (Fenster ist NICHT immun gegen Eingaben, man kann NICHT durchklicken, standardmäßig immun gegen Eingaben)
-corner 1|2|3|4 (Fenster wird in definierter Ecke angezeigt, standardmäßig 1 (links oben))
-trans 0-100 (Transparenz des Fensters in Prozent, standardmäßig 10% transparenz)
Example: sd.exe -s -m 10
Fährt den PC in 10 Min. runter.
Example: sd.exe -l -h 3 -notray -notop -trans 60 -corner 3
Loggt den User nach 3 Stunden aus. Es wird kein Tray-Symbol angezeigt, das Fenster ist NICHT On Top, Transparenz liegt bei 60% und die Anzeige erfolgt über dem Systray.WICHTIG: die Pause-Funktion hält zZ. nur die Zeitanzeige an, diese läuft aber im Hintergrund weiter. Wer eine Idee hat, wie ich das abstelle, her damit
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\Icons\sd.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <Date.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#Include <Misc.au3>
;
; Shutdown
;
; © sc4ry
[/autoit] [autoit][/autoit] [autoit]If _Singleton(@ScriptName, 1) = 0 Then Exit Msgbox(16,"Warning","An occurence is already running", 10)
$ini = @ScriptDir & "\SD_Settings.ini"
Global $handle, $NoTray, $Hide, $Trans, $Corner, $Resist, $Top, $T3, $T4, $T5, $T2_1, $T2_2, $T2_3, $T2_4, $T1_1, $T1_2, $T1_3, $T1_4, $T1_5, $T1_6, $T1_7, $T1_8, $T1_9, $T1_10, $T1_11, $H, $M, $S
Global $bHook = 1, $head, $sec, $end, $secShow
Opt("TrayOnEventMode", 1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)
$NoTray = IniRead($ini, "Settings", "No_Tray", "0")
$Corner = IniRead($ini, "Settings", "Corner", "1")
$Hide = IniRead($ini, "Settings", "Hide_Window", "0")
$Trans = IniRead($ini, "Settings", "Transparence", "10")
$Top = IniRead($ini, "Settings", "On_Top", "1")
$Resist = IniRead($ini, "Settings", "Resisstant", "1")
If $CmdLine[0] = 0 Then
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Shutdown by sc4ry", 211, 134, 600, Default)
$Group1 = GUICtrlCreateGroup("Method", 0, 0, 209, 41)
$Radio1 = GUICtrlCreateRadio("Shutdown", 11, 16, 73, 17)
GUICtrlSetState(-1, 1)
$Radio2 = GUICtrlCreateRadio("Reboot", 85, 16, 57, 17)
$Radio3 = GUICtrlCreateRadio("Logout", 146, 16, 57, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Time", 0, 42, 209, 89)
$Radio4 = GUICtrlCreateRadio("Hours", 8, 58, 65, 17)
$Radio5 = GUICtrlCreateRadio("Minutes", 8, 74, 65, 17)
GUICtrlSetState(-1, 1)
$Radio6 = GUICtrlCreateRadio("Seconds", 8, 90, 65, 17)
$Radio7 = GUICtrlCreateRadio("Time", 8, 106, 65, 17)
$Input1 = GUICtrlCreateInput("", 79, 76, 81, 21)
$Button1 = GUICtrlCreateButton(">", 195, 56, 9, 49, 0)
GUICtrlSetTip(-1, "Shows advanced Settings")
$Button2 = GUICtrlCreateButton("OK", 165, 111, 41, 17, $BS_DEFPUSHBUTTON )
GUICtrlSetState($Input1, $GUI_FOCUS)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Advanced", 171, 134, 818, Default, Default, Default, $Form1_1)
$Checkbox1 = GUICtrlCreateCheckbox("No Tray", 2, 3, 89, 17)
If $NoTray = 1 Then GUICtrlSetState(-1, 1)
$Checkbox2 = GUICtrlCreateCheckbox("Hide Window", 2, 20, 89, 17)
If $Hide = 1 Then GUICtrlSetState(-1, 1)
$Checkbox3 = GUICtrlCreateCheckbox("On Top", 2, 37, 89, 17)
If $Top = 1 Then GUICtrlSetState(-1, 1)
$Checkbox4 = GUICtrlCreateCheckbox("Resisstant", 2, 53, 89, 17)
If $Resist = 1 Then GUICtrlSetState(-1, 1)
$Label1 = GUICtrlCreateLabel("Corner", 0, 80, 67, 17)
$Label2 = GUICtrlCreateLabel("Transparence", 0, 107, 70, 17)
$Combo1 = GUICtrlCreateCombo("", 72, 77, 97, 25)
Select
Case $Corner = 1
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Left Top")
Case $Corner = 2
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Right Top")
Case $Corner = 3
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Right Bottom")
Case $Corner = 4
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Left Bottom")
Case $Corner = 5
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Left Bottom")
Case Else
GUICtrlSetData(-1, "Left Top|Right Top|Right Bottom|Left Bottom|Full Screen", "Full Screen")
EndSelect
$Combo2 = GUICtrlCreateCombo("", 72, 104, 65, 25)
GUICtrlSetData(-1, "0|10|20|30|40|50|60|70|80|90|100", $Trans)
$Label3 = GUICtrlCreateLabel("%", 148, 108, 12, 17)
GUISetState(@SW_SHOW, $Form1_1)
#EndRegion ### END Koda GUI section ###
$GUIPos = WinGetPos($Form1_1)
GUIRegisterMsg($WM_MOVE, "_MoveUrAss")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$WGS = WinGetState($Form2)
If $WGS = 5 Then
GUISetState(@SW_SHOW, $Form2)
Else
GUISetState(@SW_HIDE, $Form2)
EndIf
Case $Button2
$ValueI1 = GUICtrlRead($Input1)
If $ValueI1 = "" Then
MsgBox(16, "Error", "You have to enter some Numbers")
ContinueLoop
EndIf
$ValueR1 = GUICtrlRead($Radio1)
$ValueR2 = GUICtrlRead($Radio2)
$ValueR3 = GUICtrlRead($Radio3)
$ValueR4 = GUICtrlRead($Radio4)
$ValueR5 = GUICtrlRead($Radio5)
$ValueR6 = GUICtrlRead($Radio6)
$ValueR7 = GUICtrlRead($Radio7)
If $ValueR1 = 1 Then
$Par1 = " -s "
ElseIf $ValueR2 = 1 Then
$Par1 = " -r "
ElseIf $ValueR3 = 1 Then
$Par1 = " -l "
EndIf
If $ValueR4 = 1 Then
$Par2 = "-h "
ElseIf $ValueR5 = 1 Then
$Par2 = "-m "
ElseIf $ValueR6 = 1 Then
$Par2 = "-s "
ElseIf $ValueR7 = 1 Then
$Par2 = "-t "
EndIf
$ValueCB1 = GUICtrlRead($Checkbox1)
$ValueCB2 = GUICtrlRead($Checkbox2)
$ValueCB3 = GUICtrlRead($Checkbox3)
$ValueCB4 = GUICtrlRead($Checkbox4)
$ValueC1 = GUICtrlRead($Combo1)
$ValueC2 = GUICtrlRead($Combo2)
$Par3 = " "
If $ValueCB1 = 1 Then $Par3 = $Par3 & "-notray "
If $ValueCB2 = 1 Then $Par3 = $Par3 & "-hide "
If $ValueCB3 = 0 Then $Par3 = $Par3 & "-notop "
If $ValueCB4 = 0 Then $Par3 = $Par3 & "-noresist "
If $ValueC2 <> "" Then $Par3 = $Par3 & "-trans " & $ValueC2 & " "
If $ValueC1 <> "" Then
Select
Case $ValueC1 = "Left Top"
$Par3 = $Par3 & "-corner 1"
Case $ValueC1 = "Right Top"
$Par3 = $Par3 & "-corner 2"
Case $ValueC1 = "Right Bottom"
$Par3 = $Par3 & "-corner 3"
Case $ValueC1 = "Left Bottom"
$Par3 = $Par3 & "-corner 4"
Case $ValueC1 = "Full Screen"
$Par3 = $Par3 & "-corner 5"
Case Else
$Par3 = $Par3 & "-corner 1"
EndSelect
EndIf
ShellExecute(@AutoItExe, $Par1 & $Par2 & $ValueI1 & $Par3, @ScriptDir)
Exit
EndSwitch
WEnd
EndIf
HotKeySet("!{END}", "_ToogleTray") ;show/hide Tray
HotKeySet("{End}", "_kill")
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
TraySetToolTip("ShutDown by sc4ry")
[/autoit] [autoit][/autoit] [autoit]_createTray()
[/autoit] [autoit][/autoit] [autoit]If $CmdLine[0] >= 3 Then
If $CmdLine[1] = "-l" Or $CmdLine[1] = "-s" Or $CmdLine[1] = "-r" Then
$Funktion = $CmdLine[1]
If $CmdLine[2] = "-t" Or $CmdLine[2] = "-h" Or $CmdLine[2] = "-m" Or $CmdLine[2] = "-s" Then
$TimeZone = $CmdLine[2]
If StringRegExp($CmdLine[3], "[0-9]+") Then
$Countdown = $CmdLine[3]
If _ArraySearch($CmdLine, "-notray") <> -1 Then $NoTray = 1
If _ArraySearch($CmdLine, "-hide") <> -1 Then $Hide = 1
If _ArraySearch($CmdLine, "-notop") <> -1 Then $Top = 0
If _ArraySearch($CmdLine, "-noresist") <> -1 Then $Resist = 0
$vValue = _ArraySearch($CmdLine, "-corner")
If $vValue <> -1 Then $Corner = $CmdLine[$vValue + 1]
If $Corner < 1 Then
$Corner = 1
ElseIf $Corner > 5 Then
$Corner = 4
EndIf
$vValue = _ArraySearch($CmdLine, "-trans")
If $vValue <> -1 Then $Trans = $CmdLine[$vValue + 1]
If $Trans < 0 Then
$Trans = 0
ElseIf $Trans > 100 Then
$Trans = 100
EndIf
_countDown($Countdown)
Else
_Help()
EndIf
Else
_Help()
EndIf
Else
_Help()
EndIf
Else
_Help()
EndIf
Func _MoveUrAss()
$GuiPosExt = WinGetPos($Form1_1)
If Not $GuiPosExt[0] <> $GUIPos[0] Or $GuiPosExt[1] <> $GUIPos[1] Then
WinMove($Form2, "", $GuiPosExt[0] + 217, $GuiPosExt[1])
EndIf
EndFunc ;==>_MoveUrAss
;countdown Function
Func _countDown($Countdown)
;action?
If $CmdLine[1] = "-l" Then
$head = "Logoff"
ElseIf $CmdLine[1] = "-s" Then
$head = "Shutdown"
ElseIf $CmdLine[1] = "-r" Then
$head = "Reboot"
EndIf
;countdowns
If $CmdLine[2] = "-s" Then
$ttt = _TimeToTicks(@HOUR, @MIN)
$ttt2 = _TimeToTicks(0, 0, $Countdown)
_TicksToTime($ttt + $ttt2, $H, $M, $S)
If StringLen($H) = 1 Then $H = 0 & $H
If $H >= 24 Then
Do
$H = $H - 24
Until $H <= 24
If StringLen($H) = 1 Then $H = 0 & $H
EndIf
If StringLen($M) = 1 Then $M = 0 & $M
If StringLen($S) = 1 Then $S = 0 & $S
$handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
_Do_Settings()
_FinalCountDown($Countdown, 0, 0, 0, True)
EndIf
If $CmdLine[2] = "-m" Then
$ttt = _TimeToTicks(@HOUR, @MIN)
$ttt2 = _TimeToTicks(0, $Countdown)
_TicksToTime($ttt + $ttt2, $H, $M, $S)
If StringLen($H) = 1 Then $H = 0 & $H
If $H >= 24 Then
Do
$H = $H - 24
Until $H <= 24
If StringLen($H) = 1 Then $H = 0 & $H
EndIf
If StringLen($M) = 1 Then $M = 0 & $M
If StringLen($S) = 1 Then $S = 0 & $S
$handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
_Do_Settings()
_FinalCountDown(0, $Countdown, 0, 0, True)
EndIf
If $CmdLine[2] = "-h" Then
$ttt = _TimeToTicks(@HOUR, @MIN)
$ttt2 = _TimeToTicks(0, $Countdown * 60)
_TicksToTime($ttt + $ttt2, $H, $M, $S)
If StringLen($H) = 1 Then $H = 0 & $H
If $H >= 24 Then
Do
$H = $H - 24
Until $H <= 24
If StringLen($H) = 1 Then $H = 0 & $H
EndIf
If StringLen($M) = 1 Then $M = 0 & $M
If StringLen($S) = 1 Then $S = 0 & $S
$handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
_Do_Settings()
_FinalCountDown(0, 0, $Countdown, 0, True)
EndIf
If $CmdLine[2] = "-t" Then
$ShutDownTime = $CmdLine[3]
If $ShutDownTime < @HOUR & ':' & @MIN Then
$now = @YEAR & '/' & @MON & '/' & @MDAY+1
Else
$now = @YEAR & '/' & @MON & '/' & @MDAY
EndIf
$string = StringSplit($ShutDownTime, ":")
If Not @error Then
$H = $string[1]
$M = $string[2]
Else
Exit MsgBox(16, "Error", "Wrong Format")
EndIf
$min = _DateDiff('n', _NowCalc(), $now & ' ' & $ShutDownTime )
$Countdown = $min + 1
$handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
_Do_Settings()
_FinalCountDown(0, $Countdown, 0, 0, True)
EndIf
;action
If $CmdLine[1] = "-l" Then
;~ Shutdown(4) ; Logoff und Force
SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
While 1
Sleep(1)
WEnd
ElseIf $CmdLine[1] = "-s" Then
;~ Shutdown(13) ; Shutdown, Powerdown und Force
SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
While 1
Sleep(1)
WEnd
ElseIf $CmdLine[1] = "-r" Then
;~ Shutdown(6) ; Reboot und Force
SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
While 1
Sleep(1)
WEnd
EndIf
EndFunc ;==>_countDown
Func _FinalCountDown($SEC, $MIN=0, $HOUR=0, $DAY=0, $VISIBLEDOWN=True)
$Sekunden = $SEC + $MIN*60 + $HOUR*3600 + $DAY*86400
$end = _DateAdd('s', $Sekunden, _NowCalc())
Local $message
Do
Sleep(100)
$sec = _DateDiff('s', _NowCalc(), $end)
If Not $VISIBLEDOWN Then
$secShow = $Sekunden - $sec
Else
$secShow = $sec
EndIf
Select
Case $secShow < 60
ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & StringFormat('%02u', $secShow) & ' s')
Case $secShow < 60*60
$message = StringFormat('%02u', Floor($secShow/60)) & ':' & _
StringFormat('%02u', Mod($secShow,60)) & ' min'
ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
Case $secShow < 60*60*24
$message = StringFormat('%02u', Floor($secShow/3600)) & ':' & _
StringFormat('%02u', Floor(Mod($secShow,3600)/60)) & ':' & _
StringFormat('%02u', Mod(Mod($secShow,3600),60)) & ' h'
ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
Case Else
$message = Floor($secShow/86400) & ' d / ' & _
StringFormat('%02u', Floor(Mod($secShow,86400)/3600)) & ':' & _
StringFormat('%02u', Floor(Mod(Mod($secShow,86400),3600)/60)) & ':' & _
StringFormat('%02u', Mod(Mod(Mod($secShow,86400),3600),60)) & ' h'
ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
EndSelect
$pos = WinGetPos($handle)
;~ Exit MsgBox(0, _WinIsOnTop($handle), $pos[2] & @TAB & @DesktopWidth - 2 & @CRLF & $pos[3] & @TAB & @DesktopHeight - 2)
If $pos[2] = @DesktopWidth - 2 And $pos[3] = @DesktopHeight - 2 And _WinIsOnTop($handle) Then WinSetOnTop($handle, "", 1)
Until $sec = 0
EndFunc ;==>_CountDown by BugFix ([email='bugfix@autoit.de'][/email])
Func _createTray()
$T1 = TrayCreateMenu("Transparence")
$T1_1 = TrayCreateItem("0 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_2 = TrayCreateItem("10 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_3 = TrayCreateItem("20 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_4 = TrayCreateItem("30 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_5 = TrayCreateItem("40 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_6 = TrayCreateItem("50 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_7 = TrayCreateItem("60 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_8 = TrayCreateItem("70 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_9 = TrayCreateItem("80 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_10 = TrayCreateItem("90 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T1_11 = TrayCreateItem("100 %", $T1, -1, 1)
TrayItemSetOnEvent(-1, "_Trans")
$T2 = TrayCreateMenu("Corner")
$T2_1 = TrayCreateItem("Top Left", $T2, -1, 1)
TrayItemSetOnEvent(-1, "_Corner")
$T2_2 = TrayCreateItem("Top Right", $T2, -1, 1)
TrayItemSetOnEvent(-1, "_Corner")
$T2_3 = TrayCreateItem("Bottem Right", $T2, -1, 1)
TrayItemSetOnEvent(-1, "_Corner")
$T2_4 = TrayCreateItem("Bottom Left", $T2, -1, 1)
TrayItemSetOnEvent(-1, "_Corner")
$T2_5 = TrayCreateItem("Full Screen", $T2)
TrayItemSetOnEvent(-1, "_Corner")
TrayCreateItem("")
$T3 = TrayCreateItem("Resisstant")
TrayItemSetOnEvent(-1, "_Resist")
$T4 = TrayCreateItem("On Top")
TrayItemSetState(-1, 1)
TrayItemSetOnEvent(-1, "_Top")
;~ $T5 = TrayCreateItem("Pause")
;~ TrayItemSetOnEvent(-1, "TogglePause")
TrayCreateItem("")
$T6 = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_kill")
EndFunc
Func _kill()
Exit
EndFunc ;==>_kill
Func _Do_Settings()
If $NoTray = "1" Then Opt("TrayIconHide", 1)
If $Hide = 1 Then WinSetState($handle, "", @SW_HIDE)
WinSetTrans($handle, "", (100 - $Trans) * 255 / 100)
;~ If Not $TransValue = 0 Or $TransValue = 10 Or $TransValue = 20 Or $TransValue = 30 Or $TransValue = 40 Or $TransValue = 50 Or $TransValue = 60 Or $TransValue = 70 Or $TransValue = 80 Or $TransValue = 90 Or $TransValue = 100 Then $TransValue = Round($TransValue, -1)
If $Trans <> 0 And $Trans <> 10 And $Trans <> 20 And $Trans <> 30 And $Trans <> 40 And $Trans <> 50 And $Trans <> 60 And $Trans <> 70 And $Trans <> 80 And $Trans <> 90 And $Trans <> 100 Then $Trans = Round($Trans, -1)
Select
Case $Trans = "0"
TrayItemSetState($T1_1, 1)
Case $Trans = "10"
TrayItemSetState($T1_2, 1)
Case $Trans = "20"
TrayItemSetState($T1_3, 1)
Case $Trans = "30"
TrayItemSetState($T1_4, 1)
Case $Trans = "40"
TrayItemSetState($T1_5, 1)
Case $Trans = "50"
TrayItemSetState($T1_6, 1)
Case $Trans = "60"
TrayItemSetState($T1_7, 1)
Case $Trans = "70"
TrayItemSetState($T1_8, 1)
Case $Trans = "80"
TrayItemSetState($T1_9, 1)
Case $Trans = "90"
TrayItemSetState($T1_10, 1)
Case $Trans = "100"
TrayItemSetState($T1_11, 1)
EndSelect
If $Resist = 1 Then
_Win_SetClickThrough($handle, "", True)
TrayItemSetState($T3, 1)
EndIf
If $Top = 0 Then
WinSetOnTop($handle, "", 0)
TrayItemSetState($T4, 4)
EndIf
Select
Case $Corner = 1
$x = 1
$y = 1
TrayItemSetState($T2_1, 1)
Case $Corner = 2
$x = @DesktopWidth - 132
$y = 1
TrayItemSetState($T2_2, 1)
Case $Corner = 3
$x = @DesktopWidth - 132
$y = @DesktopHeight - 80
TrayItemSetState($T2_3, 1)
Case $Corner = 4
$x = 1
$y = @DesktopHeight - 80
TrayItemSetState($T2_4, 1)
Case $Corner = 5
$x = 1
$y = 1
Case Else
$x = 1
$y = 1
TrayItemSetState($T2_1, 1)
EndSelect
If $Corner = 5 Then
WinMove($handle, "", $x, $y, @DesktopWidth - 2, @DesktopHeight - 2)
Else
WinMove($handle, "", $x, $y, 130, 50)
EndIf
EndFunc
Func _Help()
If Not _WinAPI_AttachConsole() Then
$ret = DllCall("Kernel32.dll", "long", "AllocConsole")
If $ret = 0 Then Exit
EndIf
$hConsole = _WinAPI_GetStdHandle(1)
$hConsoleIn = _WinAPI_GetStdHandle(0)
If $hConsole = -1 Then Exit
_WinAPI_WriteConsole($hConsole, @CRLF & @CRLF & 'Possible Commands are...' & @CRLF & @CRLF & 'Parameter 1:' & @CRLF & '-l = Logoff' & @CRLF & '-r = Reboot' & @CRLF & '-s = Shutdown' & @CRLF & @CRLF & 'Parameter 2:' & @CRLF & '-s = Seconds' & @CRLF & '-m = Minutes' & @CRLF & '-h = Hours' & @CRLF & '-t = Time' & @CRLF & @CRLF & 'Parameter 3:' & @CRLF & '0 - 9' & @CRLF & @CRLF & 'Example: ' & @ScriptName & ' -s -m 10' & @CRLF & @CRLF & 'This will shutdown your PC in 10 Minutes'& @CRLF & @CRLF & 'Press ENTER to Continue' & @CRLF & @CRLF)
Exit
EndFunc
Func _Resist()
$Style = _WinAPI_GetWindowLong($handle,$GWL_EXSTYLE)
If BitAND($Style,$WS_EX_TRANSPARENT) = $WS_EX_TRANSPARENT And BitAND($Style,$WS_EX_LAYERED) = $WS_EX_LAYERED Then
_Win_SetClickThrough($handle, "", False)
Else
_Win_SetClickThrough($handle, "", True)
EndIf
EndFunc
Func _Top()
WinSetOnTop($handle, "", Not _WinIsOnTop($handle))
EndFunc
Func _Corner()
Select
Case @TRAY_ID = 20
$x = 1
$y = 1
TrayItemSetState($T2_1, 1)
Case @TRAY_ID = 21
$x = @DesktopWidth - 132
$y = 1
TrayItemSetState($T2_2, 1)
Case @TRAY_ID = 22
$x = @DesktopWidth - 132
$y = @DesktopHeight - 105
TrayItemSetState($T2_3, 1)
Case @TRAY_ID = 23
$x = 1
$y = @DesktopHeight - 105
TrayItemSetState($T2_4, 1)
Case @TRAY_ID = 24
$x = 1
$y = 1
EndSelect
If @TRAY_ID = 24 Then
WinMove($handle, "", $x, $y, @DesktopWidth - 2, @DesktopHeight - 2)
Else
WinMove($handle, "", $x, $y, 130, 50)
EndIf
EndFunc
func _Trans()
Select
Case @TRAY_ID = 8
WinSetTrans($handle, "", 255)
TrayItemSetState($T1_1, 1)
Case @TRAY_ID = 9
WinSetTrans($handle, "", 90 * 255 / 100)
TrayItemSetState($T1_2, 1)
Case @TRAY_ID = 10
WinSetTrans($handle, "", 80 * 255 / 100)
TrayItemSetState($T1_3, 1)
Case @TRAY_ID = 11
WinSetTrans($handle, "", 70 * 255 / 100)
TrayItemSetState($T1_4, 1)
Case @TRAY_ID = 12
WinSetTrans($handle, "", 60 * 255 / 100)
TrayItemSetState($T1_5, 1)
Case @TRAY_ID = 13
WinSetTrans($handle, "", 50 * 255 / 100)
TrayItemSetState($T1_6, 1)
Case @TRAY_ID = 14
WinSetTrans($handle, "", 40 * 255 / 100)
TrayItemSetState($T1_7, 1)
Case @TRAY_ID = 15
WinSetTrans($handle, "", 30 * 255 / 100)
TrayItemSetState($T1_8, 1)
Case @TRAY_ID = 16
WinSetTrans($handle, "", 20 * 255 / 100)
TrayItemSetState($T1_9, 1)
Case @TRAY_ID = 17
WinSetTrans($handle, "", 10 * 255 / 100)
TrayItemSetState($T1_10, 1)
Case @TRAY_ID = 18
WinSetTrans($handle, "", 0)
TrayItemSetState($T1_11, 1)
EndSelect
EndFunc
Func _WinIsOnTop($WindowHandle)
Local $long = _WinAPI_GetWindowLong(WinGetHandle($WindowHandle),$GWL_EXSTYLE)
Return BitAND($long,8)=8 ; $WS_EX_TOPMOST = 8
EndFunc ; Author(s): Prog@ndy
Func _Win_SetClickThrough($title,$text = "",$noclic = True)
Local $hWnd = WinGetHandle($title,$text)
If @error Then Return SetError(1,0,0)
If $noclic Then
_WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitOR(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),$WS_EX_TRANSPARENT))
If @error Then Return SetError(2,0,0)
Else
_WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitAND(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),BitNOT($WS_EX_TRANSPARENT)))
If @error Then Return SetError(2,0,0)
EndIf
Return 1
EndFunc ; Author(s): Prog@ndy
Func _ToogleTray()
Opt("TrayIconHide", Not Opt("TrayIconHide", "Default"))
EndFunc
Func TogglePause()
$Paused = Not $Paused
$time = 0
While $Paused
ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", @CRLF & 'Script is "Paused"')
Sleep(1000)
$time += 1
$end = _DateAdd('s', 1, $end)
WEnd
$ttt = _TimeToTicks($H, $M)
$ttt2 = _TimeToTicks(0, 0, $time)
_TicksToTime($ttt + $ttt2, $H, $M, $S)
EndFunc ;==>TogglePause