Code : Tout sélectionner
#include <Process.au3>
#include<File.au3>
Global $login = GUICtrlRead($saisir_login)
Global $passw = GUICtrlRead($saisir_mdp)
Global $ip = GuiCtrlRead($saisir_ip)
Func VNC()
Local $netuse = ("Net use " & "\\" & $ip & "\c$" & " /user:" & $login & " " & $passw)
Local $sFile = (@ScriptDir & '\Connection vnc.vnc')
Local $dFile = ('"C:\Program Files\RealVNC\VNC4\vncviewer.exe" -config "' & $sFile )
Local $regdir = ("\\" & $ip & "\HKLM\SOFTWARE\RealVNC\WinVNC4")
$hFile = FileOpen($sFile, 2) ; écriture dans le fichier connection vnc.vnc
FileWriteLine($hFile, "[Connection]")
FileWriteLine($hFile, "Host=" & $ip)
FileWriteLine($hFile, "[Options] ")
FileWriteLine($hFile, "UseLocalCursor=1 ")
FileWriteLine($hFile, "UseDesktopResize=1 ")
FileWriteLine($hFile, "FullScreen=0 ")
FileWriteLine($hFile, "FullColour=1 ")
FileWriteLine($hFile, "LowColourLevel=1 ")
FileWriteLine($hFile, "AutoSelect=1 ")
FileWriteLine($hFile, "Shared=0 ")
FileWriteLine($hFile, "SendPtrEvents=1 ")
FileWriteLine($hFile, "SendKeyEvents=1 ")
FileWriteLine($hFile, "SendCutText=1 ")
FileWriteLine($hFile, "AcceptCutText=1 ")
FileWriteLine($hFile, "DisableWinKeys=1 ")
FileWriteLine($hFile, "Emulate3=0 ")
FileWriteLine($hFile, "PointerEventInterval=0 ")
FileWriteLine($hFile, "Monitor=\\.\DISPLAY2")
FileWriteLine($hFile, "MenuKey=F8 ")
FileWriteLine($hFile, "AutoReconnect=1 ")
FileClose($hFile)
_RunDOS ( $netuse )
; entrée du registre distant qui vont vous permettre d'enlever l'acceptation de la machine distante
RegWrite($regdir, "QueryConnect", "REG_DWORD", "0")
RegWrite($regdir, "QueryOnlyIfLoggedOn", "REG_DWORD", "0")
RegWrite($regdir, "SecurityTypes", "REG_SZ", "None")
; Choix de l'activation "clavier souris distant"
$yesorno = MsgBox (4, " Choix activation clavier, souris distant" , "Voulez vous activer les clavier/souris de l'utilisateur distant ?")
If $yesorno = 6 Then
RegWrite($regdir, "DisableLocalInputs", "REG_DWORD", "0") ; si oui alors le clavier/souris distant reste actif
Else
RegWrite($regdir, "DisableLocalInputs", "REG_DWORD", "1") ; si non le clavier/souris distant sont désactivé
EndIf
RunWait($dFile) ; lancement de VNC
Sleep(2000) ; Quand vous avez terminer et que vous fermer votre VNC attendre 2 seconde et ...
; retour de config normal du pc distant
RegWrite($regdir, "QueryConnect", "REG_DWORD", "1")
RegWrite($regdir, "QueryOnlyIfLoggedOn", "REG_DWORD", "1")
RegWrite($regdir, "SecurityTypes", "REG_SZ", "Vnc-Auth")
If $yesorno = 7 Then
RegWrite($regdir, "DisableLocalInputs", "REG_DWORD", "0") ; Si vous avez répondu non a la question alors retour config normal pour le clavier/souris distant
EndIf
EndFunc