以下代码,按【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;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;