以下代码,按【Alt+;】将鼠标移动到光标缩在位置 。
但是在cmd、微博首页搜索框等窗口激活时,获取到的是窗口左上角坐标,而不是原输入框光标缩在位置。
请问如何修改?
或者任何其他能实现此功能的方法?
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;