Jump to content

Recommended Posts

Posted

Working on a script, how do I read only first line on a notepad and launch it on google chrome?

example:

notepad will be written...

youtube.com

myspace.com

facebook.com

I want to launch the first line on the notepad on google chrome and close it after 4 seconds.

Posted

$File_Path = "C:\Test.txt"
$file = FileOpen($File_Path, 0)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file, 1)
    ShellExecute($line)
Wend

FileClose($file)

if you read the help file about the functions used in above, you 'll get all the info there.

This was just a example...

Posted

I don't think you can ShellExecute a website.

After you read the first line of text with FileReadLine, you can use _IECreate, passing it the line of text as a parameter. That will open the website in Internet Explorer. You'll need to #include <IE.au3>. Be sure to read the help file for these functions.

As far as Google Chrome goes, maybe someone knows about a UDF for it ;)

Posted

i don't know, why people always stated that ShellExecute() does not work for websites.

i 've been using this method for years and it works perfect. it opens the page in default browser.

Tested many times by myself. ;)

Posted

Hawk is right. As long as you have at minimum "www." or "http://" as the first strings in the file to run, it will open in the default browser "ftp." or "ftp://" will also open in default browser unless another program is registered to handle those actions. "nntp://" can also be opened if there is an appropriate action associated with it.

Posted

Ok. Always learning! ;) I need a "http://" for shellExecute() to open a website. So gui529's file will need that too.

Yes, his file cannot ShellExecute "youtube.com", but "www.youtube.com" or "http://youtube.com" will work
Posted (edited)

You could put

if not StringInStr($line, "http://") then $line = "http://" & $line
above shellexecute, then it would run any website...

Edited by hooked

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
×
×
  • Create New...