關於偵測按鍵 Topic is solved

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

Moderators: tmplinshi, arcticir

SkyLife
Posts: 19
Joined: 18 May 2017, 20:53

關於偵測按鍵  Topic is solved

23 Dec 2017, 01:03

我希望能偵測到我按下了什麼鍵且能在按下的時候執行命令,像是下面所列的,但是要把所有的按鍵都列進去會需要太多列
evilC發布的UCR有這樣的功能
https://autohotkey.com/boards/viewtopic.php?t=12249
希望有人能幫忙
能偵測鍵盤上的所有按鍵是最好的

Code: Select all

Gui, new
Gui +ToolWindow -Border
Gui, Font, S15
Gui, Add, Text, Center, 按下想要替換的按鍵
Gui, Show
Loop
{
	if getkeystate("A", "P" )
	{
	MsgBox 你按下了A
	ExitApp
	}
	if getkeystate("B", "P" )
	{
	MsgBox 你按下了B
	ExitApp
	}
}
return
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: 關於偵測按鍵

23 Dec 2017, 04:24

examples

Code: Select all

;- http://www.autohotkey.com/board/topic/15574-morse-find-hotkey-press-and-hold-patterns/
;- http://www.autohotkey.com/board/topic/9166-fkee3/
;- http://www.autohotkey.com/board/topic/35566-rapidhotkey/

; !n::run,notepad  ;- a hotkey example alt+n

;------- example -------
;- push F1  twice or 3*  
;- write this above the F1-key :
; 2* notepad
; 3* calc 

$F1::
   p := Morse()
   If (p = "00")
        run, notepad
   If (p = "000")
        run,calc
return

$F12::
   p := Morse()
   If (p = "00")
        msgbox, 262144, F12-Key, F12 2 * pushed,2
   If (p = "000")
        msgbox, 262144, F12-Key, F12 3 * pushed,2
return
;--------------------------------------------------

Morse(timeout = 400)
{
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   Loop
       {
      t := A_TickCount
      KeyWait %key%
      Pattern .= A_TickCount-t > timeout
      KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern
       }
}
return
;===================================================
SkyLife
Posts: 19
Joined: 18 May 2017, 20:53

Re: 關於偵測按鍵

23 Dec 2017, 05:52

你給的例子並不能解決我的問題
這只能知道次數,而且我需要創建無數個熱鍵
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: 關於偵測按鍵

23 Dec 2017, 14:04

hotkeys ( alt+x... )

Code: Select all

!a::run,notepad
!b::run,calc
!c::run,charmap
;.....
SkyLife
Posts: 19
Joined: 18 May 2017, 20:53

Re: 關於偵測按鍵

23 Dec 2017, 21:43

謝謝你的回覆,我已經找到更好的方法了

Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 18 guests