Sign in to follow this  
Followers 0
Marvel

Read url from config file in sequence order

2 posts in this topic

#1 ·  Posted (edited)

Hello,

I'm new to AutoIT forum, i've done re-search before but still couldn't find any examples which would suit for my small project.

As I mention i'm new to AutoIT forum, so obviously i'm rookie at autoit it self. At the moment i'm trying to create small project for my needs.

What i want to create? Well basically autoit project which opens url from config/txt file with sequence order example first yahoo.com, after google.com so on. In config/txt file will be around 50 urls. I want to merge 2 projects into 1 with some adjustments.

Part 1.

Local $oIE = _IECreateEmbedded()
GUICreate("MyProject", 800, 480, "250", "150", $WS_EX_MDICHILD  )
GUICtrlCreateObj($oIE, 1, 1, 800, 480)
GUISetState(@SW_SHOW)
$oIE.Navigate("https://www.yahoo.com/")
_IELoadWait($oIE)
Sleep(5000)
$oObject = _IEGetObjById($oIE, "nav-mail")
_IEAction($oObject, "click")
Sleep(8000)
GUIDelete() 

This part working fine, this opens yahoo.com and after clicking email button.

Part 2.

#include <file.au3>
Dim $aSite
If Not _FileReadToArray("Sites.txt",$aSite) Then
MsgBox(4096,"Error", " Error reading file to Array    error:" & @error)
Exit
EndIf
$x = Random(1, $aSite[0], 1)
ShellExecute($aSite[$x])

Part 2 working fine too, but not like i want. This reading url from Sites.txt and starts default browser with one of them randomly. I want to make it not random but from top to bottom sequence.

And also to use for every url.

$oObject = _IEGetObjById($oIE, "nav-mail")
_IEAction($oObject, "click")

I could do in easier way (in worst case) by adding 1 by 1 urls without config/txt file, but then script would be long. Could anyone with higher autoit experience advise me how to get working both parts into one ? 

Best regards

Marius

Edited by Marvel

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you don't want it to be random you should remove the random generating code ;)  :

$x = Random(1, $aSite[0], 1)

The way to get them all in order is with a loop through your array:

for $a=0 to ubound($aSite)-1
ShellExecute($aSite[$a]); this could also be navigate instead
next

Also, if you want advice on merging your code you need to post the entire script.




			
				


	Edited  by Jfish
	
	

			
		

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0