commit 0f54c4f52889966221b3e9389edcc6cec5595abf Author: Bernhard Date: Tue Sep 12 23:14:55 2017 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ae430f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tumblr_opjjpnQXfQ1use0z2o1_1280.jpg +*.back diff --git a/CalibeIcon.ico b/CalibeIcon.ico new file mode 100644 index 0000000..1f5dffb Binary files /dev/null and b/CalibeIcon.ico differ diff --git a/CalibreMultiuserStarter.au3 b/CalibreMultiuserStarter.au3 new file mode 100644 index 0000000..c2ed6be --- /dev/null +++ b/CalibreMultiuserStarter.au3 @@ -0,0 +1,186 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.15 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim Const $s_WallpaperFile = "e4a21754cc0d4b0ee446f41df2b2ed9d.jpg" +Dim Const $a_ReplaceUsername[2] = [ "Error", "Bernhard" ] +Dim Const $a_ReplaceComputername[2] = [ "ERROR-PC" , "Computer von Bernhard" ] +Dim $sUsername +Dim $sComputername +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False +Dim $b_SetWallpaper = False + +$sComputername = StringReplace(@ComputerName, $a_ReplaceComputername[0], $a_ReplaceComputername[1]) +$sUsername = StringReplace(@UserName, $a_ReplaceUsername[0], $a_ReplaceUsername[1]) + +;Setzt Hintergrundbild, siehe https://autoit.de/index.php/Thread/19060-Wallpaper-im-laufenden-Betrieb-%C3%A4ndern-inkl-auswahl-des-Styles/ +Func Wallpaper($Wallpaper, $Stile) +;Set Wallpaper +;In XP only bmp files! +;$Wallpaper = Full Path and Filename. Leave blank if no Wallpaper +;$Stile = Wallpaper Style +;Call: Wallpaper("Path\Filename.extention","Stile") +;Don't miss to include the GDIPlus.au3 (#include ) + Select + Case $Stile="Center" + $Stile="0" + $Stile2="0" + Case $Stile="Fit" + $Stile="1" + $Stile2="0" + Case $Stile="Stretch" + $Stile="2" + $Stile2="0" + Case $Stile="Fill" + $Stile="-1" + $Stile2="0" + Case $Stile="Tile" + $Stile="0" + $Stile2="1" + EndSelect + + Local $TempWallpaper = @TempDir & "\Wallpaper.bmp" + _GDIPlus_Startup() + $hBitmap = _GDIPlus_BitmapCreateFromFile($Wallpaper) ;Converts Image to Bitmap + _GDIPlus_ImageSaveToFile($hBitmap, $TempWallpaper) ;Save in temp directory + _GDIPlus_BitmapDispose($hBitmap) ;Release Bitmap Resource + _GDIPlus_Shutdown() + RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $Stile) + RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $Stile2) + RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", $TempWallpaper) + DllCall("user32.dll", "int", "SystemParametersInfo","uint",20,"uint",0,"str",$TempWallpaper,"uint",3) +EndFunc ;EndFunc Wallpaper + + +If $CmdLine[0] > 0 Then + If $CmdLine[1] = "wallpaper" Then + $b_SetWallpaper = True + EndIf +EndIf + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then ; Wenn da 7 Werte drin stehen ist es eine gültige Datei + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, $sUsername & ":" & $sComputername & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +If $b_SetWallpaper = True Then + Wallpaper(@ScriptDir & "\" & $s_WallpaperFile, "Fill") +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +;SpashImage features: Title=No, Width=602, Height=302, Always On Top +SplashImageOn("", "bittewarten.jpg","602","302","-1","-1",1) + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("calibre") = 1 Then + Sleep(2000) + SplashOff() + ;MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(1000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/CalibreMultiuserStarter.exe b/CalibreMultiuserStarter.exe new file mode 100644 index 0000000..75a9bc2 Binary files /dev/null and b/CalibreMultiuserStarter.exe differ diff --git a/Icon256-32.ico b/Icon256-32.ico new file mode 100644 index 0000000..f70f635 Binary files /dev/null and b/Icon256-32.ico differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Sonstiges/WTSAPI_ClientName.au3 b/Sonstiges/WTSAPI_ClientName.au3 new file mode 100644 index 0000000..8ef6bdc --- /dev/null +++ b/Sonstiges/WTSAPI_ClientName.au3 @@ -0,0 +1,38 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Icon256-32.ico +#AutoIt3Wrapper_Change2CUI=y +#AutoIt3Wrapper_Res_SaveSource=y +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +Opt('MustDeclareVars', 1) +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + +Func _ANSI2OEM($text) + $text = DllCall('user32.dll', 'Int', 'CharToOem', 'str', $text, 'str', '') + Return $text[2] +EndFunc ;==>_ANSI2OEM + +RegDelete("HKEY_CURRENT_USER\Environment", "WTSAPI_ClientName") + +ConsoleWrite(_ANSI2OEM("Call Wtsapi32.dll for Remote-Clientname ... ")) +$h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) +If @error Or $h_DllErgebnis[0] = 0 Then + ConsoleWrite(_ANSI2OEM("failed! (It's ok if this is a Console-Session)" & @CRLF & @CRLF)) + $s_clientname = "" +Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + ConsoleWrite(_ANSI2OEM("success! Name is " & $s_clientname & @CRLF & @CRLF)) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) +EndIf + +$s_clientname = _ANSI2OEM($s_clientname) +ConsoleWrite(_ANSI2OEM("Setting %WTSAPI_ClientName% to '" & $s_clientname & "'" & @CRLF & @CRLF)) +EnvSet("WTSAPI_ClientName", $s_clientname) +;~ RunWait(@ComSpec & "/C setx WTSAPI_ClientName " & $s_clientname) +RegWrite("HKEY_CURRENT_USER\Environment", "WTSAPI_ClientName", "REG_SZ", $s_clientname) + +;~ EnvUpdate() +;~ MsgBox(0,"Clientname", @UserName & @CRLF & "COMPUTERNAME: " & @ComputerName & @CRLF & " RDP-Client: " & $s_clientname & " - " & $s_ip) \ No newline at end of file diff --git a/Sonstiges/WTSAPI_ClientName.exe b/Sonstiges/WTSAPI_ClientName.exe new file mode 100644 index 0000000..0006e1e Binary files /dev/null and b/Sonstiges/WTSAPI_ClientName.exe differ diff --git a/Sonstiges/calibre-portable.exe b/Sonstiges/calibre-portable.exe new file mode 100644 index 0000000..01ab047 Binary files /dev/null and b/Sonstiges/calibre-portable.exe differ diff --git a/Thunderbird/ThunderbirdMultiuserStarter.au3 b/Thunderbird/ThunderbirdMultiuserStarter.au3 new file mode 100644 index 0000000..9d11a73 --- /dev/null +++ b/Thunderbird/ThunderbirdMultiuserStarter.au3 @@ -0,0 +1,79 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=thunderbird.ico +#AutoIt3Wrapper_Outfile=ThunderbirdMultiUserStarter.exe +#AutoIt3Wrapper_Outfile_x64=D:\Dropbox\Thunderbird Portable\ThunderbirdPortable.exe +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.13 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y +#AutoIt3Wrapper_Run_Tidy=y +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#Region +; **** Directives created by AutoIt3Wrapper_GUI **** +#EndRegion +; **** Directives created by AutoIt3Wrapper_GUI **** +; ThunderbirdMultiuserStarter +; 2013 von Bernhard Linz +; http://znil.net +; Bernhard@znil.net  +Dim Const $s_LockFileName = "ThunderbirdLockFile.txt" +Dim Const $s_ThunderbirdProgramName = "ThunderbirdPortable.exe" +Dim Const $s_ThunderbirdMainProgramName = "Thunderbird.exe" +Dim $h_lockfile +Dim $h_Thunderbird +Dim $b_RunThunderbird = False +Dim $a_gelockt_von +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName, 0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Thunderbird blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Thunderbird gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunThunderbird = False +Else + $h_lockfile = FileOpen($s_LockFileName, 2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunThunderbird = True +EndIf +;  +If $b_RunThunderbird = False Then + Exit 1 +EndIf +;  +$h_Thunderbird = Run(@ScriptDir & "\" & $s_ThunderbirdProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Thunderbird = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_ThunderbirdProgramName & "' nicht starten") + Exit 1 +EndIf +;  +Do + Sleep(3000) + If (ProcessExists($h_Thunderbird) = 0) And (ProcessExists($s_ThunderbirdMainProgramName) = 0) Then + $b_RunThunderbird = False + EndIf +Until $b_RunThunderbird = False +; +FileDelete($s_LockFileName) +Sleep(3000) +;  +If FileExists($s_LockFileName) = 1 Then + MsgBox(16, "Warnung", "Konnte das Thunderbird-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_ThunderbirdProgramName) + Exit 1 +Else + Exit 0 +EndIf diff --git a/V1/CalibreMultiuserStarter.au3 b/V1/CalibreMultiuserStarter.au3 new file mode 100644 index 0000000..4b77eed --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3 @@ -0,0 +1,82 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +; CalibeMultiuserStarter +; 2013 von Bernhard Linz +; http://znil.net +; Bernhard@znil.net + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.1.bak b/V1/CalibreMultiuserStarter.au3.1.bak new file mode 100644 index 0000000..4cd0314 --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.1.bak @@ -0,0 +1,77 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.2.bak b/V1/CalibreMultiuserStarter.au3.2.bak new file mode 100644 index 0000000..bb454a7 --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.2.bak @@ -0,0 +1,76 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.2 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibeProgramName = "calibre-portable.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibeProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibeProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If ProcessExists($h_Calibre) = 0 Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibeProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.3.bak b/V1/CalibreMultiuserStarter.au3.3.bak new file mode 100644 index 0000000..78a62eb --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.3.bak @@ -0,0 +1,76 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibeProgramName = "calibre-portable.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibeProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibeProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If ProcessExists($h_Calibre) = 0 Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibeProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.4.bak b/V1/CalibreMultiuserStarter.au3.4.bak new file mode 100644 index 0000000..ee40c37 --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.4.bak @@ -0,0 +1,76 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibeProgramName = "calibre-portable.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" $s_CalibeProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibeProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If ProcessExists($h_Calibre) = 0 Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibeProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.5.bak b/V1/CalibreMultiuserStarter.au3.5.bak new file mode 100644 index 0000000..6afeb64 --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.5.bak @@ -0,0 +1,71 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibeLockFile.txt" +Dim Const $s_CalibeProgramName = "calibre-portable.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run($s_CalibeProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + Exit 1 +EndIf + +Do + Sleep(3000) +Until ProcessExists($s_CalibeProgramName) = 0 + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibeProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.6.bak b/V1/CalibreMultiuserStarter.au3.6.bak new file mode 100644 index 0000000..1126b07 --- /dev/null +++ b/V1/CalibreMultiuserStarter.au3.6.bak @@ -0,0 +1,64 @@ +#NoTrayIcon + +Dim Const $s_LockFileName = "CalibeLockFile.txt" +Dim Const $s_CalibeProgramName = "calibre-portable.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run($s_CalibeProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + Exit 1 +EndIf + +Do + Sleep(3000) +Until ProcessExists($s_CalibeProgramName) = 0 + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibeProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V1/CalibreMultiuserStarter.au3.7.bak b/V1/CalibreMultiuserStarter.au3.7.bak new file mode 100644 index 0000000..e69de29 diff --git a/V1/CalibreMultiuserStarter.exe b/V1/CalibreMultiuserStarter.exe new file mode 100644 index 0000000..b624d39 Binary files /dev/null and b/V1/CalibreMultiuserStarter.exe differ diff --git a/V2/CalibreMultiuserStarterV2.au3 b/V2/CalibreMultiuserStarterV2.au3 new file mode 100644 index 0000000..a4cbbf9 --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3 @@ -0,0 +1,115 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.8 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.au3.1.bak b/V2/CalibreMultiuserStarterV2.au3.1.bak new file mode 100644 index 0000000..da9afd8 --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3.1.bak @@ -0,0 +1,116 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_UseX64=y +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.7 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.au3.2.bak b/V2/CalibreMultiuserStarterV2.au3.2.bak new file mode 100644 index 0000000..6a6cff3 --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3.2.bak @@ -0,0 +1,110 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.4 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.au3.3.bak b/V2/CalibreMultiuserStarterV2.au3.3.bak new file mode 100644 index 0000000..4dcbfdc --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3.3.bak @@ -0,0 +1,110 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.au3.4.bak b/V2/CalibreMultiuserStarterV2.au3.4.bak new file mode 100644 index 0000000..940ec1e --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3.4.bak @@ -0,0 +1,110 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON "-" @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON "-" @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.au3.5.bak b/V2/CalibreMultiuserStarterV2.au3.5.bak new file mode 100644 index 0000000..4cd0314 --- /dev/null +++ b/V2/CalibreMultiuserStarterV2.au3.5.bak @@ -0,0 +1,77 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +Do + Sleep(3000) + ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +Sleep (1000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V2/CalibreMultiuserStarterV2.exe b/V2/CalibreMultiuserStarterV2.exe new file mode 100644 index 0000000..6824132 Binary files /dev/null and b/V2/CalibreMultiuserStarterV2.exe differ diff --git a/V3/CalibreMultiuserStarterV3.au3 b/V3/CalibreMultiuserStarterV3.au3 new file mode 100644 index 0000000..61069a9 --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3 @@ -0,0 +1,127 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.13 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +;SpashImage features: Title=No, Width=602, Height=302, Always On Top +SplashImageOn("", "bittewarten.jpg","602","302","-1","-1",1) + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("calibre") = 1 Then + Sleep(2000) + SplashOff() + ;MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(1000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.1.bak b/V3/CalibreMultiuserStarterV3.au3.1.bak new file mode 100644 index 0000000..86db35c --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.1.bak @@ -0,0 +1,126 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.12 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + +;SpashImage features: Title=No, Width=602, Height=302, Always On Top +SplashImageOn("", "bittewarten.jpg","602","302","-1","-1",1) + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("calibre") = 1 Then + SplashOff() + ;MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(1000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.2.bak b/V3/CalibreMultiuserStarterV3.au3.2.bak new file mode 100644 index 0000000..b78babe --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.2.bak @@ -0,0 +1,123 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.11 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("calibre") = 1 Then + MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(1000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.3.bak b/V3/CalibreMultiuserStarterV3.au3.3.bak new file mode 100644 index 0000000..c7277b5 --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.3.bak @@ -0,0 +1,123 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.10 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("calibre") = 1 Then + MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(3000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.4.bak b/V3/CalibreMultiuserStarterV3.au3.4.bak new file mode 100644 index 0000000..75949b7 --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.4.bak @@ -0,0 +1,123 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.9 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("Calibre") = 1 Then + MsgBox(0, "Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(3000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.5.bak b/V3/CalibreMultiuserStarterV3.au3.5.bak new file mode 100644 index 0000000..a150594 --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.5.bak @@ -0,0 +1,123 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.8 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] +Dim $b_CalibreWindowsActive = False + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + + +Do + If $b_CalibreWindowsActive = False Then + If WinExists ("Calibre") = 1 Then + MsgBox("Calibre-Fenster", "Ist da!") + $b_CalibreWindowsActive = True + EndIf + EndIf + Sleep(3000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.au3.6.bak b/V3/CalibreMultiuserStarterV3.au3.6.bak new file mode 100644 index 0000000..1220d6a --- /dev/null +++ b/V3/CalibreMultiuserStarterV3.au3.6.bak @@ -0,0 +1,117 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CalibeIcon.ico +#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net +#AutoIt3Wrapper_Res_Fileversion=1.0.0.8 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_LegalCopyright=znil.net +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +Dim Const $s_LockFileName = "CalibreLockFile.txt" +Dim Const $s_CalibreProgramName = "calibre-portable.exe" +Dim Const $s_CalibreMainProgramName = "calibre.exe" +Dim $h_lockfile +Dim $h_Calibre +Dim $b_RunCalibe = False +Dim $a_gelockt_von +Dim $h_DllErgebnis +Dim $s_clientname +Dim $s_ip +Dim $a_DezimalIP[5] + + +If FileExists($s_LockFileName) = 1 Then + $h_lockfile = FileOpen($s_LockFileName,0) + $a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0) + FileClose($h_lockfile) + ; $a_gelockt_von[1] = Benutzername + ; $a_gelockt_von[2] = Computername + ; $a_gelockt_von[3] = Stunde + ; $a_gelockt_von[4] = Minute + ; $a_gelockt_von[5] = Tag + ; $a_gelockt_von[6] = Monat + ; $a_gelockt_von[7] = Jahr + If $a_gelockt_von[0] = 7 Then + MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _ + "hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _ + "Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _ + "Programmaufruf ist blockiert!") + EndIf + $b_RunCalibe = False +Else + $h_lockfile = FileOpen($s_LockFileName,2) + FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF) + FileClose($h_lockfile) + $b_RunCalibe = True + ; Dinge aus RDP-Session herausfinden + $h_DllErgebnis = DllCall("Wtsapi32.dll","BOOL","WTSQuerySessionInformationW","int",0, "int", -1, "int", 10, "ptr*", 0, "DWORD*",0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_clientname = "unknown" + Else + $s_clientname = BinaryToString( DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) ,2) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + EndIf + $h_DllErgebnis = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", -1, "int", 14, "ptr*", 0, "DWORD*", 0) + If @error Or $h_DllErgebnis[0] = 0 Then + $s_ip = "unknown" + Else + $s_ip = DllStructGetData(DllStructCreate("byte[" & $h_DllErgebnis[5] & "]" , $h_DllErgebnis[4]),1) + DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $h_DllErgebnis[4]) + $s_ip = StringTrimLeft($s_ip,14) + $a_DezimalIP[1] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[2] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[3] = Dec(StringLeft($s_ip,2)) + $s_ip = StringTrimLeft($s_ip,2) + $a_DezimalIP[4] = Dec(StringLeft($s_ip,2)) + $s_ip = $a_DezimalIP[1] & "." & $a_DezimalIP[2] & "." & $a_DezimalIP[3] & "." & $a_DezimalIP[4] + EndIf + ; Und Logfile-Schreiben + If $s_clientname = "" Then + $s_clientname = "Keine RDP Sitzung!" + $s_ip = "" + EndIf + + FileWriteLine(@ScriptDir & "\MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGIN => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +EndIf + + +If $b_RunCalibe = False Then + Exit 1 +EndIf + +$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE) +If $h_Calibre = 0 Then + FileDelete($s_LockFileName) + MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten") + Exit 1 +EndIf + + + +Do + Sleep(3000) + ;ConsoleWrite($h_Calibre & @CRLF) + If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then + $b_RunCalibe = False + EndIf +Until $b_RunCalibe = False + +FileDelete($s_LockFileName) +FileWriteLine("MultiuserLOG.txt", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - LOGOUT => USERNAME: " & @UserName & _ + " COMPUTERNAME: " & @ComputerName & " RDP-Client: " & $s_clientname & " - " & $s_ip) +Sleep (2000) + +If FileExists($s_LockFileName) = 1 Then + MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName) + Exit 1 +Else + Exit 0 +EndIf + + + + + diff --git a/V3/CalibreMultiuserStarterV3.exe b/V3/CalibreMultiuserStarterV3.exe new file mode 100644 index 0000000..6fcb8a0 Binary files /dev/null and b/V3/CalibreMultiuserStarterV3.exe differ diff --git a/bittewarten.jpg b/bittewarten.jpg new file mode 100644 index 0000000..2ddb4ef Binary files /dev/null and b/bittewarten.jpg differ