问题描述
对于那些后来发现这一点的人,出于谷歌原因或任何原因,虽然评论有所帮助,但我在很大程度上不得不从头开始重新编写代码。如果您想在 Procreate 中使用 CSP 等效的私有层,或者如果您想使用 CSP 录制功能而不显示您的参考层,请下载 autohotkey 和此脚本,然后设置以下设置。
- CTRL 和 Numpad+ 放大
- CTRL 和 Numpad- 缩小
- 鼠标中键平移。
然后执行以下操作,在两页上放置某种类型的参考,一个大棋盘,一个带有几行的点,等等。然后将两个窗口对齐,使它们显示完全相同的内容,仅使用鼠标中键平移,使用 CTRL+ 和 CTRL- 放大和缩小。
这是我的第一个自动热键脚本,我试图链接一个艺术程序的两个不同窗口,这样当我平移一个画布时,它也会平移另一个。我希望它尽可能精确,但我在第 1 行收到一个错误,说它是一个无效的热键,我尝试删除变量并移动逗号,但我不确定是什么我做错了。
这是我的代码。出于目的,我将解释按钮组合。
Space + L Mouse Button 一起让我平移画布,当我释放一个或另一个时,我需要知道光标在哪里。
LCtrl + Numpad5 禁用在 WindowTop 上的点击,我用它来将一个窗口透明地覆盖在另一个窗口上。
LCtrl + Tab 在应用中的两个画布之间切换
#IfWinActive ahk_exe CLIPStudioPaint.exe
; coordmode
Coordmode,Mouse,Screen
t := 0
;Below line starts script,and declares The Starting Coordinates
WinTitle = 3DLayer
SetTitleMatchMode,2
^F9::
WinSet,Transparent,Off
^F11::
WinSet,ExStyle,-0x20,% WinTitle
return
^F10::
WinSet,+0x20,% WinTitle
WinSet,128,% WinTitle
return
~MButton::
if (t = 0)
{
MouseGetPos,MouseStartX,MouseStartY
t := 1
}
return
~MButton up::
;When MButton is released,records mouse ending positions
MouseGetpos,MouseEndX,MouseEndY
;Blocks input in case I move mouse or touch keyboard while it's running
BlockInput,On
; switches canvas
Send ^{TAB}
; set window for click through
WinTitle = 3DLayer
SetTitleMatchMode,2
; disables Click Through
WinSet,% WinTitle
; drag
MouseClickDrag,M,MouseStartY,MouseEndY
;Re-enables Click Through
WinSet,% WinTitle
Winset,150,% WinTitle
;Turns inputs back on,so that I can resume using the art program
Send ^{TAB}
BlockInput,Off
t := 0
return
~^NumpadAdd::
BlockInput,On
; Get Mouse Position
MouseGetPos,ScrollX,ScrollY
;Block input,then switch canvases
Send ^{Tab}
sleep 50
; disables Click Through
WinSet,% WinTitle
; Move Mouse where it needs to be then scroll
MouseMove,ScrollY
Send ^{NumpadAdd}
;Re-enables Click Through
WinSet,Off
return
~^NumpadSub::
BlockInput,ScrollY
Send ^{NumpadSub}
;Re-enables Click Through
WinSet,Off
return
解决方法
这个时候,我做的最大的改变就是更换
Space UP || LMButton UP::MouseGetPos MouseEndX,MouseEndY
与
while (GetKeyState("LButton","P") and GetKeyState("Space","P"))
sleep 50
MouseGetPos MouseEndX,MouseEndY
(因为你不能有嵌套的热键)
我实际上不知道它是否按预期工作,因为我没有您正在使用的软件,但如果出现问题,请随时 lmk。
更新 1:
为了保留键的本机功能,我们可以使用 ~
修饰符。
来自modifier section of the docs的相关部分:
当热键触发时,其键的本机功能不会被阻止 (对系统隐藏)。
为了实现这一点,我们可以添加 ~
键作为热键的前缀,转
Space & LButton::
进入
~Space & LButton::
当前代码 v2:
#IfWinActive ahk_exe CLIPStudioPaint.exe
;Below line starts script,and declares 4 variables with the value 0 to reset the script,to make sure for no reason it uses the old values
~Space & LButton::
;Once variables are declared,it records those variables
MouseGetPos MouseStartX,MouseStartY
;When space or Mouse button release,it uses the 4 recorded variables to move and click on the canvas
while (GetKeyState("LButton",MouseEndY
;Blocks input in case I move mouse or touch keyboard while it's running
BlockInput,On
;Disables Click Through in WindowTop (That's a literal name of the program) by pressing CTRL and Numpad5
Send ^{Numpad5}
;Switches Canvasses to the new canvas (Basically a 2nd tab in the program)
Send ^{TAB}
;Uses the recorded mouse positions to middle mouse button drag the exact same way I had in the previous section
MouseClickDrag,M,MouseStartX,MouseStartY,MouseEndX,MouseEndY
;Re-enables Click Through
Send ^{TAB}
;Switches back too original canvas
Send ^{Numpad5}
;Turns inputs back on,so that I can resume using the art program
BlockInput,Off
return
Space::Space