How do I sum a digit to an integer?

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

How do I sum a digit to an integer?

20 Sep 2017, 06:51

My script has to repeat itself for 1156 times, and for everytime it repeats I need it to sum by 1 an integer, until it ends.

Code: Select all

Loop 1156
var:= 11186
{
    var+=1
    ToolTip % var
    Sleep, 85
    
    SendInput {Raw}11186
    SendInput {Raw}File 11186
    SendInput {Raw}11186
}
return ;
So in the next loops I need it to be 11187, 11188... and so on.

The way I put it isn't working, any ideas?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: How do I sum a digit to an integer?

20 Sep 2017, 07:42

Example

Code: Select all

global MyCounterVar := 11186

loop 1156
{
    MsgBox % MyCounterVar
    MyCounterVar++
    sleep 85
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
strid

zona remember

20 Sep 2017, 08:05

jNizM wrote:Example

Code: Select all

global MyCounterVar := 11186

loop 1156
{
    MsgBox % MyCounterVar
    MyCounterVar++
    sleep 85
}
Hi NizM, that isn't working either.

This script will automate the process to upload a bunch of PDFs to a site, the page where I upload them has fields that need to be filled, also it can upload only file by file, it goes like this:

[*]fill field
[*]fill field
[*]11186
[*]File 11186
[*]11186
[*]upload
[*]insert a new file

Then it repeats, so the next file will be the 11187. The script works fine, except for the part that I especified.
strid

Re: How do I sum a digit to an integer?

20 Sep 2017, 08:41

These are the fields that will be filled: https://i.imgur.com/uvOOUWz.jpg

Here's the whole code:

Code: Select all

	global MyCounterVar := 11186

loop 1156
{
    ToolTip % MyCounterVar
    MyCounterVar++
    sleep 85

	MouseMove, 572, 485, 5
	Click 2
	Sleep, 1000
	SendInput {Raw}2013
	Sleep, 1000

	SendInput {Tab}
	Sleep, 1000
	SendInput {Raw}11186

	Sleep, 1000
	SendInput {Tab}
	Sleep, 1000
	SendInput {Raw}File n. 11186
	
	Sleep, 1000
	SendInput {Tab}
	Sleep, 1000
	SendInput {Raw}.

	Sleep, 1000
	SendInput {Tab}
	Sleep, 1000
	SendInput {Enter}

	Sleep, 1000
	SendInput {Raw}11186
	Sleep, 1000
	SendInput {Enter}

	Sleep, 1000
	SendInput {Tab}
	Sleep, 1000
	SendInput {Enter}
	Sleep, 1000

	MouseMove, 807, 260, 15
	Sleep, 1000
	click
	Sleep, 1000

}

return ;

Esc::ExitApp
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How do I sum a digit to an integer?

20 Sep 2017, 08:43

The script works fine, except for the part that I especified.
That's the idea, to show you a working concept and you specify your specifics on your own. :thumbup:
strid

Re: How do I sum a digit to an integer?

20 Sep 2017, 08:48

BoBo wrote:
The script works fine, except for the part that I especified.
That's the idea, to show you a working concept and you specify your specifics on your own. :thumbup:
I get it.

I'm trying to learn all this stuff because I will need it in the future, also I'm not a programmer so you can imagine how struggling it is to put all this in my head.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: How do I sum a digit to an integer?

20 Sep 2017, 11:44

Maybe your difficulty is caused by the order of the first two lines in your original script?
Change the order and you will get a script with the Loop command followed by a Block of commands that are meant to be looped over.
Currently your script will repeatedly assign the value 11186 to a variable 1156 times, and after that it will execute the block only once.

I hope that helps.
strid

Re: How do I sum a digit to an integer?

20 Sep 2017, 13:13

wolf_II wrote:Maybe your difficulty is caused by the order of the first two lines in your original script?
Change the order and you will get a script with the Loop command followed by a Block of commands that are meant to be looped over.
Currently your script will repeatedly assign the value 11186 to a variable 1156 times, and after that it will execute the block only once.

I hope that helps.
Hey wolf, thanks for the help.

I see what you're trying to say and I realized it when I saw jNizM's post earlier. Fixing that made the script work nearly as perfect, the only problem I can't seem to solve is to make the value 11186 increase by 1 after each loop (11187, 11188, 11189...).
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: How do I sum a digit to an integer?

20 Sep 2017, 13:23

I see, in that case you should not use the literal value, use the var instead:

Code: Select all

var := 11186
Loop 1156
{
    var+=1
    ToolTip % var
    Sleep, 85
    
    SendInput {Raw}%var%
    SendInput {Raw}File %var%
    SendInput {Raw}%var%
}
return ;
I hope that helps. (Untested)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: FortniteSpanishGuy, mihai369 and 171 guests