vnc unlock windows session

Asked by Laurent IZAC

Hi

has anybody managed to unlock a Windows session accessed through vnc ?
I'm using Sikulix 2.0.5 from a Jython script (in the IDE) and neither :
    screen.type(Key.DELETE, Key.CTRL+Key.ALT)
nor :
   screen.keyDown(Key.CTRL)
   screen.keyDown(Key.ALT)
   screen.keyDown(Key.DELETE)
   screen.keyUp(Key.DELETE)
   screen.keyUp(Key.ALT)
   screen.keyUp(Key.CTRL)

works for me.

Thanks for your insights

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Laurent IZAC
Solved:
Last query:
Last reply:
Revision history for this message
Laurent IZAC (laurent-izac) said (last edit ):
#1

BTW, it does not even work locally...so I guess there is more to it than just a key combination.
I read on other threads that it could be related to a Java bug, but both TigerVNC and TightVNC viewers (both Java apps) are able to do it...

Oh, and I tried also the NUM_LOCK trick but with no better result.

Thoughts ?

Revision history for this message
RaiMan (raimund-hocke) said :
#2

Not possible.
SikuliX can only act on unlocked screens.

Revision history for this message
Laurent IZAC (laurent-izac) said :
#3

Thanks for your feedback Raiman.
My understanding is that TigerVNC client triggers the sequence here : https://github.com/TigerVNC/tigervnc/blob/9d63d9c2b388e7a5491deaf8b39756b773029158/java/com/tigervnc/vncviewer/Viewport.java#L728

Is there a way I could call that code from my script ?

Revision history for this message
RaiMan (raimund-hocke) said :
#4

The TigerVNC version you mentioned above is not the one bundled with SikuliX.

The bundled one is here: https://github.com/RaiMan/sikulix2tigervnc (based on T-VNC 1.7.1 from 2017).
Since the sources are bundled, I do not believe, that putting the latest TVNC jar on class path makes the features accessible - but you might try ;-)

Accessing Java features (jars on class path) is rather simple in Jython:
import package.class as myClass
instance = myClass(....) # create an instance
retVal = instance.method(....) # run the method

I guess next year ;-) I will try to reactivate the VNC support again in SikuliX.

Revision history for this message
Laurent IZAC (laurent-izac) said (last edit ):
#5

Ok.

When I look at your embedded version of TigerVNC I can find a similar sequence here : https://github.com/RaiMan/sikulix2tigervnc/blob/682ba518bc1f4d9f790c0bd92d19582249507ea4/src/main/java/com/tigervnc/vncviewer/F8Menu.java#L113

I confirm that using your jar, I can start the interactive TigerVnc client and through F8 menu trigger this sequence that actually unlocks the session.

Now what would be required for this same sequence to be triggerable from a Sikuli script ?

Revision history for this message
RaiMan (raimund-hocke) said :
#6

Ok, then you might give it a try as mentioned in comment #4

Revision history for this message
Laurent IZAC (laurent-izac) said :
#7

I would need a reference to the currently open connection...
because these writeKeyEvent() methods come from the CConn object associated with the current screen.
I don't think we have access to that object from the python script.

Looking further, it seems that TigerVNC is actually using X11 key codes, even for Windows, while Sikuli has these key mappings only for Linux...
Is there a way to temporary use Linux key mappings from a Python script (even if the target OS is Windows) ?

Revision history for this message
RaiMan (raimund-hocke) said :
#8

The VNC-start should return a VNCScreen object, which in turn has a method getClient(), that returns the internal connection object.

Revision history for this message
Laurent IZAC (laurent-izac) said :
#9

IT WORKS ! Thanks

Please find below a working Python script example (the VNC server is TightVNC in my case):

import sys
import shutil
import com.tigervnc.rfb.CMsgWriterV3
import com.tigervnc.rfb.Keysyms
import org.sikuli.vnc.VNCScreen as VNCScreen

vs = VNCScreen.start("<vnc_server>", <vnc_port>, "<vnc_password>", 10, 1000)

if not vs:
   print("Error connecting to VNC")
   exit(-1)

wait(1)
vs.click()
wait(1)

if(vs.exists("press_ctrl_alt_del_to_unlock.png")):
    print("we need to unlock the session")
    cc = vs.getClient().writer()
    cc.writeKeyEvent(Keysyms.Control_L, True)
    cc.writeKeyEvent(Keysyms.Alt_L, True)
    cc.writeKeyEvent(Keysyms.Delete, True)
    cc.writeKeyEvent(Keysyms.Delete, False)
    cc.writeKeyEvent(Keysyms.Alt_L, False)
    cc.writeKeyEvent(Keysyms.Control_L, False)

    wait(1)

vs.click(vs.wait("password_field.png",1))
wait(1)

vs.type("<windows_password>"+Key.ENTER)
wait(1)

vs.doubleClick(vs.wait("Google_icon.png",1))

[...]