【问题标题】:ahk hotkey profilesahk 热键配置文件
【发布时间】:2015-09-12 09:47:00
【问题描述】:

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

#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 将它们合并到一个脚本中,以选择当前处于活动状态的热键集。不幸的是,每次我运行脚本时,我都会不断收到“重复热键”错误(在 End 键上,如果这告诉你什么的话)。

我一直在网上搜寻,试图找到有人尝试同样的事情,但我一无所获。我在正确的轨道上吗?有没有可能?

感谢您的宝贵时间!

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 语句能解决这个问题。如果我可以随时使除一个以外的所有内容都处于非活动状态,我不明白为什么重复会成为问题。

标签: excel scripting autohotkey key-bindings vba


【解决方案1】:

您不能以幼稚的方式多次定义同一个热键,唯一的方法是使用#IfWinActive

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

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

【讨论】:

  • 感谢您的回复,抱歉让您度过了糟糕的一天。
【解决方案2】:

我知道您已经确定了答案,但如果您使用 AutoHotKey_L,则可以使用 #IF
#IF 的工作方式与 #IfWindowActive 类似,但随后使用常规 if 语句。
在这里您可以创建如下脚本:

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

附:如果你想发送 OK+,你可以用 SendRaw 来做,但你也可以用普通的 Send 来做。你可以在这里写:发送,OK+=
+ 移动下一个字符。 Shift+=+

【讨论】:

  • 非常感谢您的意见。以后我会牢记这一点!
猜你喜欢
  • 2018-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-19
  • 2018-10-10
  • 2013-10-21
  • 2014-05-25
  • 1970-01-01
相关资源
最近更新 更多