Code: Select all
~^c::
SoundPlay, C:\Sound.wav
KeyWait, ^c, T.5
Run, % ErrorLevel ? "D:\Command1" : "D:\Command2"
KeyWait, ^c
return
Code: Select all
~^c::
SoundPlay, C:\Sound.wav
KeyWait, ^c, T.5
Run, % ErrorLevel ? "D:\Command1" : "D:\Command2"
KeyWait, ^c
return
Thanks! I've made an edit to the code and have another question - can I get the delayed command (^x) to play a sound in addition to the initial sound? I tried it with AND SoundPlay but got an error.boiler wrote: ↑25 Jun 2021, 05:24KeyWait is looking for a single key to be identified, not a key combination. Change it to just c. That doesn’t mean you're hotkey has to change. It just means it won’t be waiting for Ctrl to be released. If you really want to wait for both, you can follow it with another KeyWait.
Code: Select all
~^c::
SoundPlay, C:\Sound.wav
KeyWait, c, T.5
SendInput, % ErrorLevel ? "^x" AND SoundPlay, C:\Sound.wav: "^c"
KeyWait, c
return
Code: Select all
~^c::
SoundPlay, C:\Sound.wav
KeyWait, c, T.5
if ErrorLevel
{
SendInput, ^x
SoundPlay, C:\Sound.wav
}
else
SendInput, ^c
KeyWait, c
return
Thanks again, ive made another version that pastes text on its first command and opens a folder on its second command - the first command is running correctly, but the folder command does not triggerboiler wrote: ↑27 Jun 2021, 06:11You can’t use the ternary operator in this case — at least not unless you create a function that would be called as part of an expression instead of trying to insert a command. Just use regular if/else:Code: Select all
~^c:: SoundPlay, C:\Sound.wav KeyWait, c, T.5 if ErrorLevel { SendInput, ^x SoundPlay, C:\Sound.wav } else SendInput, ^c KeyWait, c return
I would think you don’t really want to use ~ before the hotkey in this case because that would cause ^c to be sent every time (actually just allowing the natural one to stand), sometimes followed by ^x and other times followed by a second ^c. And I would think you would want to replace it with a $ to prevent the hotkey from triggering itself when you send ^c. See Hotkey Modifier Symbols.
Code: Select all
$<^<!1::
SoundPlay, D:\SOUND.WAV
KeyWait, 1, T.5
if ErrorLevel
{
Run, D:\FOLDER
SoundPlay, D:\SOUND.WAV
KeyWait, 1
}
else
SendRaw TEXT
Sleep 250
Send {Enter}
Code: Select all
$<^<!1::
SoundPlay, D:\SOUND.WAV
KeyWait, 1, T.5
if ErrorLevel
{
Run, D:\FOLDER
SoundPlay, D:\SOUND.WAV
KeyWait, 1
}
else
{
SendRaw TEXT
Sleep 250
Send {Enter}
}
return