Easy Spacebar script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Aztekke

Easy Spacebar script

24 Oct 2014, 01:39

Hello... i wanted to make a easy script whitch contains a variable and a if else query...
The script should ask for the number in the variable and send a key. After that it should change the variable to two.
So when you hit spacebar again it should produce a different key and set the variable to three. But for some reason the script is not working...
Any idea what im doing wrong?

Code: Select all

~^Space::

spacecount = 1

if (spacecount = 1)
{
	send {A}
	spacecount = 2
}

if (spacecount = 2)
{
	send {B}
	spacecount++
	return
}
It is producing A and B at the same time :headwall: can you help me
Greetings Aztekke :wave:
Guest

Re: Easy Spacebar script

24 Oct 2014, 02:04

Try this

Code: Select all

~^Space::
spacecount = 1
if (spacecount = 1)
{
    send {A}
    spacecount = 2
}
else if (spacecount = 2) ; added an [b]else[/b] here
{
    send {B}
    spacecount++
    return
}
Guest

Re: Easy Spacebar script  Topic is solved

24 Oct 2014, 02:31

Guest wrote:Try this

Code: Select all

~^Space::
spacecount = 1
if (spacecount = 1)
{
    send {A}
    spacecount = 2
}
else if (spacecount = 2) ; added an [b]else[/b] here
{
    send {B}
    spacecount++
    return
}

Hmm, no sorry. it's only producing the first and ignores the second query...
Guest

Re: Easy Spacebar script

24 Oct 2014, 02:40

Guest wrote:Try this

Code: Select all

~^Space::
spacecount = 1
if (spacecount = 1)
{
    send {A}
    spacecount = 2
}
else if (spacecount = 2) ; added an [b]else[/b] here
{
    send {B}
    spacecount++
    return
}
I DID IT :superhappy:

The problem was that the var was set to one everytime i hit Ctrl+Space so i just moved the Var out of the function. Also there was a mistake with my second var. It is supposed to set the var to 1 and not to 3 ^^

Thanks anyway for help. I think the "else if" was also a mistake i did :)

Here's the code:

Code: Select all

spacecount = 1

~^Space::
if (spacecount = 1)
{
    send {A}
    spacecount++
}
else if (spacecount = 2)
{
    send {B}
    spacecount = 1
}

return
Guest

Re: Easy Spacebar script

24 Oct 2014, 03:40

Code: Select all

~^Space::
spacecount:=!spacecount
if (spacecount)
    send {B}
else
    send {A}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 185 guests