syntax with referenced variables Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Danniique
Posts: 6
Joined: 11 Feb 2018, 02:11

syntax with referenced variables

13 Feb 2018, 06:34

I've been trying to adopt this line of code I found elsewhere on the AHK forums:

Code: Select all

	Send % m ?"{Volume_Up}":"{Volume_Down}"

Into something along the lines of:

	send % "{Volume_Up}"

which works fine, but using a referenced variable, like:

	Vu={Volume_Up}
	send % "%Vu%"

but this just sends the raw text %Vu%, so I try instead perhaps swapping the quotes to be included with the variable:

	Vu="{Volume_Up}"
	send % %Vu%
but this still doesn't work, with the error saying it contains Illegal characters, yet when I inspect the variable it contains what I want it to. I've tried heaps of other variations but I just can't get it to work.

Is it even possible to do?
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: syntax with referenced variables  Topic is solved

13 Feb 2018, 07:11

try this

Code: Select all

	Vu:="{Volume_Up}"
	send %Vu%

	Vu:="{Volume_Up}"
	send % Vu

	Vu={Volume_Up}
	send %Vu%
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
Danniique
Posts: 6
Joined: 11 Feb 2018, 02:11

Re: syntax with referenced variables

13 Feb 2018, 11:31

Blackholyman wrote:try this

Code: Select all


Vu:="{Volume_Up}"
	send % Vu
	
Thank you Blackholyman!

So, the problem as you have no doubt seen was my use of the = equals operator instead of the := assign operator. I must say though, I'm a bit confused though as to why assign work and equals doesn't.
As your other two examples show, when not forcing the expression in the Send command with send % [...], both operators work equally. Grrrr. I can't believe one little : sign ended up costing me so much time.

On second thoughts, yes, I can believe it; otherwise debugging wouldn't be the endless party that puts the F in your Fun all night long.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Rohwedder and 144 guests