Using variables

Get help with using AutoHotkey and its commands and hotkeys
carthagod
Posts: 16
Joined: 20 Oct 2017, 06:52

Using variables

20 Oct 2017, 07:07

Hi!

Just discovered AutoHotKey and it's fantastic!
I'm trying to write some scripts and I have a very basic problem: I don't understand how variables are supposed to work. I HAVE seen the page https://autohotkey.com/docs/Variables.htm but it doesn't help me.

In ording to test setting and retrieving a variable, I'm trying to set a certain value (ex:12) to a variable, then display it in a message box when hotkey pressed. Here's what I have:

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

MyVar:=12
^F4:: MsgBox, %MyVar%


If I do so, the Message box displays an empty value.

Can someone please explain more clearly than the documentation how variables are supposed to work?

Thanks !!
Best,
Thomas

NB : I'm not a dev nore a super-geek so don't hesitate to be very basic in your explanations. I do have some programming notions though, so not problem with the concept of variable itself.
Helgef
Posts: 2404
Joined: 17 Jul 2016, 01:02
Contact:

Re: Using variables

20 Oct 2017, 07:14

Hello and welcome.
There is nothing wrong with your script. It displays 12 in the message box. If that code is part of a larger script, you need to consider the auto execute section. Also, see the tutorial.
carthagod
Posts: 16
Joined: 20 Oct 2017, 06:52

Re: Using variables

21 Oct 2017, 03:14

OK I get it. Thanks a lot Helgef !

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Hellbent, Kamil KW, mast4rwang, nivek142, RozRoyal and 49 guests