Hallo, mein bisheriges Script von Master Control für die Schule (von Andy gekürtzt)
Es soll:
-die sachen, wofür buttons & co bereits vorhanden sind
-evtl noch bildschirm von Clients übertragen
Es tut bereits:
-schön aussehen
-Sich mit clients verbinden
-Client und Rauminformationen aus ini auslesen
Master Control:
Spoiler anzeigen
#include <Array.au3>
;~ Includes
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3> ;<- Für Combolist
#include <inet.au3> ;<- zum prüfen ob PChostname die endung le hat
#include <Misc.au3> ;<- zum prüfen, ob Programm bereits läüft
;testen, ob Programm bereits läuft.Wenn ja: Hinweis darauf und beenden
If _Singleton("Skript", 1) = 0 Then
MsgBox(64, "MasterControl", "MasterControl läuft bereits", 5)
Exit
EndIf
; teste, ob Programm auf Lehrer PC ausgeführt wird. Wenn nicht: Meldung + Beenden
TCPStartup()
$hostname = _TCPIpToName(@IPAddress1)
$hostnametest = StringSplit($hostname, "-")
If $hostnametest[0] = 3 Then ;wenn im hostname 3 - vorhanden sind dann
[/autoit] [autoit][/autoit] [autoit]If $hostnametest[3] <> "le" Then
MsgBox(64, "MasterControl", "Dieses Programm darf nur auf Lehrerrechnern ausgeführt werden")
Exit
EndIf
If $hostnametest[3] <> "LE" Then
MsgBox(64, "MasterControl", "Dieses Programm darf nur auf Lehrerrechnern ausgeführt werden")
Exit
EndIf
Else ; wenn im hostname keine 2 - vorhanden sind
MsgBox(64, "MasterControl", "Dieses Programm sollte auf einem Lehrerrechner der Schule ausgeführt werden")
EndIf
TCPShutdown()
$pcsinraum = IniRead(@ScriptDir & "\einstellungen.ini","infos","pcs","0")
$raumnummer = IniRead(@ScriptDir & "\einstellungen.ini","infos","raum","0")
;~ Hier startet der GUI-Code
$Gui = GUICreate("MasterControl 1.0 BETA", 350, 320); <-- Erstelle die GUI
GUICtrlCreateLabel("Auswahl der PCs", 10, 20)
; checkboxen zum PCs auswählen
Dim $pc[21]
Dim $pcip[21]
Dim $verbindung[21]
Dim $datenpcfenster[21]
For $i = 1 To $pcsinraum
$pc[$i] = GUICtrlCreateCheckbox($i, 10 + (($i > 10) * 40), 30 + ($i - (($i > 10) * 10)) * 20)
Next
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit];copyright
GUICtrlCreateLabel("© Copyright Jonathan", 110, 295)
;Icon setzten
If FileExists(@ScriptDir & "\icon.ico") Then
GUISetIcon(@ScriptDir & "\icon.ico")
Else
MsgBox(48, "Icon fehlt", "Das Icon wurde nicht gefunden. Das Programm wird ohne das Icon weiter ausgeführt!")
EndIf
;trennlinie
GUICtrlCreatePic("linie.jpg", 100, 5, 2, 310)
$Buttonuebernehmen = GUICtrlCreateButton("Übernehmen", 5, 295, 90, 25, $WS_GROUP)
$Buttonalle = GUICtrlCreateButton("alle", 55, 265, 40, 25, $WS_GROUP)
$buttonkeinen = GUICtrlCreateButton("keinen", 5, 265, 40, 25, $WS_GROUP)
;Combolist
$combo = GUICtrlCreateCombo("", 110, 10, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Reboot|Sperren|Fenster|MsgBox")
$combobutton = GUICtrlCreateButton("wechseln", 270, 10, 65, 20, $WS_GROUP)
; --- --- --- --- Funktionenen --- --- --- ---
;Reboot
$neustart = GUICtrlCreateButton("Neustarten", 110, 100, 100, 50, $WS_GROUP)
$herunterfahren = GUICtrlCreateButton("Herunterfahren", 110, 150, 100, 50, $WS_GROUP)
$abmelden = GUICtrlCreateButton("Abmelden", 220, 100, 100, 50, $WS_GROUP)
$standby = GUICtrlCreateButton("Standby", 220, 150, 100, 50, $WS_GROUP)
GUICtrlSetState($neustart, $GUI_HIDE)
GUICtrlSetState($herunterfahren, $GUI_HIDE)
GUICtrlSetState($abmelden, $GUI_HIDE)
GUICtrlSetState($standby, $GUI_HIDE)
;MsgBox
$msgboxicon1 = GUICtrlCreateIcon("shell32.dll", 263, 110, 70)
$msgboxicon2 = GUICtrlCreateIcon("shell32.dll", 240, 170, 70)
GUICtrlSetState($msgboxicon1, $GUI_HIDE)
GUICtrlSetState($msgboxicon2, $GUI_HIDE)
$msgboxlabel1 = GUICtrlCreateLabel("1", 150, 72)
$msgboxlabel2 = GUICtrlCreateLabel("2", 210, 72)
$msgboxlabel3 = GUICtrlCreateLabel("Icon wählen:", 120, 40)
$msgboxlabel4 = GUICtrlCreateLabel("Text eingeben:", 120, 120)
GUICtrlSetState($msgboxlabel1, $GUI_HIDE)
GUICtrlSetState($msgboxlabel2, $GUI_HIDE)
GUICtrlSetState($msgboxlabel3, $GUI_HIDE)
GUICtrlSetState($msgboxlabel4, $GUI_HIDE)
$msgboxinhalt = GUICtrlCreateInput("", 112, 150, 228)
GUICtrlSetState($msgboxinhalt, $GUI_HIDE)
$iconwahl1 = GUICtrlCreateRadio("Icon1", 230, 70)
$iconwahl2 = GUICtrlCreateRadio("Icon2", 230, 90)
GUICtrlSetState($iconwahl1, $GUI_HIDE)
GUICtrlSetState($iconwahl2, $GUI_HIDE)
$msgboxsenden = GUICtrlCreateButton("Senden", 174, 200, 100, 50)
GUICtrlSetState($msgboxsenden, $GUI_HIDE)
For $i to $pcsinraum
$pcip[$i] = "10.20.55.55"
Next
;hostnames zu ips
;If $hostnametest[0] = 3 Then
ProgressOn("IP ermitteln", "Die IP's werden ermittelt")
TCPStartup()
For $i = 1 To $pcsinraum
$r = StringFormat("_%02u%", $i)
ProgressSet(5 * $i, "Rechner " & $i & " / " & $pcsinraum, "Die IP's werden ermittelt")
If Ping("wks-if" & $raumnummer & "-" & $r, 50) Then $pcip[$i] = TCPNameToIP("wks-if" & $raumnummer & "-" & $r)
Next
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]TCPShutdown()
ProgressOff()
;EndIf
;sperren
$sperreneingabe = GUICtrlCreateButton("Eingabe sperren", 110, 100, 100, 50, $WS_GROUP)
$sperrenbildschirm = GUICtrlCreateButton("Bildschirm sperren", 110, 150, 100, 50, $WS_GROUP)
$entsperreneingabe = GUICtrlCreateButton("Eingabe freigeben", 220, 100, 100, 50, $WS_GROUP)
$entsperrenbildschirm = GUICtrlCreateButton("Bildschirm freigeben", 220, 150, 100, 50, $WS_GROUP)
GUICtrlSetState($sperreneingabe, $GUI_HIDE)
GUICtrlSetState($sperrenbildschirm, $GUI_HIDE)
GUICtrlSetState($entsperreneingabe, $GUI_HIDE)
GUICtrlSetState($entsperrenbildschirm, $GUI_HIDE)
; Fenster
[/autoit] [autoit][/autoit] [autoit]$aktualisieren = GUICtrlCreateButton("Aktualisieren", 110, 35, 230, 20, $WS_GROUP)
GUICtrlSetState($aktualisieren, $GUI_HIDE)
; --- --- --- ---Ende Funktionen --- --- --- ---
[/autoit] [autoit][/autoit] [autoit];starticon
$starticon = GUICtrlCreateIcon("shell32.dll", 19, 200, 150);starticon
GUISetState($starticon, $GUI_HIDE)
UDPStartup()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1 ; <-- Endlosschleife anfangen
[/autoit] [autoit][/autoit] [autoit]$nMsg = GUIGetMsg(); <-- Fange die Button-Events ab
Switch $nMsg ;<-- Unterscheide die Events
Case $GUI_EVENT_CLOSE ; <-- Wenn GUI geschlossen wird dann
UDPShutdown()
Exit ; <-- Skript beenden
;;;;; reboot ;;;;;
Case $neustart
Case $herunterfahren
case $standby
Case $abmelden
Case $Buttonuebernehmen
ProgressOn("Bitte warten...", "Verbindungen werden hergestellt")
For $i = 1 To $pcsinraum
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($pc[$i]) = $GUI_CHECKED Then
If Ping($pcip[$i]) Then
$verbindung[$i] = UDPBind($pcip[$i], 2000)
Else
ToolTip("PC " & $i & " ist nicht erreichbar")
sleep(1000)
GUICtrlSetState($pc[$i], $GUI_UNCHECKED)
EndIf
EndIf
ProgressSet(5 * $i, $i & "/" & $pcsinraum)
sleep(200)
Next
ToolTip("")
ProgressOff()
Case $Buttonalle
For $i = 1 To $pcsinraum
GUICtrlSetState($pc[$i], $GUI_CHECKED)
Next
Case $buttonkeinen
For $i = 1 To $pcsinraum
GUICtrlSetState($pc[$i], $GUI_UNCHECKED)
Next
Case $combobutton
If GUICtrlRead($combo) = "Reboot" Then
GUICtrlSetState($neustart, $GUI_SHOW)
GUICtrlSetState($herunterfahren, $GUI_SHOW)
GUICtrlSetState($abmelden, $GUI_SHOW)
GUICtrlSetState($standby, $GUI_SHOW)
Else
GUICtrlSetState($neustart, $GUI_HIDE)
GUICtrlSetState($herunterfahren, $GUI_HIDE)
GUICtrlSetState($abmelden, $GUI_HIDE)
GUICtrlSetState($standby, $GUI_HIDE)
EndIf
If GUICtrlRead($combo) = "" Then
GUICtrlSetState($starticon, $GUI_SHOW)
Else
GUICtrlSetState($starticon, $GUI_HIDE)
EndIf
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($combo) = "MsgBox" Then
GUICtrlSetState($msgboxicon1, $GUI_SHOW)
GUICtrlSetState($msgboxicon2, $GUI_SHOW)
GUICtrlSetState($msgboxlabel1, $GUI_SHOW)
GUICtrlSetState($msgboxlabel2, $GUI_SHOW)
GUICtrlSetState($iconwahl1, $GUI_SHOW)
GUICtrlSetState($iconwahl2, $GUI_SHOW)
GUICtrlSetState($msgboxlabel3, $GUI_SHOW)
GUICtrlSetState($msgboxlabel4, $GUI_SHOW)
GUICtrlSetState($msgboxinhalt, $GUI_SHOW)
GUICtrlSetState($msgboxsenden, $GUI_SHOW)
Else
GUICtrlSetState($msgboxicon1, $GUI_HIDE)
GUICtrlSetState($msgboxicon2, $GUI_HIDE)
GUICtrlSetState($msgboxlabel1, $GUI_HIDE)
GUICtrlSetState($msgboxlabel2, $GUI_HIDE)
GUICtrlSetState($iconwahl1, $GUI_HIDE)
GUICtrlSetState($iconwahl2, $GUI_HIDE)
GUICtrlSetState($msgboxlabel3, $GUI_HIDE)
GUICtrlSetState($msgboxlabel4, $GUI_HIDE)
GUICtrlSetState($msgboxinhalt, $GUI_HIDE)
GUICtrlSetState($msgboxsenden, $GUI_HIDE)
EndIf
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($combo) = "Sperren" Then
GUICtrlSetState($sperreneingabe, $GUI_SHOW)
GUICtrlSetState($sperrenbildschirm, $GUI_SHOW)
GUICtrlSetState($entsperreneingabe, $GUI_SHOW)
GUICtrlSetState($entsperrenbildschirm, $GUI_SHOW)
Else
GUICtrlSetState($sperreneingabe, $GUI_HIDE)
GUICtrlSetState($sperrenbildschirm, $GUI_HIDE)
GUICtrlSetState($entsperreneingabe, $GUI_HIDE)
GUICtrlSetState($entsperrenbildschirm, $GUI_HIDE)
EndIf
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($combo) = "Fenster" Then
GUICtrlSetState($aktualisieren, $GUI_SHOW)
Else
GUICtrlSetState($aktualisieren, $GUI_HIDE)
EndIf
[/autoit] [autoit][/autoit] [autoit]Case $aktualisieren
$standartheight = 50
ProgressOn("Bitte warten...", "Infos werden abgerufen")
For $i = 1 To $pcsinraum
If Ping($pcip[$i]) Then
If GUICtrlRead($pc[$i]) = $GUI_CHECKED Then
UDPSend($verbindung[$i], "fensteranfrage")
While 1
$datenpcfenster[$i] = UDPRecv($verbindung[$i], 50000)
If $datenpcfenster[$i] <> "" Then ExitLoop
ToolTip("warte auf PC " & $i)
WEnd
ToolTip("")
$pcfenster1 = StringSplit($datenpcfenster[$i], "%")
For $x = 2 To $pcfenster1[0]
GUICtrlCreateLabel($pcfenster1, 110, $standartheight)
$standartheight += 10
Next
EndIf
EndIf
ProgressSet(5 * $i, "")
Next
ProgressOff()
[/autoit] [autoit][/autoit] [autoit]EndSwitch
[/autoit] [autoit][/autoit] [autoit]WEnd ; <-- Beginne Schleife von Vorne;### Tidy Error -> while is never closed in your script.
[/autoit] [autoit][/autoit] [autoit][/autoit]
Client:
Spoiler anzeigen
;feststellen des Scriptpfadt
$scriptpfad = @ScriptDir & "\" & @ScriptName
;setzen der Testvariable
$regtest = 0
; überprüfen ob Schlüssel besteht und gegebenenfalls schreiben
RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","MasterControl")
if not @error then $regtest = 1
if $regtest = 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","MasterControl","REG_SZ",$scriptpfad)
if @error Then MsgBox(48,"Fehler","Felher beim Schreiben in die Regitery")
;TCP und UDP Starten
UDPStartup
;Schleife um auf befehle zu warten
while 1
Sleep(10)
$befehl = UDPRecv(@ipadress1,1000)
WEnd
vllt. kann ja irgendjemand mit langeweile es Fertig machen^^