home *** CD-ROM | disk | FTP | other *** search
Wrap
; AutoIt Version: 3.2.12.0 ; Language : German / English ; Author : michaelm_007 ; Version : 1.3.6 ; Download : http://www.german-nlite.de/index.php?showtopic=14306# #include <GUIConstantsEx.au3> #include <Constants.au3> #NoTrayIcon #RequireAdmin Opt ("TrayOnEventMode", 1) Opt ("GUIOnEventMode", 1) Opt ("TrayMenuMode", 1) Opt ("TrayAutoPause", 0) TraySetClick (16) HotKeySet ("^1", "ShowWindows_VM") HotKeySet ("^2", "HideWindows_VM") HotKeySet ("^3", "ShowWindows") HotKeySet ("^4", "HideWindows") HotKeySet ("^5", "UserHome") HotKeySet ("^6", "StartVM") HotKeySet ("^7", "ExitScript") HotKeySet ("^{NUMPAD1}", "ShowWindows_VM") HotKeySet ("^{NUMPAD2}", "HideWindows_VM") HotKeySet ("^{NUMPAD3}", "ShowWindows") HotKeySet ("^{NUMPAD4}", "HideWindows") HotKeySet ("^{NUMPAD5}", "UserHome") HotKeySet ("^{NUMPAD6}", "StartVM") HotKeySet ("^{NUMPAD7}", "ExitScript") Global $settings If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then TrayCreateItem ("Zeige VM (STRG+1)") TrayItemSetOnEvent (-1, "ShowWindows_VM") TrayCreateItem ("Verstecke VM (STRG+2)") TrayItemSetOnEvent (-1, "HideWindows_VM") TrayCreateItem("") TrayCreateItem ("Zeige VirtualBox (STRG+3)") TrayItemSetOnEvent (-1, "ShowWindows") TrayCreateItem ("Verstecke VirtualBox (STRG+4)") TrayItemSetOnEvent (-1, "HideWindows") TrayCreateItem ("") $settings = TrayCreateMenu ("VirtualBox Optionen") TrayCreateItem ("Homeverzeichnis (STRG+5)", $settings) TrayItemSetOnEvent (-1, "UserHome") TrayCreateItem ("Starte mit VM (STRG+6)", $settings) TrayItemSetOnEvent (-1, "StartVM") TrayCreateItem ("") TrayCreateItem ("Beende VirtualBox (STRG+7)") TrayItemSetOnEvent (-1, "ExitScript") Else TrayCreateItem ("Show VM (CTRL+1)") TrayItemSetOnEvent (-1, "ShowWindows_VM") TrayCreateItem ("Hide VM (CTRL+2)") TrayItemSetOnEvent (-1, "HideWindows_VM") TrayCreateItem("") TrayCreateItem ("Show VirtualBox (CTRL+3)") TrayItemSetOnEvent (-1, "ShowWindows") TrayCreateItem ("Hide VirtualBox (CTRL+4)") TrayItemSetOnEvent (-1, "HideWindows") TrayCreateItem ("") $settings = TrayCreateMenu ("VirtualBox Settings") TrayCreateItem ("Homeroot (STRG+5)", $settings) TrayItemSetOnEvent (-1, "UserHome") TrayCreateItem ("Starte with VM (STRG+6)", $settings) TrayItemSetOnEvent (-1, "StartVM") TrayCreateItem ("") TrayCreateItem ("Exit VirtualBox (CTRL+7)") TrayItemSetOnEvent (-1, "ExitScript") EndIf TraySetState () TraySetToolTip ("Portable-VirtualBox") If NOT ProcessExists ("VirtualBox.exe") Then If FileExists (@ScriptDir&"\data\settings\SplashScreen.jpg") Then SplashImageOn ("Portable-VirtualBox", @ScriptDir&"\data\settings\SplashScreen.jpg", 480, 360, -1, -1, 1) Else SplashTextOn ("Portable-VirtualBox", "Start Portable-VirtualBox", 220, 18, -1, -1, 1, "arial", 12) EndIf If FileExists (@ScriptDir&"\app\VirtualBox.exe") And (@ScriptDir&"\app\VBoxSVC.exe") And (@ScriptDir&"\app\VBoxC.dll") Then RunWait ("cmd /c sc create VBoxDRV binpath= ""%CD%\app\drivers\VBoxDrv\VBoxDrv.sys"" type= kernel start= auto error= normal displayname= VBoxDRV", @ScriptDir, @SW_HIDE) RunWait ("cmd /c sc create VBoxUSBMon binpath= ""%CD%\app\drivers\USB\filter\VBoxUSBMon.sys"" type= kernel start= auto error= normal displayname= VBoxUSBMon", @ScriptDir, @SW_HIDE) RunWait ("app\VBoxSVC.exe /reregserver", @ScriptDir, @SW_HIDE) RunWait ("regsvr32.exe /S app\VBoxC.dll", @ScriptDir, @SW_HIDE) ;RunWait ("rundll32.exe app\VBoxRT.dll, RTR3Init", @ScriptDir, @SW_HIDE) DllCall ("app\VBoxRT.dll", "hwnd", "RTR3Init") RunWait ("cmd /c sc start VBoxDRV", @ScriptDir, @SW_HIDE) RunWait ("cmd /c sc start VBoxUSBMon", @ScriptDir, @SW_HIDE) SplashOff () If FileExists (@ScriptDir&"\data\.VirtualBox") Then If FileExists (@ScriptDir&"\data\settings") Then $UserHome = IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") $StartVM = IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = true Then RunWait ("cmd /c set VBOX_USER_HOME=" &$UserHome& "& .\app\VBoxManage.exe startvm "" &$StartVM& """ , @ScriptDir, @SW_HIDE) Else RunWait ("cmd /c set VBOX_USER_HOME=" &$UserHome& "& .\app\VirtualBox.exe", @ScriptDir, @SW_HIDE) EndIf Else DirCreate (@ScriptDir&"\data\settings") IniWrite (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "%CD%\data\.VirtualBox") IniWrite (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "") RunWait ("cmd /c set VBOX_USER_HOME=%CD%\data\.VirtualBox & .\app\VirtualBox.exe", @ScriptDir, @SW_HIDE) EndIf Else DirCreate (@ScriptDir&"\data\settings") IniWrite (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "%CD%\data\.VirtualBox") IniWrite (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "") RunWait ("cmd /c set VBOX_USER_HOME=%CD%\data\.VirtualBox & .\app\VirtualBox.exe", @ScriptDir, @SW_HIDE) EndIf ProcessWaitClose ("VirtualBox.exe") ProcessWaitClose ("VBoxManage.exe") SplashTextOn ("Portable-VirtualBox", "Exit Portable-VirtualBox", 220, 18, -1, -1, 1, "arial", 12) Sleep (7000) RunWait ("cmd /c sc stop VBoxDRV", @ScriptDir, @SW_HIDE) RunWait ("cmd /c sc stop VBoxUSBMon", @ScriptDir, @SW_HIDE) RunWait ("app\VBoxSVC.exe /unregserver", @ScriptDir, @SW_HIDE) RunWait ("regsvr32.exe /S /U app\VBoxC.dll", @ScriptDir, @SW_HIDE) RunWait ("cmd /c sc delete VBoxDRV", @ScriptDir, @SW_HIDE) RunWait ("cmd /c sc delete VBoxUSBMon", @ScriptDir, @SW_HIDE) SplashOff () Else SplashOff () If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then MsgBox (0, "Fehler", "Bitte die Dateien von VirtualBox in den APP-ORDNER kopieren.") Else MsgBox (0, "Error", "Please copy the files of VirtualBox in the APP-FOLDER.") EndIf EndIf Else WinSetState ("Sun xVM VirtualBox", "", BitAND (@SW_SHOW, @SW_RESTORE)) WinSetState ("] - Sun xVM VirtualBox", "", BitAND (@SW_SHOW, @SW_RESTORE)) EndIf Exit Func ShowWindows_VM () Opt ("WinTitleMatchMode", 2) WinSetState ("] - Sun xVM VirtualBox", "", BitAND (@SW_SHOW, @SW_RESTORE)) EndFunc Func HideWindows_VM () Opt ("WinTitleMatchMode", 2) WinSetState ("] - Sun xVM VirtualBox", "", @SW_HIDE) EndFunc Func ShowWindows () Opt ("WinTitleMatchMode", 3) WinSetState ("Sun xVM VirtualBox", "", BitAND (@SW_SHOW, @SW_RESTORE)) EndFunc Func HideWindows () Opt ("WinTitleMatchMode", 3) WinSetState ("Sun xVM VirtualBox", "", @SW_HIDE) EndFunc Func UserHome () Opt ("GUIOnEventMode", 1) Local $WS_POPUP Global $Radio1, $Radio2, $HomeRoot If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then GUICreate ("Startauswahl - Heimverzeichnis", 334, 221, 193, 125, $WS_POPUP) GUISetFont (9, 400, 0, "Arial") GUISetBkColor (0xFFFFFF) GUICtrlSetFont (-1, 10, 800, 0, "Arial") GUICtrlCreateLabel ("Hier kannst du dein Heimverzeichnis auswΣhlen, in dem VirtualBox deine Einstellungen und VMs abspeichern soll. (DEFAULT = Verzeichnis von ""Portable-VirtualBox.exe"")", 16, 16, 304, 80) $Radio1 = GUICtrlCreateRadio ("Radio1", 16, 88, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") = "%CD%\data\.VirtualBox" Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf $Radio2 = GUICtrlCreateRadio ("Radio2", 16, 120, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") <> "%CD%\data\.VirtualBox" Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf GUICtrlCreateLabel ("VirtualBox normal starten (DEFAULT)", 39, 88, 280, 19) GUICtrlCreateLabel ("VirtualBox mit", 39, 121, 78, 19) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") = "%CD%\data\.VirtualBox" Then $HomeRoot = GUICtrlCreateInput ("Verzeichnis auswΣhlen ...", 119, 119, 142, 20) Else $User_Home = IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") $HomeRoot = GUICtrlCreateInput ($User_Home, 119, 119, 142, 20) EndIf GUICtrlCreateButton ("starten", 266, 118, 50, 22, 0) GUICtrlSetOnEvent (-1, "SRCUserHome") GUICtrlCreateButton ("OK", 46, 153, 57, 25, 0) GUICtrlSetOnEvent (-1, "OKUserHome") GUICtrlCreateButton ("Abbrechen", 210, 153, 70, 25, 0) GUICtrlSetOnEvent (-1, "ExitGUI") Else GUICreate ("Startsettings - Homelisting", 334, 221, 193, 125, $WS_POPUP) GUISetFont (9, 400, 0, "Arial") GUISetBkColor (0xFFFFFF) GUICtrlSetFont (-1, 10, 800, 0, "Arial") GUICtrlCreateLabel ("Here you can select your homelisting, in which VirtualBox is to store your attitudes and VMs. (DEFAULT = Listing of ""Portable VirtualBox.exe"")", 16, 16, 304, 80) $Radio1 = GUICtrlCreateRadio ("Radio1", 16, 88, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") = "%CD%\data\.VirtualBox" Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf $Radio2 = GUICtrlCreateRadio ("Radio2", 16, 120, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") <> "%CD%\data\.VirtualBox" Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf GUICtrlCreateLabel ("Normal VirtualBox start (DEFAULT)", 39, 88, 280, 19) GUICtrlCreateLabel ("VirtualBox with", 39, 121, 80, 19) If IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") = "%CD%\data\.VirtualBox" Then $HomeRoot = GUICtrlCreateInput ("Select homelisting ...", 121, 119, 142, 20) Else $User_Home = IniRead (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "NotFound") $HomeRoot = GUICtrlCreateInput ($User_Home, 121, 119, 142, 20) EndIf GUICtrlCreateButton ("start", 266, 118, 50, 22, 0) GUICtrlSetOnEvent (-1, "SRCUserHome") GUICtrlCreateButton ("OK", 46, 153, 57, 25, 0) GUICtrlSetOnEvent (-1, "OKUserHome") GUICtrlCreateButton ("Exit", 210, 153, 70, 25, 0) GUICtrlSetOnEvent (-1, "ExitGUI") EndIf GUISetState () EndFunc Func StartVM () Opt ("GUIOnEventMode", 1) Local $WS_POPUP Global $Radio3, $Radio4, $VMStart If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then GUICreate ("Startauswahl - Start VM", 334, 221, 193, 125, $WS_POPUP) GUISetFont (9, 400, 0, "Arial") GUISetBkColor (0xFFFFFF) GUICtrlSetFont (-1, 10, 800, 0, "Arial") GUICtrlCreateLabel ("Hier kannst du eine virtuelle Maschine auswΣhlen, die VirtualBox beim starten laden soll. (DEFAULT = Normaler Start von VirtualBox)", 16, 16, 304, 80) $Radio3 = GUICtrlCreateRadio ("Radio3", 16, 88, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = false Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf $Radio4 = GUICtrlCreateRadio ("Radio4", 16, 120, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = true Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf GUICtrlCreateLabel ("VirtualBox normal starten (DEFAULT)", 39, 88, 280, 19) GUICtrlCreateLabel ("VirtualBox mit", 39, 121, 78, 19) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = false Then $VMStart = GUICtrlCreateInput ("VM auswΣhlen ...", 119, 119, 142, 20) Else $Start_VM = IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") $VMStart = GUICtrlCreateInput ($Start_VM, 119, 119, 142, 20) EndIf GUICtrlCreateButton ("starten", 266, 118, 50, 22, 0) GUICtrlSetOnEvent (-1, "SRCStartVM") GUICtrlCreateButton ("OK", 46, 153, 57, 25, 0) GUICtrlSetOnEvent (-1, "OKStartVM") GUICtrlCreateButton ("Abbrechen", 210, 153, 70, 25, 0) GUICtrlSetOnEvent (-1, "ExitGUI") Else GUICreate ("Startsettings - Start VM", 334, 221, 193, 125, $WS_POPUP) GUISetFont (9, 400, 0, "Arial") GUISetBkColor (0xFFFFFF) GUICtrlSetFont (-1, 10, 800, 0, "Arial") GUICtrlCreateLabel ("Here you can select a virtual machine, which VirtualBox start with to load are. (DEFAULT = normal start of VirtualBox)", 16, 16, 304, 80) $Radio3 = GUICtrlCreateRadio ("Radio3", 16, 88, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = false Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf $Radio4 = GUICtrlCreateRadio ("Radio4", 16, 120, 15, 17) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = true Then GUICtrlSetState (-1, $GUI_CHECKED) EndIf GUICtrlCreateLabel ("Start VirtualBox normal (DEFAULT)", 39, 88, 280, 19) GUICtrlCreateLabel ("VirtualBox with", 37, 121, 80, 19) If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") = false Then $VMStart = GUICtrlCreateInput ("Select a VM ...", 120, 119, 142, 20) Else $Start_VM = IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") $VMStart = GUICtrlCreateInput ($Start_VM, 120, 119, 142, 20) EndIf GUICtrlCreateButton ("start", 266, 118, 50, 22, 0) GUICtrlSetOnEvent (-1, "SRCStartVM") GUICtrlCreateButton ("OK", 46, 153, 57, 25, 0) GUICtrlSetOnEvent (-1, "OKStartVM") GUICtrlCreateButton ("Exit", 210, 153, 70, 25, 0) GUICtrlSetOnEvent (-1, "ExitGUI") EndIf GUISetState () EndFunc Func SRCUserHome () If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then $PathHR = FileSelectFolder ("Heimverzeichnis auswΣhlen", "", 1+4) Else $PathHR = FileSelectFolder ("Select homelisting", "", 1+4) EndIf If not @error Then GUICtrlSetState ($Radio2, $GUI_CHECKED) GUICtrlSetData ($HomeRoot, $PathHR) EndIf EndFunc Func OKUserHome () If GUICtrlRead($Radio1) = $GUI_CHECKED Then IniWrite (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", "%CD%\data\.VirtualBox") GUIDelete () Else If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then If GUICtrlRead ($HomeRoot) = "Verzeichnis auswΣhlen ..." Then MsgBox (0, "Fehler", "Bitte ein Heimverzeichnis oder DEFAULT auswΣhlen.") Else IniWrite (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", GUICtrlRead ($HomeRoot)) GUIDelete () EndIf Else If GUICtrlRead($HomeRoot) = "Select homelisting ..." Then MsgBox (0, "Error", "Please select a homelisting or DEFAULT.") Else IniWrite (@ScriptDir&"\data\settings\settings.ini", "userhome", "key", GUICtrlRead ($HomeRoot)) GUIDelete () EndIf EndIf EndIf EndFunc Func SRCStartVM () $Start_VM = IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") Then $PathVM = FileOpenDialog ("VirtualBox VM auswΣhlen", $Start_VM&"\.VirtualBox\VDI", "VirtualBox VM (*.vdi)", 1+2) Else $PathVM = FileOpenDialog ("VirtualBox VM auswΣhlen", @ScriptDir&"\data\.VirtualBox\VDI", "VirtualBox VM (*.vdi)", 1+2) EndIf Else If IniRead (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "NotFound") Then $PathVM = FileOpenDialog ("Select VirtualBox VM", $Start_VM&"\.VirtualBox\VDI", "VirtualBox VM (*.vdi)", 1+2) Else $PathVM = FileOpenDialog ("Select VirtualBox VM", @ScriptDir&"\data\.VirtualBox\VDI", "VirtualBox VM (*.vdi)", 1+2) EndIf EndIf If not @error Then $VM_String = StringSplit ($PathVM, "\") $String = "" For $VDI In $VM_String $String = $VDI Next $VM_Start = StringSplit ($String, ".") GUICtrlSetState ($Radio4, $GUI_CHECKED) GUICtrlSetData ($VMStart, $VM_Start[1]) EndIf EndFunc Func OKStartVM () If GUICtrlRead($Radio3) = $GUI_CHECKED Then IniWrite (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", "") GUIDelete () Else If StringInStr ("0407, 0807, 0c07, 1007, 1407", @OSLANG) Then If GUICtrlRead ($VMStart) = "VM auswΣhlen ..." Then MsgBox (0, "Fehler", "Bitte eine VM oder DEFAULT auswΣhlen.") Else IniWrite (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", GUICtrlRead ($VMStart)) GUIDelete () EndIf Else If GUICtrlRead ($VMStart) = "Select a VM ..." Then MsgBox (0, "Error", "Please select a VM or DEFAULT.") Else IniWrite (@ScriptDir&"\data\settings\settings.ini", "startvm", "key", GUICtrlRead ($VMStart)) GUIDelete () EndIf EndIf EndIf EndFunc Func ExitGUI () GUIDelete () EndFunc Func ExitScript () Opt ("WinTitleMatchMode", 2) WinClose ("] - Sun xVM VirtualBox", "") WinWaitClose ("] - Sun xVM VirtualBox", "") WinClose ("Sun xVM VirtualBox", "") Break (1) EndFunc