【求助】热键激活时获取原光标所在位置

JRJJ 6月前 598

以下代码,按【Alt+;】将鼠标移动到光标缩在位置 。

但是在cmd、微博首页搜索框等窗口激活时,获取到的是窗口左上角坐标,而不是原输入框光标缩在位置。

请问如何修改?

或者任何其他能实现此功能的方法?

Code AardioLine:46复制
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
    • import win.ui;
    • /*DSG{{*/
    • var winform = win.form(text="aardio form";right=759;bottom=469)
    • winform.add()
    • /*}}*/
    • import key.hotkey;
    • var superHotkey = key.hotkey(winform)
    • var hotkeyf=function(hFocus){
    • //部分窗口正常
    • GetCaretPos = ::User32.api("GetCaretPos","int(struct& lpPoint)");
    • var hwndCaret = hFocus
    • winex.attach(hwndCaret, true);
    • var ok, pt = GetCaretPos( ::POINT() );
    • var x, y = win.toScreen(hwndCaret, pt.x, pt.y);
    • win.toScreen(hwndCaret,)
    • winex.attach(hwndCaret, false);
    • import mouse;
    • mouse.moveTo(x, y, true);
    • }
    • superHotkey.loadTable({
    • (function(){
    • import process
    • //这里的代码可以直接执行
    • var lastFocus,lastPath,lastClass;
    • checkImeProcess = function(hFocus,exeFile){
    • if(lastFocus != hFocus){
    • lastClass = win.getClass(hFocus);
    • var tid,pid = win.getThreadProcessId(hFocus);
    • lastpid = pid;
    • lastPath = process.getPath(pid);
    • lastFocus = hFocus
    • lt("lastClass:{} tid:{} pid:{} lastPath:{} hFocus:{} exeFile:{}",lastClass,tid,pid,lastPath,hFocus,exeFile)
    • }
    • return (lastPath && io.splitpath(lastPath).file == exeFile )
    • }
    • })();
    • ["Alt+;"] = hotkeyf;
    • });
    • winform.show();
    • win.loopMessage();
    • return winform;


    最新回复 (2)
    • 瞌睡蟲子 6月前
      0 2
      工具》探测器
    • JRJJ 6月前
      0 3
      瞌睡蟲子 工具》探测器
      人工?我想知道的是,代码中怎么知道:在某个窗口的某个输入框,按了快捷键,激活自己的应用,输入,这时候有些应用就失去焦点无法模拟输入了。所以我需要鼠标点一下原来的位置。
    返回