简体   繁体   English

使用32位JRE打开64位Windows的虚拟键盘

[英]Open the 64 bits windows's virtual keyboard using a 32 bit JRE

I need to open the Windows's virtual keyboard from my application, which will be deployed using Eclipse RCP on the windows 32 bit platform (ie win32 JRE). 我需要从我的应用程序中打开Windows的虚拟键盘,该虚拟键盘将在Windows 32位平台(即win32 JRE)上使用Eclipse RCP进行部署。

Following the answers to the post open the Windows virtual keyboard in a Java program , the applications does so correctly on a 32 bit Windows OS, but refuses to work on a 64 bits Windows OS. 按照帖子的答案, 在Java程序中打开Windows虚拟键盘 ,应用程序可以在32位Windows OS上正常运行,但拒绝在64位Windows OS上运行。

The solution I am using is the following ones: 我正在使用的解决方案如下:

//          String sysroot = System.getenv("SystemRoot"); //$NON-NLS-1$
//          Runtime.getRuntime().exec("cmd.exe /c "+sysroot + "\\system32\\osk.exe /n"); //$NON-NLS-1$ //$NON-NLS-2$
            Runtime.getRuntime().exec("osk");

Is there a way to fix this without using a 64 bit deploy? 有没有办法在不使用64位部署的情况下解决此问题? (which I can't create, as long as I am using a library that does not support this environment). (只要我使用的是不支持该环境的库,就无法创建)。

Thanks 谢谢

Try this code. 试试这个代码。 not sure it will work. 不确定它是否会工作。 but worth a try. 但值得一试。

Desktop desktop = null;
if (Desktop.isDesktopSupported()) 
{
    desktop = Desktop.getDesktop();
}
String sysroot = System.getenv("SystemRoot");
desktop.open(new File(sysroot+"/system32/osk.exe"));

I am new to this Desktop class, and i would like to know if the class does the trick ;) 我是这个Desktop类的新手,我想知道这个类是否能解决问题;)

No. You won't be able to use the 64-bit library from a 32-bit Java app and/or a 32-bit OS. 不可以您将无法使用32位Java应用程序和/或32位OS中的64位库。 You'll have to deploy your app x64. 您必须部署您的应用程序x64。

this is my workaround: 这是我的解决方法:

FileOutputStream fileOutputStream = new FileOutputStream(new File("C:/TEMP/RUN.BAT"));

        String file = "START C:/Windows/System32/osk.exe" + '\n'
                + "EXIT";
        fileOutputStream.write(file.getBytes());
        fileOutputStream.close();
        Runtime.getRuntime().exec("CMD /C START C:/TEMP/RUN.bat");
        Runtime.getRuntime().exec("CMD /C DEL C:/TEMP/RUN.bat");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM