【发布时间】:2018-05-02 06:03:29
【问题描述】:
我制作了一些只出现在 OneNote 上并提供一些按钮的代码。我遇到的问题是,当我按下按钮时,它会获得焦点,因此 GUI 会消失。我找到了两种可能的解决方案,但我不确定如何实现它们。
我的第一个想法是让 GUI 无法聚焦,但如前所述,我不知道它是如何工作的。
第二个想法是我可以做
WinWaitNotActive - OneNote
只有在 OneNote 和 GUI 都没有激活时才通过,但我也不知道如何将两个可能的程序传递到命令中。
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#Notrayicon
SetTitleMatchMode 2
Gui +LastFound -Caption +ToolWindow +Border + AlwaysOnTop
Gui Add, Button, gDublicate x-1 y-1 w60 h25, Dublicate
Gui Add, Button, gDelete x57 y-1 w60 h25, Delete
Gui Add, Button, gBackwards x115 y-1 w25 h25, ←
Gui Add, Button, gForwards x138 y-1 w25 h25, →
Loop{
WinWaitActive - OneNote
Gui, Show, xCenter y35 NoActivate h23 w162
WinWaitNotActive - OneNote
Gui Hide
}
return:
Dublicate:
WinActivate - OneNote
SendInput ^c
Sleep 50
SendInput ^v
return
Delete:
WinActivate - OneNote
SendInput {Del}
return
Backwards:
WinActivate - OneNote
SendInput ^z
return
Forwards:
WinActivate - OneNote
SendInput ^y
return
【问题讨论】:
-
用例是什么?页面上的私人信息?如果你在处理多任务,那么高对比度/对比度会分散注意力?
-
@HashRocketSyntax 我正在使用绘图板记笔记,所以我经常用钢笔画画。不过,删除和复制等功能只能通过键盘实现。
-
既然你在按钮 g-labels 中激活了 OneNote,
WinWaitActive - OneNote不会返回并因此再次显示 GUI? -
@JoshBrobst 确实,但是如果我按下按钮太久重新出现后不会注册,而且它也需要时间所以双击不起作用。
标签: autohotkey