2013-03-01 130 views
1

這是我的工作代碼,以防萬一這可以幫助其他人!ahk熱鍵配置文件

#Warn ; Enable warnings to assist with detecting common errors. 
#SingleInstance FORCE 

GUI, Add, Radio, vInventoryCompare, Compare Inventories 
GUI, Add, Radio, vProductionSheet, Production Spreadsheet Stuff 
GUI, Add, Radio, vInventorySheet, Inventory Sheet Stuff 
GUI, Add, Radio, vStop, Disable Hotkeys 
GUI, Add, Button, default xm, Set ; xm puts it at the bottom left corner. 
GUI, Show 

ButtonSet: 
GUI, Submit, NoHide 
Return 




Insert:: ; paste values 
send, {alt}hvv 
return 

; ---------------------------------- 

Home:: 
If InventoryCompare = 1 ; font size up 3 times 
{ 
Send, {enter}{up} 
Loop 3 
{ 
Send, {alt}hfg 
} 
return 
} 
Else If ProductionSheet = 1 ; Recheck 
{ 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{right 3}{enter} 
Send, {F2}{left 5} 
Send, R-{enter}{up} 
return 
} 
Else If Stop = 1 
{ 
send {Home} 
Return 
} 
Return 

; ---------------------------------- 

End:: 
If InventoryCompare = 1 ; autocounter for bcg 
{ 
Sendraw, =SUMIF($A$8:$A$38,A3,$F$8:$F$38) 
send {enter} 
return 
} 
Else If ProductionSheet = 1 ; discard 
{ 
Send, D{enter}{up} 
Send, ^b 
return 
} 
Else If InventorySheet = 1 ; write ok+ and tab 
{ 
send {tab} 
Sendraw, ok+ 
send {tab} 
return 
} 
Else If Stop = 1 
{ 
send {end} 
Return 
} 
Return 

; ---------------------------------- 

PgUp:: 
If InventoryCompare = 1 ; green bg with white text 
{ 
Send, {alt}hh{down 6}{right 5}{enter} ; bg green 
Send, {alt}hfc{down}{left 4}{enter} ; font white 
return 
} 
Else If ProductionSheet = 1 ; ok+ coloring 
{ 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{right}{enter} 
return 
} 
Else If InventorySheet = 1 ; write ok and tab 
{ 
send {tab} 
Sendraw, ok 
send {tab} 
return 
} 
Else If Stop = 1 
{ 
send {PgUp} 
Return 
} 
Return 

; ---------------------------------- 

PgDn:: 
If InventoryCompare = 1 ; red bg with white text 
{ 
Send, {alt}hh{down 6}{right}{enter} ; bg red 
Send, {alt}hfc{down}{left 4}{enter} ; font white 
return 
} 
Else If ProductionSheet = 1 ; ok- coloring 
{ 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{left 3}{enter} 
return 
} 
Else If InventorySheet = 1 ; write ok- and tab 
{ 
send {tab} 
Sendraw, ok- 
send {tab} 
return 
} 
Else If Stop = 1 
{ 
send {PgDn} 
Return 
} 
Return 

; ---------------------------------- 

PrintScreen:: 
If InventoryCompare = 1 ; Break merged top cell of old inventories 
{ 
send {F2} ; enter cell 
sleep 200 
send +{left 50} ; select name 
sleep 200 
send ^x ; cut name 
sleep 200 
send {enter}{up} ; reselect cell 
sleep 200 
send {alt}hmu ; break merged cells 
sleep 200 
send {down}{f2}^v{enter} ; paste name 
return 
} 
Else If Stop = 1 
{ 
send {PrintScreen} 
Return 
} 
Return 


GuiClose: 
ExitApp 

老問題: 我有3套,我想使用具有單選按鈕(或其他裝置)的GUI選擇哪個熱鍵組當前處於活動狀態,以合併成單一腳本熱鍵綁定宏。不幸的是,每次運行腳本時,我總是收到「重複快捷鍵」錯誤(在結束鍵上,如果有的話)。

我一直在網上搜尋試圖找到某人試圖做同樣的事情,但我什麼都沒有提出。我在正確的軌道上嗎?它甚至有可能嗎?

謝謝你的時間!

