1

我如何能:

  1. 读取(等待并记录)单次按下(即 Shift-Alt-F5 )
  2. 将此记录的组合键传递给程序(即 Photoshop),而不将其作为热键运行。

我试过这个,但它不适用于我的非 ASCII 热键。它适用于 t 热键。

F6::
Suspend, On
Input, OutputVar, L1 M
Send, %OutputVar% 
Suspend, Off
return


F5::Run explorer
t::Run notepad
!+5::Run cmd
  • F5 是运行程序资源管理器的热键。
  • F6 是一个热键,一按即可暂停所有热键。并通过组合键作为非热键
  • 当我在 Firefox 中时,如果我按 F6 F5 它将进入 Firefox 的刷新页面操作。
  • 当我按 F5 时,没有前面的 F6,它将打开资源管理器
4

6 回答 6

1

根据您的笔记,我认为您想要执行以下操作。使用 #r 阻止任何输入并启动脚本,然后当您再次按 #r 时,脚本将停止并恢复输入。在这种情况下,你可以试试这个:

#Singleinstance force
$#r::
If (MyToggle := !MyToggle) ; Toggle the value MyToggle True/False
    {
        ToolTip,Input  blocked [Win]+r,A_ScreenWidth/2-50,0
        BlockInput, on ; In Vista and above, you need to run AHK as admin or run AHK in compatility mode with Windows XP SP 3
        SetTimer RunMyScript, 500 ; Start the actual script in 500 ms outside of this script, so you can toggle
        Return
    }
Else
    {
        Tooltip
        BlockInput, off
        ;Reload ; This will KILL the "RunMyScript" IMMEDIATELY at an unpredictable location.
        Return
    }
return

RunMyScript: ; This script runs independently from the script above. The script stops after 10 loops and resets the input. [Ctrl]+[Alt]+[Del] still kills any script.
SetTimer RunMyScript, Off ; Turn the 500 ms timer off
loop, 10
{
    if (!MyToggle) ; Check the MyToggle variable to see if you need to stop the script. This will Exit the script at a predictable location.
        Exit

    SoundBeep, 600,600
    Sleep, 1000
}
BlockInput, off ; Allow keyboard & mouse input again. Warning the [Win] key key may be left activated, causing keyboard actions to start applications
Tooltip
Return

让我知道这是否是您想要的。

于 2012-07-25T11:29:51.467 回答
1

两种解决方案。

  1. 将要捕获的热键添加到输入中,如下所示:

    Input, OutputVar, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
    

否则,这些非 ascii 键将被输入忽略。

或者,使 F5 键应用程序的行为特定。

SetTitleMatchMode, 2
#IfWinNotActive, Firefox
    F5::Run explorer
#IfWinNotActive

这样,您的F5密钥将始终启动 IE,除非您在 Firefox 中工作,然后F5重新F5加载您的页面。

于 2012-07-17T20:03:43.677 回答
0

可以通过这种方式将内容写入日志文件。在这里,我每天都会创建一个新的日志文件,并且对于每个条目,您必须重复最后两行(以获取实际时间)。

FormatTime, DateRef, %TimeNow%, yyyyMMdd ; Store current date in variable DateRef
MyLogFile = %A_ScriptDir%\LogFiles\LogFile-%DateRef%.txt ; Define the name of the log file.
FormatTime, TimeAbsolute, %TimeNow%, HH:mm:ss ; Use the current time to set the timestamp variable called TimeAbsolute used inside the Log File
FileAppend, `n`r| %TimeAbsolute% | Your hotkey and possibly in which application`n`r,%MyLogFile% ; Write logfile
于 2012-07-28T08:09:29.293 回答
0

我还没有检查过这个,但我认为这就是你要找的......

FormatTime, DateRef, %TimeNow%, yyyyMMdd ; Store current date in variable DateRef
MyLogFile = %A_ScriptDir%\LogFiles\LogFile-%DateRef%.txt ; Define the name of the log file.
FileAppend, `n`r| %TimeAbsolute% | Your hotkey and possibly in which application`n`r,%MyLogFile% ; Write logfile
Suspend, on ; Start with hotkeys disabled
Return

