Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Example

#Persistent
fileName = H:\Data\Desktop\myfile.txt
return

^#Left::
FileDelete, %fileName%
return

^#Right::
FileDelete, %fileName%
FileAppend, %clipboard%, %fileName%
return

Right now it works with the #Persistent command but I have to put the #Persistent at the top of the file, which is inconvenient. If I remove the Persistent, it stops working.

share|improve this question
up vote 1 down vote accepted

Okay, apparently superuser is not the place to ask autohotkey questions :)

The autohotkey forum is quite active and I found the answer on the first search (Asked and answered yesterday). In my defense: Google didn't give me any relevant answer even after multiple search attempts.

maul.esel: Only the Global variables in the function you need: globalVar := "abc"

func()
{
    Global globalVar
    MsgBox %globalVar%
}

Latest AHK supports so-called "super-globals":

global globalVar := "abc"
func()
{
    MsgBox %globalVar%
}

The original thread: globals not global

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .