Jump to content

VNC Auto Login


Recommended Posts

Hello,

Trying to write a script that will initiate a Real VNC 4 connection to a remote computer and then log on to that computer with a users Windows Credentials. I can intiate the VNC viewer program, type in the VNC username and password, and initiate the connection. I can also bring up the menu on the VNC viewer via the F8 key. Once this Menu is up I need to send the keystrokes "d" (Send Ctrl-Alt-Delete), followed by the users password. However, I can not seem to send keystrokes to this menu via auto it. I have tried sending them in ASCII hexadecimal and decimal. The Window Info for the VNC viewer only shows a Title, Class, and Size. No info is shown for the menu. Any ways around this or am I SOL?

#include <Misc.au3>
ShellExecute ("C:\Program Files\RealVNC\VNC4\vncviewer.exe")
Do
    sleep (1000)
    Until WinExists("VNC Viewer : Connection Details")
ControlSend ( "VNC Viewer : Connection Details", "", 1001, "WS-1:5900")
sleep (50)
ControlClick ("VNC Viewer : Connection Details", "OK", 1)
sleep (100)
ControlSend ( "VNC Viewer : Authentication [No Encryption]", "", 1000, "VNCPassword")
Sleep (50)
ControlClick ("VNC Viewer : Authentication [No Encryption]", "OK", 1)
sleep (1000)
$i = 0
SplashTextOn("Title", "Press F8 key to send Windows logon credentials", -1, -1, -1, -1, 4, "", 24)
sleep (1000)
Splashoff ()
while ($i < 10)
sleep (1000)
if _isPressed ("77") Then;if f8 is pressed send windows login credentials
sleep (1000)
send ("{F8}")
sleep (1500)
send ("{ASC 064)"); send D to menu to send Ctrl-Alt-Del to remote computer
sleep (100)
send ("userspassword"); Send users password
sleep (100)
Send ("{Enter}")
EndIf
$i = $i + 1
Wend
Edited by williamk
Link to comment
Share on other sites

When you use the _IsPressed UDF, the key that you are watching for is still sent to the application... so, you do not need to send the F8 key again.

Also, test your assumptions:

send ("{ASC 064)")

does not send a lower case d

Try that one line within SciTE and you should see what is being sent.

I was able to send a lower case d to that menu within VNC, if you cannot get that to work, then I would suggest sending "{UP}" as many times as needed to reach the desired menu option.

Try this untested code:

HotKeySet("{F8}", "_logon")

ShellExecute("C:\Program Files\RealVNC\VNC4\vncviewer.exe")
WinWait("VNC Viewer : Connection Details")
WinActivate("VNC Viewer : Connection Details")
WinWaitActive("VNC Viewer : Connection Details")
ControlSend("VNC Viewer : Connection Details", "", 1001, "WS-1:5900")
Sleep(50)
ControlClick("VNC Viewer : Connection Details", "OK", 1)
Sleep(100)
ControlSend("VNC Viewer : Authentication [No Encryption]", "", 1000, "VNCPassword")
Sleep(50)
ControlClick("VNC Viewer : Authentication [No Encryption]", "OK", 1)
Sleep(1000)
SplashTextOn("Title", "Press F8 key to send Windows logon credentials", -1, -1, -1, -1, 4, "", 24)
Sleep(1000)
SplashOff()

While 1
    Sleep(99)
WEnd

Func _logon()
    HotKeySet("{F8}")
    Send("{F8}")
    HotKeySet("{F8}", "_logon")
    Sleep(1500)
    Send("d"); send d to menu to send Ctrl-Alt-Del to remote computer
    Sleep(1000)
    Send("userspassword"); Send users password
    Sleep(100)
    Send("{Enter}")
EndFunc   ;==>_logon

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Also, test your assumptions:

send ("{ASC 064)")

does not send a lower case d

Especially since it's a left curly brace paired with a right parentheses... :whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...