Pause:: ; Use pause key to 'activate' the hotkeys
Suspend, Off ; Activate the hotkeys
SetTimer, Stop, 10000 ; If no hotkey is pressed within 10 seconds, deactivate the hotkeys aagain
Return

Stop: ; Deactivate the hotkeys
Suspend, on ; Deactivate the hotkeys
SetTimer, Stop, Off ; turn the stop timer off
Return

q:: ; use a key (q) as a hotkey
Soundbeep, 600,600 ; sound a short beep to show that it works
HotKeyType = "q key"
WinGet, ApplicationType, ProcessName, A
GoSub, Write
Return

Write:
SetTimer, Stop, Off ; Make sure that the stop timer is turned off
FormatTime, TimeAbsolute, %TimeNow%, HH:mm:ss ; Use the current time to set  the timestamp variable called TimeAbsolute used inside the Log File
FileAppend, `n`r| %TimeAbsolute% | %HotKeyType% used in %ApplicationType%`n`r,%MyLogFile% ; Write logfile
Suspend, On ; Disable the hotkeys again
Exit
于 2012-07-28T10:25:25.963 回答
0

好吧,我认为这是最终的脚本......

通常,除非您按 F6,否则所有键都照常运行,然后在 3 秒钟内您可以使用热键。一旦您使用热键,行为就会再次恢复正常(3 秒仅在您不按热键的情况下)。当您按两次 F6 时,它将发送 F6。如果您找到了更简单的解决方案,请告诉我,因为这相对复杂。

FormatTime, DateRef, %TimeNow%, yyyyMMdd ; Store current date in variable DateRef
MyLogFile = %A_ScriptDir%\LogFile-%DateRef%.txt ; Define the name of the log file for today.
FormatTime, TimeAbsolute, %TimeNow%, HH:mm:ss
FileAppend, | %TimeAbsolute% | Your hotkey and possibly in which application`n`r,%MyLogFile% ; Write logfile
SpecialF6:=1
Suspend, On
Return

$F6::
Suspend, Permit
If SpecialF6
{
Suspend, Off
ToolTip Hotkeys On for 3 seconds,A_ScreenWidth/2-50,0
SpecialF6:=0
SetTimer, SuspendOn, 3000
Return
}
else
{
    Send, {F6}
    MyText = F6
    Gosub, WriteClose
}
Return

SuspendOn:
Suspend, On
SetTimer, SuspendOn, Off
ToolTip
SpecialF6:=1
return

F5::
Run explorer
MyText = F5 Run Explorer
Gosub, WriteClose
Return

t::
Run notepad
MyText = t Run Notepad
Gosub, WriteClose
Return

!+5::
Run cmd
MyText = Alt Shift 5 Run Command
Gosub, WriteClose
return

WriteClose:
Suspend, On
SetTimer, SuspendOn, Off
FormatTime, TimeAbsolute, %TimeNow%, HH:mm:ss
ToolTip
SpecialF6:=1
FileAppend, | %TimeAbsolute% | %MyText%`n`r,%MyLogFile% ; Write logfile
Exit
于 2012-07-28T19:19:15.213 回答
0

关于记录密钥,我专门将要在日志文件中打印的密钥类型定义为文本字符串,这样您就可以为每个不可打印的密钥定义自己的文本。

我用以下方式重新编写了脚本:当您按 F6 一次,然后按另一个键(在本例中为 F5)时,它将发出哔声(充当热键)。如果你按 F6 两次,if 将发送 F6,就好像没有设置热键一样。如果在没有先按 F6 的情况下按 F5,它只会发送 F5,就好像没有激活热键一样。希望这是你想要的......

$F6::
If (MySuspend := !MySuspend) ; Toggle the value MySuspend True/False
{
        ToolTip Hotkeys On (F6),A_ScreenWidth/2-50,0
}
Else
{
    Tooltip
    Send, {F6}
}
return

$F5::
If MySuspend
{
    SoundBeep, 600, 600
    MySuspend := 0
    ToolTip
}
else
{
    Send, {F5}
}
Return
于 2012-07-28T16:11:06.203 回答