GUI, Add, Radio, vInventoryCompare, Compare Inventories 
GUI, Add, Radio, vProductionSheet, Production Spreadsheet Stuff 
GUI, Add, Radio, vInventorySheet, Inventory Sheet Stuff 
GUI, Add, Radio, vDisable, Disable hotkeys 
GUI, Show 

GuiClose: 
ExitApp 

IF ErrorLevel 
ExitApp 

Insert:: ; paste values 
send, {alt}hvv 
return 

IF %vInventoryCompare% = 1 
{ 
End:: ; autocounter for bcg 
Sendraw, =SUMIF($A$8:$A$38,A3,$F$8:$F$38) 
send {enter} 
return 

Home:: ; font size up 3 times 
Send, {enter}{up} 
Loop 3 
{ 
Send, {alt}hfg 
} 
return 

PgUp:: ; green bg with white text 
Send, {alt}hh{down 6}{right 5}{enter} ; bg green 
Send, {alt}hfc{down}{left 4}{enter} ; font white 
return 

PgDn:: ; red bg with white text 
Send, {alt}hh{down 6}{right}{enter} ; bg red 
Send, {alt}hfc{down}{left 4}{enter} ; font white 
return 

PrintScreen:: ; Break merged top cell of old inventories 
send {F2} ; enter cell 
sleep 200 
send +{left 50} ; select name 
sleep 200 
send ^x ; cut name 
sleep 200 
send {enter}{up} ; reselect cell 
sleep 200 
send {alt}hmu ; break merged cells 
sleep 200 
send {down}{f2}^v{enter} ; paste name 
return 

} 

IF %vProductionSheet% = 1 
{ 
End:: ; discard 
Send, D{enter}{up} 
Send, ^b 
return 

Home:: ; Recheck 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{right 3}{enter} 
Send, {F2}{left 5} 
Send, R-{enter}{up} 
return 

PgUp:: ; ok plus coloring 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{right}{enter} 
return 

PgDn:: ; ok minus coloring 
Send, {enter}{up} 
Send, {alt}hfc{down 7}{left 3}{enter} 
return 
} 

IF %vInventorySheet% = 1 
{ 
End:: 
send {tab} 
Sendraw, ok+ 
send {tab} 
return 

PgUp:: 
send {tab} 
Sendraw, ok 
send {tab} 
return 

PgDn:: 
send {tab} 
Sendraw, ok- 
send {tab} 
return 
} 

IF %vDisable% = 1 
{ 
} 
+0

你知道重複的意思嗎? – 2013-03-01 20:54:01

+0

你真好。是的,我希望那些IF聲明能夠解決這個問題。我不明白爲什麼重複應該是一個問題,如果我可以在任何時候使所有但不活躍的話。 – user1988168 2013-03-01 20:57:35

回答

0

你不能多次定義相同的熱鍵你在做一個簡單的方式,只有這樣才能讓他們使用#IfWinActive

我建議您不要使用多個熱鍵和多個if語句,而要設置一個熱鍵並將所有這些if語句放入其中。

hotkey:: 
    if(statement) 
    { 
     do this; 
    } 
    else if(statement) 
    { 
     do that; 
    } 
    else... 
return 
+0

感謝您的迴應,抱歉您今天過得很糟糕。 – user1988168 2013-03-01 21:05:31

+0

@ user1988168我其實不是:),我只是指着顯而易見的,希望你會學習你自己。 – 2013-03-01 21:06:43

+0

哎呀使用了錯誤的文本字段... – user1988168 2013-03-01 23:33:54

0

我知道你在回答解決,但如果你使用AutoHotKey_L你可以使用#IF
#IF的作品類似#IfWindowActive,但隨後使用常規if語句。
在這裏,你可以創建一個腳本,如:

#IF (vInventoryCompare = 1) 
    Home:: 
     Send.... 
     . 
     . 
    Return 
#IF (vProductionSheet = 1) 
    Home:: 
     Send.... 
     . 
     . 
    Return 
#IF 

附:如果你想發送OK +,你可以使用SendRaw來完成,但你也可以使用常規Send來完成。在這裏你可以寫下:發送,OK + =
+改變下一個字符。 Shift + =+

+0

感謝您的輸入。我將銘記未來! – user1988168 2013-03-01 23:39:45