LibVNC / libvncserver

LibVNCServer/LibVNCClient are cross-platform C libraries that allow you to easily implement VNC server or client functionality in your program.
GNU General Public License v2.0
1.07k stars 481 forks source link

RFB3.8 sending cut text fails, Win7 and Win10 using VMware16.1.2 #622

Closed YFforever2022 closed 5 days ago

YFforever2022 commented 6 days ago

Here is my code:

    std::string str = "Hello, World!";
    BOOL ret = SendClientCutText(client, (char*)str.c_str(), str.size());
    std::cout << "[" << str << "] " << ret << std::endl;

    str = "Hello, World!";
    ret = SendClientCutTextUTF8(client, (char*)str.c_str(), str.size());
    std::cout << "[" << str << "(UTF8)]  " << ret << std::endl;

    str = "你好, 世界!";
    ret = SendClientCutText(client, (char*)str.c_str(), str.size());
    std::cout << "[" << str << "]  " << ret << std::endl;

    str = "你好, 世界!";
    ret = SendClientCutTextUTF8(client, (char*)str.c_str(), str.size());
    std::cout << "[" << str << "(UTF8)]  " << ret << std::endl;

    SendKeyEvent(client, XK_Control_L, TRUE);
    Sleep(50);
    SendKeyEvent(client, XK_V, TRUE);
    Sleep(77);
    SendKeyEvent(client, XK_V, FALSE);
    Sleep(66);
    SendKeyEvent(client, XK_Control_L, FALSE);

This is the log:

04/07/2024 19:31:00 VNC server supports protocol version 3.8 (viewer 3.8)
04/07/2024 19:31:00 We have 1 security types to read
04/07/2024 19:31:00 0) Received security type 1
04/07/2024 19:31:00 Selecting security type 1 (0/1 in the list)
04/07/2024 19:31:00 Selected Security Scheme 1
04/07/2024 19:31:00 No authentication needed
04/07/2024 19:31:00 VNC authentication succeeded
04/07/2024 19:31:00 Desktop name "Windows 7 x64"
04/07/2024 19:31:00 Connected to VNC server, using protocol version 3.8
04/07/2024 19:31:00 VNC server default format:
04/07/2024 19:31:00   32 bits per pixel.
04/07/2024 19:31:00   Least significant byte first in each pixel.
04/07/2024 19:31:00   TRUE colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
04/07/2024 19:31:00 Unknown encoding 'tight'
04/07/2024 19:31:00 Unknown encoding 'zrle'
04/07/2024 19:31:00 Unknown encoding 'zlib'
[Hello, World!] 1
[Hello, World!(UTF8)]  0
[你好, 世界!]  1
[你好, 世界!(UTF8)]  0

I haven't figured out how to solve this problem. This problem has troubled me for two or three days. I really need your help.

YFforever2022 commented 5 days ago

a Even though I set LIBVNCSERVER_HAVE_LIBZ and added zlib, I still cannot run SendClientCutTextUTF8 successfully. SendClientCutText can return 1, but the VNC server clipboard is not successfully set.

bk138 commented 5 days ago

Please specify if you're trying to code a client or server and what type the remote end is. Are you maybe seeing #592?

YFforever2022 commented 5 days ago

Please specify if you're trying to code a client or server and what type the remote end is. Are you maybe seeing #592?

Hello, I am trying to write client code to connect to the VNC server that comes with VMware 16.1.2. I can successfully connect and obtain images and keyboard and mouse operations, but I cannot see success in setting the clipboard. I am not thinking about the UTF8 problem for now, and I cannot succeed in just sending English letters.

bk138 commented 5 days ago

Please use the chat at https://gitter.im/LibVNC/libvncserver for future questions :-)

For this here question; I recommend you take a look at the client examples at https://github.com/LibVNC/libvncserver/tree/master/examples/client

It could also be that the server does not support UTF8 cuttext or no cuttext at all.

YFforever2022 commented 5 days ago

Thank you very much for your suggestion. I referred to the code but still failed. Maybe the VNC server does not support it. I gave up this direction.