transfer variables from autoit

Get help with using AutoHotkey and its commands and hotkeys
Guest

transfer variables from autoit

14 Dec 2017, 12:38

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





Can you help me plox?
How can I transfer it from autoit to ahk?
I want to have a set of variables
I want to put them in clipboard and send one by one starting with a number that I set in $i. If I set 0 it sends all variables, if I set 8 it sends to last variables.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: transfer variables from autoit

14 Dec 2017, 13:57

do you mean convert that code into AHK? or send those variables to an AHK script?
if the first, this should be the equivalent:

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

name := ("adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre")
for i, v in name {
Clipboard := v
Send, +{INSERT}
}
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
Guest

Re: transfer variables from autoit

15 Dec 2017, 04:13

KuroiLight wrote:do you mean convert that code into AHK? or send those variables to an AHK script?
if the first, this should be the equivalent:

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

name := ("adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre")
for i, v in name {
Clipboard := v
Send, +{INSERT}
}

Thank you but it didn't send anything and it didn't put anything to clipboard.
just me
Posts: 5459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: transfer variables from autoit

15 Dec 2017, 06:33

You need to use square brackets to declare an array:

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

name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"]
Guest

Re: transfer variables from autoit

15 Dec 2017, 06:56

just me wrote:You need to use square brackets to declare an array:

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

name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"]

Thank you. How can I make it send starting from 3rd variable for example?
Guest

Re: transfer variables from autoit

15 Dec 2017, 08:54

BoBo wrote:If (index > 2) ?

Sorry, I don't know what it means.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: transfer variables from autoit

15 Dec 2017, 09:52

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

name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"]
for i, v in name {
If (i > 2) {
Clipboard := v
Send, +{INSERT}
}
}
Not tested. Unfortunately that's quite unflexible. Embeding this within a function + using a variable would be a better approach.
Guest

Re: transfer variables from autoit

15 Dec 2017, 10:34

BoBo wrote:

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

name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"]
for i, v in name {
If (i > 2) {
Clipboard := v
Send, +{INSERT}
}
}
Not tested. Unfortunately that's quite unflexible. Embeding this within a function + using a variable would be a better approach.

Thank you. Is there a chance to have my variables numbered like in my autoit code? I have hundreds of them. I want to enter a number so sending starts with a variable that I choose and ends with the last one.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: transfer variables from autoit

15 Dec 2017, 11:08

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

$name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"] ; the hardcoded array. It shouldn't be a problem to parse AU3 arrays adding its content to a variable on the fly instead.
Random, i, 1, $name.MaxIndex() ; creating a random number of iterations for testing
Loop % i ; looping that random number of iterations
MsgBox % "We'll check the content of " . i . " vars.`nThis is the " A_Index . ". one: " . $name[A_Index] ; getting all array elements based on the number of iterations
SoundBeep
MsgBox % This is the content of the 5th array element: $name[5] ; getting a single array element by its number/position within the array
Not tested.

There are definitely more sophisticated methods available. But the following one (that lies within my abilities) should do the trick ...

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

Hope that helps.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: transfer variables from autoit

15 Dec 2017, 13:52

just me wrote:You need to use square brackets to declare an array:

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

name := ["adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre"]

my mistake, I ment name := Array("adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre")
Guest wrote:Thank you. Is there a chance to have my variables numbered like in my autoit code? I have hundreds of them. I want to enter a number so sending starts with a variable that I choose and ends with the last one.

AHK arrays are indexed, starting from 1.

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

SendFromIndex(n) {
name := Array("adf", "zcxv", "agf", "zxcv", "adsf", "qtq", "dfsg", "cbvn", "fgjh", "ytre")
for i, v in name {
if(i >= n) {
Clipboard := v
Send, +{INSERT}
}
}
}
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]

01/24/18

Guest

Re: transfer variables from autoit

15 Dec 2017, 14:41

KuroiLight wrote:AHK arrays are indexed, starting from 1.

I mean I have to count variables before inputting my number. Is there a way to assign numbers to them like in my autoit code?
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: transfer variables from autoit

15 Dec 2017, 15:39

Using KuroiLight's code (from above) + researching if an option exists to use the AU3 code with only minor additions/changes we/I ended up with this ... and yes, it's working! :thumbup:

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

Hope that helps. :ugeek:
https://autohotkey.com/docs/Objects.htm ... ple_Arrays
Guest

Re: transfer variables from autoit

16 Dec 2017, 04:17

BoBo wrote:

Thank you! What's the difference between this and your previous version?

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


Both seem to work fine.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: transfer variables from autoit

16 Dec 2017, 08:08

Gast wrote:
BoBo wrote:

Thank you! What's the difference between this and your previous version?

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


Both seem to work fine.
As you can see, the array has been set to act globaly, while at the other script the array is handed over within the function call.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: transfer variables from autoit

17 Dec 2017, 11:22

and that his will start index at 0.
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]

01/24/18


Return to “Ask For Help”

Who is online

Users browsing this forum: Cuadrix and 71 guests