Hallo,
ich suche die Möglichkeit, ein System runter zu fahren, wenn das Notebook in Akku Betrieb geht. Könnte mir jemand ein Script vorschlagen?
Hallo,
ich suche die Möglichkeit, ein System runter zu fahren, wenn das Notebook in Akku Betrieb geht. Könnte mir jemand ein Script vorschlagen?
https://www.autoitscript.com/autoit3/docs/l…PowerStatus.htm ist das was du brauchst.
Eine While-Schleife die alle 5 Sekunden überprüft ob das Gerät lädt und dann Shutdown() ausführt wirst du doch sicherlich selber hinkriegen.
wäre es unverschämt zu frage, wie das Script wäre?
wäre es unverschämt zu frage, wie das Script wäre?
Schau' Dir doch einfach mal das Beispielskript aus dem Link an :
http://www.autoitscript.com/autoit3/docs/l…PowerStatus.htm
Gruß Musashi
Also mehr als diese Anregung gibts nicht:
#include <WinAPISys.au3>
Local $aData = _WinAPI_GetSystemPowerStatus()
MsgBox (0, "1", $aData[0])
Gruß
Peter
dachte so...
if $aData = 0 then Shutdown(1)
und das in eine Schleife, geht aber schon ohne Schleife nicht...
if $aData = 0 then Shutdown(1)
und das in eine Schleife, geht aber schon ohne Schleife nicht...
Das wird so auch nicht funktionieren. $aData ist ein eindimensionales Array mit 5 Elementen , [0] ... [4].
Das gewünschte Element muss schon korrekt angesprochen werden.
#include <WinAPISys.au3>
Global $aData = _WinAPI_GetSystemPowerStatus()
ConsoleWrite('> Element[0] -> ' & $aData[0] & @CRLF)
ConsoleWrite('> Element[1] -> ' & $aData[1] & @CRLF)
ConsoleWrite('> Element[2] -> ' & $aData[2] & @CRLF)
ConsoleWrite('> Element[3] -> ' & $aData[3] & @CRLF)
ConsoleWrite('> Element[4] -> ' & $aData[4] & @CRLF)
Die Werte der einzelnen Elemente kannst Du der Hilfe entnehmen (siehe Link oben),
Gruß Musashi
sieht toll aus.... verstehe ich nicht.
Du bist seit 2006 hier angemeldet und verstehst Arrays nicht?
Was hast Du bisher mit AutoIt gemacht?
Wie wäre es mal mit dem lernen der Grundlagen?
ich habe bewusst inProgrammieranfragen gepostet, schade, dachte nicht, das es so schwer wird.
Hab mal paar kleine Scripte geschrieben und bin leider nur Hardware Techniker.
Es ist ein wirklich, wirklich, unverschämt kleines Script. Probier das halt mal aus und berichte:
Und das hier ist nur die sichere Variante, ohne ginge es in vier Zeilen.
#RequireAdmin
#include <WinAPISys.au3>
While Sleep(1000)
Local $aInfo = _WinAPI_GetSystemPowerStatus()
If UBound($aInfo) and Not $aInfo[0] Then ExitLoop
WEnd
Shutdown(1)
Z.B. so
#include <WinAPISys.au3>
While _WinAPI_GetSystemPowerStatus()[0] and Sleep(1000)
WEnd
Shutdown(1)
Das könnte man noch kleiner machen (drei) aber ich glaube das was ich sagen wollte ist klar geworden.
hmmm ist das ein Zeichen der Zeit?
ich habe bewusst inProgrammieranfragen gepostet, schade, dachte nicht, das es so schwer wird.
Hab mal paar kleine Scripte geschrieben und bin leider nur Hardware Techniker.
Ein Dreizeiller ist schwer? Noch dazu einer der schon fast in meiner Antwort enthalten ist? .....zzzzzzzzzz.
Wir haben hier im Forum viele NICHTINFORMATIKER trotzdem programieren diese Mitglieder tolle Sachen. Ein kleines Script zu schreiben ist ehr eine Frage des Wollens als des Könnens. Ein wenig Fleiß gehört auch dazu. Und so die Basics (LK). Wenn Du das nicht willst sags gleich und frag nach fertigen Code.
Gruß
Peter
ps.: Bevor ich es vergesse - vergiss nicht den Status auf gelöst zu setzen.
Hey Leute... jetzt bevor wieder diese Diskutiererei anfängt, mal paar Sachen und ich mag Keinen von euch angreifen:
Ein Dreizeiller ist schwer?
Nein, für UNS natürlich nicht. Was firewalldevil gemeint hat, war eher, dass er sich gefragt hat, warum es so schwer ist, hier ne Lösung zu bekommen.
Wenn Du das nicht willst sags gleich und frag nach fertigen Code.
Ja da hast einmal DU Recht und einmal firewalldevil... er hat nämlich ganz oben gleich nach dem Code gefragt und wir sind hier in der Kategorie "Programmieranfragen" und nicht "Hilfe & Unterstützung
danke NO1!
Script geht.
Danke an alpines.
closed....
Hallo firewalldevil !
Ich habe auch erst später gesehen, dass Du in 'Programmieranfragen / Ohne Gegenleistung' gepostet hast.
Somit war deine Bitte um ein fertiges Skript natürlich völlig legitim.
Das Beispiel von alpines ist, wie er selbst sagt, zwar spartanisch, aber es funktioniert und erfüllt offenbar deine Anforderungen.
Ich hätte noch eine Frage :
Warum möchtest Du den Rechner sofort herunterfahren, sobald auf Akku-Betrieb umgeschaltet wird.
Man könnte zusätzlich abfragen, ob die Akkuleistung bei mehr als 66% bzw. 33% liegt, und z.B. erst bei 'unter 33%' den Rechner herunterfahren.
Gruß Musashi
Man kann übrigens seinen Thread als "erledigt" markieren, einfach auf "Thema bearbeiten" oben rechts klicken und dann als "erledigt markieren" auswählen.