One input for multiple outputs Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TheMainEvent
Posts: 3
Joined: 17 Nov 2019, 17:39

One input for multiple outputs

17 Nov 2019, 17:53

I'm trying to write a script that when active will display a message saying it's active, and when paused it will display a message saying that it's paused and pause the script. The active message works, but the paused message populates an error.
"Error: Target label does not exist." as well as "' 020:Goto,toggle=1 ? "a" : (toggle=2) ? "b" "'
i have no idea what im doing wrong here.

Code: Select all

t::
toggle++

If toggle>2

	toggle=1

goto, % toggle=1 ? "a" : toggle=2 ? "b"

return



a:

msgbox, Active

return



b:
suspend
msgbox, Paused

return
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: One input for multiple outputs

17 Nov 2019, 18:11

TheMainEvent wrote:
17 Nov 2019, 17:53
The active message works, but the paused message populates an error.
"Error: Target label does not exist." as well as "' 020:Goto,toggle=1 ? "a" : (toggle=2) ? "b" "'
i have no idea what im doing wrong here.
all ternary expressions MUST have an else clause

yours translates to:

Code: Select all

if (toggle=1)
   goto a
else
   if (toggle = 2)
      goto b
   ; missing else here
so either:

Code: Select all

goto, % (toggle=1) ? "a" : (toggle=2) ? "b" : ""
;or
goto, % (toggle=1) ? "a" : "b"


TheMainEvent
Posts: 3
Joined: 17 Nov 2019, 17:39

Re: One input for multiple outputs

17 Nov 2019, 22:04

guest3456 wrote:
17 Nov 2019, 18:11
TheMainEvent wrote:
17 Nov 2019, 17:53
The active message works, but the paused message populates an error.
"Error: Target label does not exist." as well as "' 020:Goto,toggle=1 ? "a" : (toggle=2) ? "b" "'
i have no idea what im doing wrong here.
all ternary expressions MUST have an else clause

yours translates to:

Code: Select all

if (toggle=1)
   goto a
else
   if (toggle = 2)
      goto b
   ; missing else here
so either:

Code: Select all

goto, % (toggle=1) ? "a" : (toggle=2) ? "b" : ""
;or
goto, % (toggle=1) ? "a" : "b"

Thank you for your reply, but now it will only suspend the script, and wont allow me to restart it.

Code: Select all

if (toggle=1)
   goto a
else
   if (toggle = 2)
      goto b

return



a:
Winset, AlwaysOnTop, On
suspend
msgbox , Paused

return



b:
Winset, AlwaysOnTop, On
suspend
msgbox, Active

return
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: One input for multiple outputs  Topic is solved

17 Nov 2019, 23:38

you didn't do what i said.. use your original script and replace your goto ternary line with one of the ones i gave you

TheMainEvent
Posts: 3
Joined: 17 Nov 2019, 17:39

Re: One input for multiple outputs

17 Nov 2019, 23:44

guest3456 wrote:
17 Nov 2019, 23:38
you didn't do what i said.. use your original script and replace your goto ternary line with one of the ones i gave you
i thought i had applied it properly, and i guess i was wrong, i apologize, im still new to ahk. I reapplied it, and now it works. thank you for your help

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 104 guests