AHK Rainmeter ErsatzfunktionenDRIVEMETER v0.1
Das ist ein kleines Tool, welches die Laufwerke am Desktop als Progress-Bar (dessen Speicherbelegung) anzeigt. Jedes neu hinzugekommene Laufwerk wird auch angezeigt, die GUI automatisch aktualisiert.
Angegeben MÜSSEN werden
- DriveTyp (Siehe DriveGet, List)
- ExcludeList (Laufwerksbuchstaben die Ausgenommen werden sollen (z.b. A, B))
Angegeben werden KÖNNEN:
- Skalierung
- Weite der GUI/Progressbars
- Position X und Y
- Textfarbe
- Used-Space Farbe
- Free-Space Farbe
- Zeilenhöhe
- Farbe die Für die Transparenz verwendet werden soll
Fonthöhe berechnet sich automatisch durch die Skalierung.
- Code: Select all
; _drivemeter
; Coded by Obi-Wahn
;
#NoTrayIcon
#Singleinstance, Force
SetTitleMatchMode, 3
Typ = FIXED|REMOVABLE ; Art der Laufwerke die angezeigt werden sollen
Exc = AB ; Laufwerksbuchstaben die Ausgeschlossen werden sollen
Scale = 1 ; Skalierfaktor
GoSub, Actualize_GUI
SetTimer, Actualize, 1000
SetTimer, Actualize_GUI, 1000
#n::ExitApp ; [Win + n] als Hotkey zum Beenden (Während des Codens)
Return
Actualize:
Gui, 2:Default
D := _GetDriveList(Typ, Exc)
Loop, Parse, D
_ActualizeDrive(A_LoopField)
Return
Actualize_GUI:
Gui, 2:Default
C1 := _GetDriveList(Typ, Exc)
If C1 != %C2%
_DriveMeter(Typ, Exc, Scale)
C2 := _GetDriveList(Typ, Exc)
Return
_DriveMeter(Type, Exclude, Scale = 1, PosX = "Left", PosY = "Down", FontC = "White", BackC = "White"
, ForeC = "Maroon", GenW = 150, RowH = 15, GuiC = "Black") {
global
local Cap, Nam, FreeSpace, Used, Per, FSize, WS, HS, X, Y, GenH, Drives
Gui, Destroy
Gui, Color, %GuiC%
Gui, -Border -Caption +LastFound +ToolWindow
WinSet, TransColor, %GuiC%
Gui, Margin, 0, 0
Drives := _GetDriveList(Type, Exclude)
Loop, Parse, Drives
{
DriveGet, Cap, Capacity, %A_LoopField%:\
DriveGet, Nam, Label, %A_LoopField%:\
DriveSpaceFree, FreeSpace, %A_LoopField%:\
Used := (Cap - FreeSpace), Per := Round((Used / (Cap / 100)), 1), FSize := 8 * Scale
WS := GenW * Scale, HS := RowH * Scale
Gui, Font, s%FSize% w600,
Gui, Add, Text, w%WS% h%HS% c%FontC% , [%Nam%] - %A_LoopField%:\
Gui, Add, Progress, yp+%HS% w%WS% h%HS% c%ForeC% Background%BackC% Range0-%Cap% vProgress_%A_LoopField% , %Used%
Gui, Add, Text, w%WS% h%HS% c%FontC% vCap_%A_LoopField% , %Per%`% belegt - %FreeSpace% MB frei ; %
GenH += (3 * HS) + 5
}
X := PosX="Left" ? 0 : (A_ScreenWidth - GenW), Y := PosY="Top" ? 0 : (A_ScreenHeight - GenH)
Gui, Show, x%X% y%Y% NoActivate, DriveMeter
WinSet, Bottom, , DriveMeter ahk_class AutoHotkeyGUI
WinSet, Disable, , DriveMeter ahk_class AutoHotkeyGUI
}
_ActualizeDrive(Drive) {
DriveGet, Cap, Capacity, %Drive%:\
DriveSpaceFree, FreeSpace, %Drive%:\
Used := (Cap - FreeSpace)
Per := Round((Used / (Cap / 100)), 1)
GuiControl, , Progress_%Drive%, %Used%
GuiControl, , Cap_%Drive%, %Per%`% belegt - %FreeSpace% MB frei ; %
}
_GetDriveList(Types, Excludes) {
Loop, Parse, Types, |
{
DriveGet, T, List, %A_LoopField%
List = %List%%T%
}
Loop, Parse, Excludes
StringReplace, List, List, %A_LoopField%,
Sort, List, D
Return, %List%
}
############################################
BATTERYSTATUS v0.1.2
Zwei Funktionen. Die eine erstellt die GUI, die andere aktualisiert sie.
Angegeben muss nichts, es kann aber folgendes angegeben werden:
- Skalierung
- Position (X/Y)
- Breite
- Zeilenhöhe
- Fontfarbe
- Hintergrundfarbe
- Vordergrundfarbe
- Transparenzfarbe
*** Changelog ***
Entfernt: GUI-ID (Bei Multiblen GUIs)
Grund: Bei multiplen GUI's: "Gui, 1:Default" verwenden. Is einfacher zu handeln bei erweiterungen
Entfernt: Zweite Funktion (Aktualisieren)
Grund: In Hauptfunktion integriert
- Code: Select all
; batterystatus.ahk
; Coded by Obi-Wahn
;
#NoTrayIcon
SetTimer, BatteryStatus, 1000
#n::ExitApp
Return
BatteryStatus:
Gui, 10:Default
_BatteryStatus()
Return
_BatteryStatus(Scale = 1, PosX = "Left", PosY = "Dowm", FontC = "White", BackC = "White"
, ForeC = "Maroon", GenW = 150, RowH = 15, GuiC = "Black") {
global Progr, Tex
If !WinExist("BatteryStatus ahk_class AutoHotkeyGUI") {
Gui, Destroy
Gui, Color, %GuiC%
Gui, -Border -Caption +LastFound +ToolWindow
WinSet, TransColor, %GuiC%
Gui, Margin, 0, 0
FSize := 8 * Scale, WS := GenW * Scale, HS := RowH * Scale
Gui, Font, s%FSize% w600,
Gui, Add, Text, w%WS% h%HS% c%FontC% vTex,
Gui, Add, Progress, yp+%HS% w%WS% h%HS% c%ForeC% Background%BackC% Range0-100 vProgr, 0
GenH += (2 * HS) + 5
X := PosX="Left" ? 0 : (A_ScreenWidth - GenW), Y := PosY="Top" ? 0 : (A_ScreenHeight - GenH)
Gui, Show, x%X% y%Y% NoActivate, BatteryStatus
WinSet, Bottom, , BatteryStatus ahk_class AutoHotkeyGUI
WinSet, Disable, , BatteryStatus ahk_class AutoHotkeyGUI
} Else {
VarSetCapacity(powerstatus, 1+1+1+1+4+4)
DllCall("kernel32.dll\GetSystemPowerStatus", "uint", &powerstatus)
Loop, 2 {
IfEqual, A_Index, 1, SetEnv, p_offset, 0
Else, SetEnv, p_offset, 2
value := 0, old_FormatInteger := A_FormatInteger
SetFormat, integer, dec
Loop, 1
value := value+( *( ( &powerstatus+p_offset )+( A_Index-1 ) ) << ( 8* ( A_Index-1 ) ) )
SetFormat, integer, %old_FormatInteger%
V%A_Index% = %value%
}
T := (V1<1 ? "Batteriebetrieb" : "Netzbetrieb") . " [" . V2 . "%]"
GuiControl, , Tex, %T%
GuiControl, , Progr, %V2%
}
}
############################################
ONLINESTATUS v0.1.1
Aus einer GUI und zwei funktionen hab ich eine Funktion zusammengeschraubt.
Angegeben werden muss wieder nichts, aber es kann angegeben werden:
- X-Pos
- Y-Pos
- Fontfarbe Online
- Fontfarbe Offline
- GuiColor
*** CHANGELOG ***
Geändert: If-Abfrage beim GuiControl-Part entfernt
Grund: Weniger code dank Ternary operator
- Code: Select all
; _onlinestatus.ahk
; Coded by Obi-Wahn
;
SetTitleMatchMode, 3
#persistent
SetTimer, Stat, 2000
#n::ExitApp
Return
Stat:
Gui, 1:Default
_OnlineStatus()
Return
_OnlineStatus(PosX = "Right", PosY = "Down", FontC_On = "Lime", FontC_Off = "Red", GuiC = "Black") {
global MyText
S := (DllCall("Wininet.dll\InternetGetConnectedState", "Str", 0x40, "Int", 0)=1) ? "ONLINE" : "OFFLINE"
If !WinExist("Online Status ahk_class AutoHotkeyGUI") {
Gui, Margin, 0,0
Gui, +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, %GuiC%
Gui, Font, s16
Gui, Add, Text, vMyText w85 h27 c%FontC_On%, %S%
WinSet, TransColor, %GuiC%
X := PosX="Left" ? 0 : (A_ScreenWidth - 85), Y := PosY="Top" ? 0 : (A_ScreenHeight - 27)
Gui, Show, x%X% y%Y% NoActivate, Online Status
} Else {
GuiControl, , MyText, %S%
Gui, Font, % S="ONLINE" ? "c" . FontC_On : "c" . FontC_Off
GuiControl, Font, MyText
}
}