对比两种写法的异同 Topic is solved

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: tmplinshi, arcticir

Azona77
Posts: 3
Joined: 02 Sep 2023, 10:17

对比两种写法的异同

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
User avatar
NPerovic
Posts: 39
Joined: 31 Dec 2022, 01:25
Contact:

Re: 对比两种写法的异同  Topic is solved

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
✨ Dark Theme for Everything
✨ Other Scripts


Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 10 guests