Changing Variables :Q

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
imnotevrensparta
Posts: 2
Joined: 11 Aug 2018, 14:38

Changing Variables :Q

11 Aug 2018, 14:43

When I press d I want the variable to switch to d same for a.

I don't want to use hotkeys because it disables the users key input so yeah :Q

Code: Select all

CurrentKey = a


while GetKeyState("d", "P")
{
Send, d
CurrentKey = d
}
return

while GetKeyState("a", "P")
{
Send, a
CurrentKey = a
}
return
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Changing Variables :Q

11 Aug 2018, 16:12

I have no idea what you're talking about, sorry.
But it's not true that hotkeys disable user key input.
This is why there is ~.
If you use this script, Ctrl+C would still copy:

Code: Select all

~^c:: ; Copy
MsgBox, Something was copied!
return
You do know when and why to use variables?
If you want to assign a variable to a key, you could simply do:

Code: Select all

~a::
currentKey = a
return

~d::
currentKey = d
return

F1::
MsgBox, %currentKey%
return
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
imnotevrensparta
Posts: 2
Joined: 11 Aug 2018, 14:38

Re: Changing Variables :Q

11 Aug 2018, 17:10

Scr1pter wrote:I have no idea what you're talking about, sorry.
But it's not true that hotkeys disable user key input.
This is why there is ~.
If you use this script, Ctrl+C would still copy:

Code: Select all

~^c:: ; Copy
MsgBox, Something was copied!
return
You do know when and why to use variables?
If you want to assign a variable to a key, you could simply do:

Code: Select all

~a::
currentKey = a
return

~d::
currentKey = d
return

F1::
MsgBox, %currentKey%
return
Regards

Hey, I'm a bit ignorant to this language and didn't really read over everything I should have.
Thanks for the fix and also clarification. :Q

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb and 380 guests