【发布时间】:2021-05-12 20:41:46
【问题描述】:
对于那些后来发现这个的人,出于谷歌原因或任何其他原因,虽然 cmets 提供了帮助,但我在很大程度上不得不从头开始重新编写代码。如果你想在 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, ExStyle, +0x20, % WinTitle
WinSet, Transparent, 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, ExStyle, -0x20, % WinTitle
; drag
MouseClickDrag, M, MouseStartX, MouseStartY, MouseEndX, MouseEndY
;Re-enables Click Through
WinSet, ExStyle, +0x20, % WinTitle
Winset, Transparent, 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, ExStyle, -0x20, % WinTitle
; Move Mouse where it needs to be then scroll
MouseMove, ScrollX, ScrollY
Send ^{NumpadAdd}
;Re-enables Click Through
WinSet, ExStyle, +0x20, % WinTitle
Winset, Transparent, 150, % WinTitle
;Turns inputs back on, so that I can resume using the art program
Send ^{TAB}
BlockInput, Off
return
~^NumpadSub::
BlockInput, On
; Get Mouse Position
MouseGetPos, ScrollX, ScrollY
;Block input, then switch canvases
Send ^{Tab}
sleep 50
; Disables Click Through
WinSet, ExStyle, -0x20, % WinTitle
; Move Mouse where it needs to be then scroll
MouseMove, ScrollX, ScrollY
Send ^{NumpadSub}
;Re-enables Click Through
WinSet, ExStyle, +0x20, % WinTitle
Winset, Transparent, 150, % WinTitle
;Turns inputs back on, so that I can resume using the art program
Send ^{TAB}
BlockInput, Off
return
【问题讨论】:
-
老实说,如果你不这么说,我真的无法判断这是 AHK。这与功能性 AHK 代码相差甚远。您能否尝试更好地解释每行应该做什么,所以也许可以采取一些措施来纠正它们。根据您的描述,我真的无法判断脚本应该做什么。
-
我已经添加了 cmets 来说明页面上每一行的作用
-
我同意@0x464e 对您的代码的评估——您使用的许多语法类似于非AHK 语言。这里有一些你可以做的更简单的修改来修复它: 1. 当你试图给变量赋值时,使用
:=而不是=; 2. AHK中的单行cmets以;开头(像Python一样),而不是//(像Java、C++等使用); 3. 如果您想让 AHK 将击键发送到您的计算机,请查看Send命令。这是The Tutorial AHK 的快速入门 -
感谢您链接我的教程,并帮助解读我正在阅读的内容,它说我可以使用 = 命令代替 := 命令,它只是一个遗留功能,它还说当我同时按下两个键来发送命令时,我使用 & 符号,最后它说我通过将变量列为 theVariableName := variableValue 来声明一个变量。在词汇表中,它说我可以按照我这样做的方式为 MouseGetPos 的变量赋值。您能否指出哪些具体部分不正确?我确实错过了我需要使用发送命令,但在那之前它就坏了。
-
我知道@AHK_Questionnaire,这只是我注意到的许多更大问题的快速解决方案,因为当时其他承诺使我无法给出完整的答案。如果我今天不能完成,我会尝试今晚(时间允许)和明天晚上试一试
标签: automation autohotkey