对比两种写法的异同

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: 对比两种写法的异同

Re: 对比两种写法的异同

Post by NPerovic » 03 Sep 2023, 04:34

  1. 寫法 1 會使用鍵盤勾點監聽鍵盤事件。
  2. 寫法 2 會失去原本 a 的功能,要保持原按鍵功能,請和寫法 1 一樣在前面加上 ~
  3. 寫法 2 在每次按下 a 時取得空白鍵的狀態。
  4. 寫法 2 在你持續按住空白鍵和 a 時,原本不該出現的 a 會隨機插入在你要發送的按鍵之間。若要發送的按鍵是單純的字串,可以使用 Text-Mode 或改用 #If 判斷空白鍵狀態來解決。
Text Mode

Code: Select all

SendInput {Text}Custom_Code
#If

Code: Select all

#If GetKeyState("Space", "P")
a::SendInput Custom_Code
#If

对比两种写法的异同

Post by Azona77 » 02 Sep 2023, 10:23

同样是使用“空格+A”触发,请问下面两种写法有什么异同吗?(ahk版本是1.1)
在触发逻辑上,好像是一致的?都不会影响空格和a键的功能?
其他方面,例如在性能上会有区别吗?

写法1:

Code: Select all

~Space & a::  
    Send, "Custom_Code"
return
写法2:

Code: Select all

a::
    If GetKeyState("Space")
    {
        Send, "Custom_Code"
    }
return

Top