Page 1 of 1

Opening web site according to my order

Posted: 21 Aug 2019, 06:26
by Ebs
I have a list of websites I have to open and check at work, I'm a beginner to ahk, so I took a acript from someone else on the forum (forgot who so can't credit). The script works perfectly, but the sites open in a random order, rather than the order I've written in the code.

I can't giveaway the sites, as they're private business, but I do have a example of the code:

sites:="site a|site b|site c|site d"
Loop, Parse, sites, |
if A_Index = 1
Run chrome.exe ℅A_LoopField℅
if A_Index = 0
Run chrome.exe -new-tab ℅A_LoopField℅
The sites' order is very random, like: bcad, and then dbac etc.
All I need is that the order goes like abcd.
Thanks in advance!

Re: Opening web site according to my order  Topic is solved

Posted: 21 Aug 2019, 09:38
by Sir Teddy the First
Hi,
first of all you probably need to insert a Sleep command after each tab, because your browser has to register what you are doing first and the response time will vary depending on the website's response time.

Second, what exactly does "If A_Index = 0" mean?
"A_Index" will never be "0" inside a loop, only outside, so what do you expect this command to do?

This should work:

Code: Select all

sites:="site a|site b|site c|site d"

Loop, Parse, sites, |
{
	if (A_Index = 1)
		Run chrome.exe %A_LoopField%
	else
		Run chrome.exe -new-tab %A_LoopField%
	Sleep 350
}

Re: Opening web site according to my order

Posted: 21 Aug 2019, 14:17
by Ebs
You don't know how much I want to thank you! It's such a easy solution, just needed to figure out what I was doing wrong.

As for the A_Index = 0 , I meant with it something like: "if chrome is not on", however I didn't realise it has no point using it in a loop :lol:
Thanks again for helping!

Re: Opening web site according to my order

Posted: 21 Aug 2019, 15:13
by garry
script to check if program already running ( here firefox , errorlevel=0 not running )

Code: Select all

#warn
#NoEnv
#SingleInstance Force
setworkingdir,%a_scriptdir%
process, exist,firefox.exe
status2 = %ErrorLevel%
if (status2<>0)       
 msgbox,FIREFOX = YES running
else
 msgbox,FIREFOX = NOT runnig
return

Re: Opening web site according to my order

Posted: 28 Aug 2019, 09:36
by Getfree
It would be much easier to just put those sites in a bookmark folder and then click with middle button on that folder to open all sites in the specified order.