Excel ahk热键配置文件

Excel ahk热键配置文件,excel,scripting,autohotkey,key-bindings,vba,Excel,Scripting,Autohotkey,Key Bindings,Vba,这是我的工作代码,以防这对其他人有帮助 #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, vInve

这是我的工作代码,以防这对其他人有帮助

#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组keybind宏,我想使用带有单选按钮(或其他方式)的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
{
}

你不能以一种天真的方式多次定义同一个热键,唯一的方法就是使用它们

我建议不要制作多个热键和多个if语句,而是制作一个热键并将所有if语句放入其中

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

我知道你已经确定了答案,但是如果你使用自动热键,你可以使用
\if

#IF
的工作原理类似于
#IfWindowActive
,但随后使用常规IF语句。
在这里,您可以创建如下脚本:

#IF (vInventoryCompare = 1)
    Home::
        Send....
        .
        .
    Return
#IF (vProductionSheet = 1)
    Home::
        Send....
        .
        .
    Return
#IF
另外,如果您想发送OK+,可以使用SendRaw,但也可以使用常规发送。您可以在这里写下:Send,OK+=

+移动下一个字符。Shift+=is+

你知道复制是什么意思吗?你真好。是的,我希望那些IF语句能解决这个问题。如果我可以在任何时候使除一个以外的所有设备处于非活动状态,我不明白为什么复制会成为一个问题。感谢您的回复,很抱歉您今天过得不好。@user1988168我不是真的:),我只是指出了明显的问题,希望您能够了解自己。非常感谢您的输入。我以后会记住的!