Page 1 of 1

can Loop help repeated "Send" more steady

Posted: 09 Dec 2018, 13:52
by AmDeG 11
I need to open a website but Sending 17 times Tab not always brings me to the place where I want

Using "Loop" can solve my problem?

Code: Select all

#IfWinActive dictionary ahk_class IEFrame
 !d::   
        Sleep 500
        Send {Tab 17}
        Return
#IfWinActive

Re: can Loop help repeated "Send" more steady

Posted: 09 Dec 2018, 19:50
by Scr1pter
Eh, I don't think Loop will solve that problem.
Where should be the difference between

Code: Select all

Send {Tab 17}
and

Code: Select all

Loop, 17
{
  Send {Tab}
}
?

I believe it doesn't work always because the website wasn't completely loaded.
Increase your sleep time.
Safest would be to test if the site was loaded completely.
(E.g. ImageSearching the icon which indicates the loading status.)

Regards

Re: can Loop help repeated "Send" more steady

Posted: 10 Dec 2018, 00:37
by neokix
Sometimes putting "Sleep" between each keypress solved problems (at least for me).
So it's like this.

Code: Select all

Loop, 17
{
  Send {Tab}
  Sleep, 100 ;or 200 or 300 or 500 depending on programs
}
But Scr1pter-san can be right. I'm not sure. Just have a try and let us know how it goes. ;)

Re: can Loop help repeated "Send" more steady

Posted: 10 Dec 2018, 04:49
by hymal7
when you open a site on the browser, the cursor doesnt guarantee that it always lands on the same place everytime.
so you can write a code at the start of your script that clicks a specific location.

Code: Select all

Mouseclick, left, x,y

Re: can Loop help repeated "Send" more steady

Posted: 10 Dec 2018, 12:55
by Scr1pter
@neokix:
Yes, if his device is not really fast, probably a sleep time within the loop might be useful.
I'm also a friend of sleep times (at least in coding) :D

@hymal7:
Yeah, would be useful to know which site he's talking about.
Maybe there is really some "dynamic" there.

Regards

Re: can Loop help repeated "Send" more steady

Posted: 10 Dec 2018, 13:06
by Nextron
To target browser elements, I usually send ^f///' to search for the matching (or nearest selectable) text/link.

Re: can Loop help repeated "Send" more steady

Posted: 11 Dec 2018, 13:48
by AmDeG 11
I realized that my problem MAY be solved if the machine opens the http slower

how can I do that?

Re: can Loop help repeated "Send" more steady

Posted: 11 Dec 2018, 14:52
by Scr1pter
Opening the site slower?
Can you please list the steps you do?
It's always meaningless if we have to guess how it can be.

Just list the steps, like:
- opening browser (manually)
- running a site (keypress script)
- running the ahk script to make tab 17

Write what you do.

Re: can Loop help repeated "Send" more steady

Posted: 12 Dec 2018, 05:09
by hymal7
in that case, you could delay the start of your code by a few seconds after the browser is loaded

add this to the start of your code:

sleep, 5000 ;waits 5 seconds before launching the next script lines