Class VernacularClient
- java.lang.Object
-
- com.shinyhut.vernacular.client.VernacularClient
-
public class VernacularClient extends Object
-
-
Constructor Summary
Constructors Constructor Description VernacularClient(VernacularConfig config)Creates a new VNC client using the specified configuration object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclick(int button)'Clicks' (presses and releases) the specified mouse button.voidcopyText(String text)Copies the specified text to the remote clipboardvoidhandleKeyEvent(KeyEvent event)Presses, releases or 'types' the key represented by the specified KeyEvent.booleanisRunning()Is the client currently running?voidmoveMouse(int x, int y)Moves the remote mouse pointer to the specified coordinates (relative to the top-left of the screen).voidscrollDown()Scroll down using the mouse wheel.voidscrollUp()Scroll up using the mouse wheel.voidstart(String host, int port)Starts the VNC client by connecting to the specified remote host and portvoidstop()Stops the VNC clientvoidtype(int keySym)'Types' (presses and releases) the key represented by the specified KeySym.voidtype(String text)'Types' (presses and releases) the key representing each character in the specified string, in order.voidupdateKey(int keySym, boolean pressed)Updates the status (pressed or not pressed) of the key represented by the specified KeySymvoidupdateMouseButton(int button, boolean pressed)Updates the status (pressed or not pressed) of the specified mouse button.
-
-
-
Constructor Detail
-
VernacularClient
public VernacularClient(VernacularConfig config)
Creates a new VNC client using the specified configuration object- Parameters:
config- The VNC client configuration
-
-
Method Detail
-
start
public void start(String host, int port)
Starts the VNC client by connecting to the specified remote host and port- Parameters:
host- Remote host to connect toport- Remote port to connect to- Throws:
IllegalStateException- if the client is already running
-
stop
public void stop()
Stops the VNC client
-
moveMouse
public void moveMouse(int x, int y)Moves the remote mouse pointer to the specified coordinates (relative to the top-left of the screen).- Parameters:
x- The X coordinatey- The Y coordinate
-
updateMouseButton
public void updateMouseButton(int button, boolean pressed)Updates the status (pressed or not pressed) of the specified mouse button.To indicate a mouse 'click', call this method twice in quick succession, first with pressed = true, then with pressed = false, or use the convenience
click(int)method.On a conventional mouse, buttons 1, 2, and 3 correspond to the left, middle, and right buttons on the mouse. On a wheel mouse, each step of the wheel upwards is represented by a press and release of button 4, and each step downwards is represented by a press and release of button 5.
- Parameters:
button- The mouse button number (1-8)pressed- Is the mouse button currently 'pressed'?
-
click
public void click(int button)
'Clicks' (presses and releases) the specified mouse button.This is equivalent to calling
updateMouseButton(int, boolean)twice in quick succession with pressed = true and pressed = false- Parameters:
button- The mouse button number (1-8)
-
scrollUp
public void scrollUp()
Scroll up using the mouse wheel.This is equivalent to calling
click(int)with button number 4
-
scrollDown
public void scrollDown()
Scroll down using the mouse wheel.This is equivalent to calling
click(int)with button number 5
-
handleKeyEvent
public void handleKeyEvent(KeyEvent event)
Presses, releases or 'types' the key represented by the specified KeyEvent.The event type should be one of KEY_PRESSED, KEY_RELEASED or KEY_TYPED. All other event types are ignored.
- Parameters:
event- The KeyEvent to handle- See Also:
KeyEvent
-
updateKey
public void updateKey(int keySym, boolean pressed)Updates the status (pressed or not pressed) of the key represented by the specified KeySymFor a complete list of KeySyms, see https://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
- Parameters:
keySym- The KeySym for this key press or releasepressed- Was the key pressed (true) or released (false)?
-
type
public void type(int keySym)
'Types' (presses and releases) the key represented by the specified KeySym.This is equivalent to calling
updateKey(int, boolean)twice in quick succession with pressed = true and pressed = false- Parameters:
keySym- The KeySym for this key press or release
-
type
public void type(String text)
'Types' (presses and releases) the key representing each character in the specified string, in order.Note that this is only guaranteed to work as expected for strings containing only printable ASCII characters - apart from line breaks, which are converted to ENTER key presses, and tabs, which are converted to TAB key presses.
- Parameters:
text- The text that will be typed on the remote server
-
copyText
public void copyText(String text)
Copies the specified text to the remote clipboard- Parameters:
text- The text to be copied to the remote clipboard
-
isRunning
public boolean isRunning()
Is the client currently running?- Returns:
- true if the client is currently running, false otherwise
-
-