好吧,所以我有这部分代码:
SetGrenade:
gui, 2: Submit, NoHide
if Flashbang
CurrentNade := "send 4|Sleep 20|send 4|Sleep 1000|Send {LButton}|Sleep 100|send 1"
else if Smoke
CurrentNade := "Send 4|Sleep 20|Send 4|Sleep 20|Send 4|Sleep 1000|Send {LButton}|Sleep 100|Send 1"
else ;He
CurrentNade := "send 4|Sleep 1000|Send {LButton}|Sleep 100|Send 1"
return
(热键是xbutton1) 一切都很好,除了这个'|'垂直条用于分隔命令但它也放置一个空格。例如: 当用户点击鼠标上的xbutton1时,用户选择选项1(Flashbang): 4 4 1 不 441(我跳过了睡眠和点击,因为它们没有显示在记事本中。)
有没有办法解决这个问题? 我尝试删除垂直条(|),但然后代码被放置为文本。 请帮忙, 问候, 亚当
编辑: 完整代码:
#SingleInstance force
SetWorkingDir %A_ScriptDir%
CurrentNade := 0
;GUI
Gui, Show, w200 h300, sAHK v0.2
Gui, Add, checkbox, gAutoNade vAutoNade cBlue, Enable Auto-Grenade
Gui, Add, button, vSettingsButton gSettings, View Settings
Gui, Add, button, gUpcoming, View Upcoming Functions
Hotkey, xbutton1, CurrentNade, Off
Gui, 2:Hide
Gui, 2:Add, Text, cBlue, Auto-Grenade To Throw:
Gui, 2:Add, radio, gSetGrenade vFlashbang, Flashbang
Gui, 2:Add, radio, gSetGrenade vSmoke, Smoke Grenade
Gui, 2:Add, radio, gSetGrenade vHe, Explosive Grenade
OnExit, GuiClose
return
;END GUI
;EXPRESSION
Settings:
WinGetPos, guiPosX, guiPosY,,, A
guiPosX := guiPosX + 200
Gui, 2:Show, x%guiPosX% y%guiPosY% Restore
Gui, 2:Show, w200 h300, Script Settings
return
AutoNade:
gui, Submit, NoHide
if AutoNade
{
SoundPlay, %A_ScriptDir%/snd-EN/SL.wav
Hotkey, xbutton1, On
}
else
{
Hotkey, xbutton1, Off
SoundPlay, %A_ScriptDir%/snd-EN/ST.wav
}
return
CurrentNade:
;MsgBox %CurrentNade%
Loop, Parse, CurrentNade,|
{
if instr(A_LoopField,"send")
send % SubStr(A_LoopField, 5)
else
Sleep SubStr(A_LoopField, 6)
}
return
SetGrenade:
gui, 2: Submit, NoHide
if Flashbang
CurrentNade := "send 4|Sleep 20|send 4|Sleep 1000|Send {LButton}|Sleep 100|send 1"
else if Smoke
CurrentNade := "Send 4|Sleep 20|Send 4|Sleep 20|Send 4|Sleep 1000|Send {LButton}|Sleep 100|Send 1"
else ;He
CurrentNade := "send 4|Sleep 1000|Send {LButton}|Sleep 100|Send 1"
return
Upcoming:
Gui, Upcoming:Add, Text,, 1. Overall impovements, UI updates, bug fixes and small changes
Gui, Upcoming:Add, Text,, 2. Bunny Hop
Gui, Upcoming:Add, Text,, 3. 180 turnaround
Gui, Upcoming:Add, Text,, 4. Recoil Reducer (RCS)
Gui, Upcoming:Show
return
GuiClose:
ExitApp
;END EXPRESSION
答案 0 :(得分:0)
substr
从1开始:
对于StartingPos,指定1从第一个字符开始
只需将代码中的索引增加1:
if instr(A_LoopField,"send")
send % SubStr(A_LoopField, 6)
else
sleep SubStr(A_LoopField, 7)
}