革博士程序V1仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ScreenKeyboard.cs 1.8 KiB

пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace LeatherApp.Utils
  9. {
  10. public class ScreenKeyboard
  11. {
  12. public static bool isShowNumBoard = false;
  13. [DllImport("kernel32.dll", SetLastError = true)]
  14. public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
  15. [DllImport("kernel32.dll", SetLastError = true)]
  16. public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
  17. public static IntPtr ptr = new IntPtr();
  18. public static void ShowScreenKeyboard()
  19. {
  20. try
  21. {
  22. //判断软键盘是否进程是否已经存在,如果不存在进行调用
  23. Process[] pro = Process.GetProcessesByName("osk");
  24. bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
  25. //键盘如果已经打开则重新打开,防止最小化无法显示
  26. if (pro != null && pro.Length > 0)
  27. {
  28. Process kbpr = pro[0];
  29. kbpr.Kill();
  30. if (isWow64FsRedirectionDisabled)
  31. {
  32. Process.Start(@"C:\WINDOWS\system32\osk.exe");
  33. Wow64RevertWow64FsRedirection(ptr);
  34. }
  35. return;
  36. }
  37. if (isWow64FsRedirectionDisabled)
  38. {
  39. Process.Start(@"C:\WINDOWS\system32\osk.exe");
  40. Wow64RevertWow64FsRedirection(ptr);
  41. }
  42. }
  43. catch (Exception ex)
  44. {
  45. }
  46. }
  47. }
  48. }