感謝2位版友的意見,
V版友提供的整個改寫不失為一個山不轉路轉的方法 :p
由於我是繼之前寫簡單的重複按鍵的script
在更換熱鍵時想簡單的編輯檔案,改變變數就好
再試著U版友的 hotkey 指令,確實可以達到替換的功能,
但不曉得是不是我的寫法關係,只能啟動不能停止,
以下是 code,需要的人可以拿去用 ( F12 為開關),
而有興趣的人,麻煩幫我看一下如何寫才好 >"<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; 程式說明 ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 版本: v0.2_2008.08.20.23:51_by n0tme
; 功能: 重複滑鼠左鍵或右鍵的點擊
; 操作: 點選要重複的左鍵(left)或右鍵(right)後,
; 調整間隔時間再按下 F12 即可啟動 ( 再按下 F12 即停止)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; 參數設定 ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 熱鍵設定: 目前尚未作用
UserDefinedKey = F10
; 初始間隔時間 (ms)
delayms= 400
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; GUI 製作 ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; x,y 座標軸
; w,h 寬,高
; v 指定(內容)變數
; g 給予(點擊,改變)function
; slider for delay time
; 間隔時間: 換算成 slider 的倍數
delaymulti=10
; 間隔時間: slider 初始刻度
delayslider := delayms / delaymulti
Gui, Add, Text, x16 y122 w100 h30 vText4Delay, delay: %delayms%
ms
Gui, Add, Edit, x336 y42 w-250 h-210, Edit
Gui, Add, Slider, x136 y122 w260 h30 vSlider4Delay gSetDelayTime,
%delayslider%
; key select
Gui, Add, GroupBox, x36 y12 w200 h60 , key
Gui, Add, Radio, x66 y32 w60 h20 vRadio4LButton +Checked, Left
Gui, Add, Radio, x136 y32 w90 h20 vRadio4RButton, Right
; status
Gui, Add, GroupBox, x356 y22 w110 h80 , Status
Gui, Add, Text, x366 y52 w90 h30 vText4Status, Stop
; Generated using SmartGUI Creator 4.0
Gui, Show, x477 y208 h174 w478, New GUI Window
; 取代 hotkey
; 失敗,只能開始,不能停下
;Hotkey, %UserDefinedKey%, RepeatClick
return
GuiClose:
ExitApp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Function: 重複點擊 ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 參考 http://www.autohotkey.com/docs/FAQ.htm#repeat
; 預設熱鍵只有一個 thread,要有2個以上共存才能讓第2個 thread的flag 改
變
; 應該 2 就好? 為了之後可以有別的熱鍵使用?
#MaxThreadsPerHotkey 3
ThreadsIsRunning = false ; 記錄是否已啟動
$F12::
;RepeatClick:
#MaxThreadsPerHotkey 1
if ThreadsIsRunning ; This means an underlying thread is already
running the loop below.
{
ThreadsIsRunning := false ; Signal that thread's loop to stop.
GuiControl,Text, Text4Status,Stop
return ; End this thread so that the one underneath will resume
and see the change made by the line above.
}
; Otherwise:
ThreadsIsRunning := true
GuiControl,Text, Text4Status,Starting
;GuiControlGet, statusvalue,, Text4Status
;MsgBox %status%
;MsgBox %statusvalue%
; 取得delay time
GuiControlGet, delayvalue,, Slider4Delay
delayvalue:=delayvalue*delaymulti
;MsgBox, %delayvalue%
; 取得哪個按鈕被選中
; GuiControlGet 是得到該 radio 是否被選中(1,沒選中則為0)
GuiControlGet, Radio4LButtonChecked,, Radio4LButton
GuiControlGet, Radio4RButtonChecked,, Radio4RButton
;MsgBox %Radio4LButtonChecked%
if (Radio4LButtonChecked =1){
;GuiControlGet,keyselected,, Radio4LButton,Text
keyselected=LButton
}
else if (Radio4RButtonChecked =1){
;GuiControlGet,keyselected,, Radio4RButton,Text
keyselected=RButton
}
Loop
{
Send {%keyselected%}
Sleep, %delayvalue%
;MsgBox %delayvalue%
if not ThreadsIsRunning ; The user signaled the loop to stop
by pressing Win-Z again.
break ; Break out of this loop.
}
ThreadsIsRunning := false ; Reset in preparation for the next press
of this hotkey.
GuiControl,Text, Text4Status,Stop
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Function: 調整delay的slider ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SetDelayTime:
GuiControlGet, delayvalue,, Slider4Delay
delayvalue:=delayvalue*delaymulti
GuiControl, ,Text4Delay,delay: %delayvalue% ms
return
※ 引述《UndeadSion (UndeadSion)》之銘言:
: ※ 引述《n0tme (who did this?)》之銘言:
: : 一般的熱鍵啟動是
: : $F12::
: : 有沒有能讓使用者指定熱鍵的辦法?
: : 用以下的方法會錯誤
: : hotkey= F12
: : $%hotkey%::
: 可以用 Hotkey 命令,KeyName、Label 皆可為變數
: 範例如下
: KeyName = F12
: Label = F12
: Hotkey, %KeyName%, %Label%
: Return
: F12:
: ; 功能寫在這裡
: Return
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.109.223.225