Send, sse a variable for number of repeats for key Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
dpgtbs
Posts: 2
Joined: 27 Mar 2023, 16:54

Send, sse a variable for number of repeats for key

Post by dpgtbs » 27 Mar 2023, 17:04

I am trying to use a variable to specify the number of times a key is repeated with send. It is somewhat similar to viewtopic.php?t=40977 but I am using V2. Also, I am trying to use a global variable since I want to use the same one in each function. Here is the code I have so far but the tab does not work in "send". The reason I'm doing this is I have 6 different functions and the tab count is the same for each but can change sometimes. So I wanted a way to make that change just one place instead of all 6. Earlier I had the literal number on each one and that worked, but would require changing each of the numbers when I want to change.

Code: Select all

GlobalTabCount := 7

F3::
{
    Send "000{Tab GlobalTabCount}"
}

F2::
{
    Send "00{Tab GlobalTabCount}"
}

User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: Send, sse a variable for number of repeats for key  Topic is solved

Post by mikeyww » 27 Mar 2023, 17:26

Welcome to this AutoHotkey forum!

To use expressions, you don't want to make your variable into a literal string of text.

Code: Select all

#Requires AutoHotkey v2.0
GlobalTabCount := 7
F3::Send '000{Tab ' GlobalTabCount '}'

dpgtbs
Posts: 2
Joined: 27 Mar 2023, 16:54

Re: Send, sse a variable for number of repeats for key

Post by dpgtbs » 28 Mar 2023, 09:48

Thanks a lot! That works. It makes total sense to me now from my VBA programming experience, I just hadn't translated it over.

Post Reply

Return to “Ask for Help (v2)”