Im dumb pls hulp Toggle help Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Squire_
Posts: 4
Joined: 15 Aug 2017, 03:42

Im dumb pls hulp Toggle help

15 Aug 2017, 03:53

So I'm newbie to this script language, the first part works where it toggles between Control+Shift+F2 & Control+Shift+F3, Via a single shortcut (Control+Shift+F1), which are shortcuts bound to a Xonarr Switch, which switch outputs between headphone jack and speaker jacks (just changes Pre-configured profiles in xonarr switch)

What I want to add to this is a just SoundPlay to play on toggle state 1 and then another sound on state 0, thats I'm trying to do anyway, so when it switches between F2 and F3 it plays one sound for f2 and another for f3.

Any advice would be mucho appreciated!

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Toggle := 1 

^+f1::Send, % Toggle = 1 ? ( "^+{F2}", Toggle := 0 ) : ( "^+{F3}", Toggle := 1 )

if Toggle := 1 ( SoundPlay, "d:\speakers.mp3", wait )
if Toggle := 0 ( SoundPlay, "d:\headphones.mp3", wait )

User avatar
thenasos
Posts: 79
Joined: 10 Nov 2015, 10:00

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 06:55

You are trying to assign values of "Toggle" when you should be comparing them

Code: [Select all] [Download] GeSHi © Codebox Plus

if (Toggle = 1) 
SoundPlay, "d:\speakers.mp3", wait
if (Toggle = 0)
SoundPlay, "d:\headphones.mp3", wait
Shrek is love...
Squire_
Posts: 4
Joined: 15 Aug 2017, 03:42

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 08:12

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Toggle := 0

^+f1::Send, % Toggle = 1 ? ( "^+{F2}", Toggle := 0 ) : ( "^+{F3}", Toggle := 1 )

if (Toggle = 1)
SoundPlay, "d:\speakers.mp3", wait
if (Toggle = 0)
SoundPlay, "d:\headphones.mp3", wait


Thanks @thenasos !
ok so, still switching but...no sounds? what am I missing ?
Guest

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 08:33

Look at the https://autohotkey.com/docs/Tutorial.htm#s2 again, what do you notice with all the hotkey examples.
You need to executing multiple lines of code, so you need to start your first command ... ?
Answer is explicitly visible here https://autohotkey.com/docs/Hotkeys.htm#Intro ;)
Squire_
Posts: 4
Joined: 15 Aug 2017, 03:42

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 10:16

Guest wrote:Look at the https://autohotkey.com/docs/Tutorial.htm#s2 again, what do you notice with all the hotkey examples.
You need to executing multiple lines of code, so you need to start your first command ... ?
Answer is explicitly visible here https://autohotkey.com/docs/Hotkeys.htm#Intro ;)


So I spent around 30min, trying "return" in different places, #if instead of just if. clearly I'm not seeing it, because nothing is really changing
any other hints xD?
Only thing I see is the return, only common thing I see that I'm missing?


Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Toggle := 0

^+f1::Send, % Toggle = 1 ? ( "^+{F2}", Toggle := 0 ) : ( "^+{F3}", Toggle := 1 )

if (Toggle = 1)
SoundPlay, "d:\speakers.mp3", wait
if (Toggle = 0)
SoundPlay, "d:\headphones.mp3", wait
return
User avatar
Xtra
Posts: 815
Joined: 02 Oct 2015, 12:15

Re: Im dumb pls hulp Toggle help  Topic is solved

15 Aug 2017, 10:54

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
tidbit
Posts: 985
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 10:57

soundplay is a command, not a function. probably don't want quotes around the path
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
Squire_
Posts: 4
Joined: 15 Aug 2017, 03:42

Re: Im dumb pls hulp Toggle help

15 Aug 2017, 11:22

Thanks guys!
Works now :D!

Return to “Ask For Help”

Who is online

Users browsing this forum: clow_yakayi, darkzbaron, Rohwedder, Yahoo [Bot] and 73 guests