Als erstes habe ich mit dem WMI-Tool Scriptomatic untersucht, anhand welcher Werte ich erkennen kann, ob mein Laser Offline ist oder nicht.
Ergebnis: Name und Attributes reichen:
Code: Alles auswählen
IncludeFile "wmi.pbi" ; http://www.purebasic.fr/german/viewtopic.php?t=2925&start=14
WMI_INIT()
WMI_Call("Select * FROM Win32_Printer", "Name, attributes")
ResetList(wmidata())
While NextElement(wmidata())
Debug wmidata() ; Alle Listenelemente darstellen / show all elements
Wend
WMI_RELEASE("OK")Code: Alles auswählen
IncludeFile "wmi.pbi" ; http://www.purebasic.fr/german/viewtopic.php?t=2925&start=14
WMI_INIT()
WMI_Call("Select * FROM Win32_Printer", "Name, attributes")
ResetList(wmidata())
While NextElement(wmidata())
If wmidata() = "Samsung SCX-4100 Series"
Debug wmidata() ;Listenelemente darstellen
NextElement(wmidata())
If wmidata() = Str(3144)
Debug "Samsung ist offline, ich schalte aus..."
;RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f","",0)
Else
Debug "Samsung ist NICHT offline"
result = MessageRequester( "Schlafmütze !!", "Der Samsung ist noch an !!"+#CRLF$+"Bitte erst ausschalten !!")
If result = #PB_MessageRequester_Yes
Debug "Ich schalte aus...."
;RunProgram("C:\Windows\System32\shutdown.exe","-s -t 0 -f","",0)
EndIf
EndIf
EndIf
Wend
WMI_RELEASE("OK")Wenn man im MessageRequester noch #MB_OKCANCEL benutzt, ist es sogar offensichtlicher, daß man den Shutdown abbrechen kann
baw... scholly