autohotkey - 将光标移动到水平方向的代码问题
问题描述
我使用的代码在激活时将光标的移动限制在水平方向,但我遇到了以下问题:切换脚本时,光标从其原始位置向下移动,而不是保持在相同的高度。
我正在使用的代码是这个:
!s:: ; Hotkey will toggle status
Confine := !Confine
MouseGetPos ,, SetY
Confine ? ClipCursor( 0 , SetY , A_ScreenWidth , SetY+1 ) : DllCall( "ClipCursor" )
Return
ClipCursor( x1=0 , y1=0 , x2=1 , y2=1 ) {
VarSetCapacity( R , 16 , 0 )
NumPut( x1 , &R + 0 )
NumPut( y1 , &R +4 )
NumPut( x2 , &R +8 )
NumPut( y2 , &R +12 )
Return DllCall( "ClipCursor" , UInt , &R )
}
我需要光标不要跳跃。如何解决这种行为?
这个问题与我之前发布的另一个问题有关:
解决方案
坐标 SetY 必须相对于桌面(整个屏幕)。
!s:: ; Hotkey will toggle status
Confine := !Confine
CoordMode, Mouse, Screen ; If this command is not used the coordinates are relative to the active window.
MouseGetPos ,, SetY
If (Confine)
ClipCursor( Confine, 0, SetY, A_ScreenWidth+1, SetY+1 )
else
DllCall( "ClipCursor" )
Return
ClipCursor( Confine=True, x1=0 , y1=0 , x2=1 , y2=1 ) {
VarSetCapacity( R , 16 , 0 )
NumPut( x1 , &R + 0 )
NumPut( y1 , &R +4 )
NumPut( x2 , &R +8 )
NumPut( y2 , &R +12 )
Return DllCall( "ClipCursor" , UInt , &R )
}
推荐阅读
- python - 在 ipython 中,如何在它解释我写的内容之前键入多行?
- c# - 无法使用空间 LINQ 查询在多边形内找到多边形
- javascript - 为什么我的 script_loader_tag 钩子实际上并没有改变脚本的类型?
- javascript - 模块“AppModule”错误导入的意外值“AngularFirestoreDocument”
- laravel - laravel 无法显示图片
- wpf - 在静态资源文件之外分配一个属性值
- javascript - While循环内部的Javascript querySelector问题
- c# - TweetInvi 验证但不执行搜索
- python - 在单独的线程中将数据写入磁盘(并行)
- here-api - Here Maps Routing API V8 - 多个航点