【问题标题】:What does an asterisk mean at the beginning of an AHK script's line?AHK 脚本行开头的星号是什么意思?
【发布时间】:2012-05-07 06:08:03
【问题描述】:

我正在尝试修改我喜欢但不太完全理解的 AHK 脚本。

这行脚本开头的星号是什么意思?

*capslock::

最后的一对冒号是否意味着这一行只是语句的一部分?是否继续到下一行?

【问题讨论】:

    标签: syntax autohotkey


    【解决方案1】:

    无论是否按下修饰符都会触发热键。

    http://www.autohotkey.com/docs/Hotkeys.htm

    通配符:即使按住额外的修饰符也可以触发热键。这通常与重新映射键或按钮一起使用。例如:

    Win+C、Shift+Win+C、Ctrl+Win+C等都会触发这个热键。

    *#c::运行Calc.exe 

    即使修改键按下,按下 Scrolllock 也会触发此热键。

    *ScrollLock::运行记事本

    编辑: 嗯,第二部没看到。

    如果您只有一个语句,则将其全部放在一行中,如上所示。如果您有多个语句,则必须在 :: 之后添加一个换行符,并在末尾添加一个 return

    #w:: MsgBox "Windows+W FTW"
    #q::
      MsgBox "Windows+Q FTW"
      MsgBox "Another annoying message box!"
      return
    

    我有一种方法可以使用 capslock 键作为我更喜欢的修饰符:

    ;; make capslock a modifier, make shift-capslock a true capslock
    setcapslockstate, OFF ;SetCapsLockState, alwaysoff
    
    $*Capslock::   ; $ means that the hotkey code shouldn't trigger its own hotkey
      Gui, 99:+ToolWindow 
      Gui, 99:Show, x-1 w1 +NoActivate, Capslock Is Down 
      keywait, Capslock 
      Gui, 99:Destroy 
      return 
    
    ; Made a window show up when the capslock is pressed.
    
    ; Now, if that hidden windown is there, do anything you like
    #IfWinExist, Capslock Is Down 
       j::Left 
       k::Right 
       i::Up 
       m::Down 
    #IfWinExist 
    
    ; Oh, by the way, right-alt and capslock works like real capslock
    ralt & Capslock::
      GetKeyState, capstate, Capslock, T
      if capstate = U
      {
        SetCapsLockState, on
      } else {
        SetCapsLockState, off
      }
      return     
    

    【讨论】:

    • 对于更现代的 AHK 版本,您必须删除 +NoActivate 中的加号才能使其正常工作。否则,它工作得很好。谢谢!
    猜你喜欢
    • 2014-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-20
    • 1970-01-01
    • 2010-10-09
    • 2015-03-26
    • 2019-05-27
    相关资源
    最近更新 更多