Sign in to follow this  
Followers 0
Guest unabatedshagie

Is It Possible

8 posts in this topic

Topic says it all, is it possible to open an hta file from an autoit script? If it's not can anyone think of a way round it.

Share this post


Link to post
Share on other sites



If it is a local copy, you should be able to open the file via FileRead.

As far as an online copy goes, it depends on the server's settings. You could try using the URLDownloadToFile command to see if you can pull a copy of the source.

Share this post


Link to post
Share on other sites

Topic says it all, is it possible to open an hta file from an autoit script? If it's not can anyone think of a way round it.

<{POST_SNAPBACK}>

you just want it to open on the client machine, like in the default browser?

run(@comspec & ' /c start "" "x:\file.hta"'

you'll want to look at the start command (start /? from cmd prompt) for your OS to determine if you want that first "" in there or not, in win2k/xp it needs to be there to define the window title.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The file is on my machine,

I use opera and gmail doesn't work with it. I found someone who had made an hta document which opens the gmail page.

So I was looking to make a script to open the gmail.hta file and insert my username and password, I just couldn't get the script to open the hta file.

I had already tried the

run(@comspec & ' /c start "" "x:\file.hta"'

but I may have had the syntax wrong because it wouldn't work.

I'll give the fileread command a shot and see if it works.

:ph34r: You can probably guess I have never used autoit before. I have tried both the methods mentioned here but I still can't get it to work.

Here's what I have so far

run(@comspec & ' /c start "GMAIL" "C:\Documents and Settings\USER\Application Data\Opera\Opera\profile\Extras\gmail.hta"'
WinActivate("GMAIL")
sleep (1000)
send ("username")
send ("{TAB}")
send ("password")
send ("{ENTER}")

I know from WinActivate down works because I tried it when the hta file was open, I just can't seem to get the opening of the file to work.

Edited by unabatedshagie

Share this post


Link to post
Share on other sites

Ah, it may be a browser limitation or the file type may not be properly registered.

First of all, I would recommend that you try right-clicking on the hta file and opening it with Opera.

Also, forget trying to use FileRead... I misunderstood what you were wanting when I mentioned it.

If Opera knows how to handle hta files, you can try the following snippet:

$Browser = "rundll32 url.dll,FileProtocolHandler"
$Opera_Path = EnvGet("AppData") & "\Opera\Opera\profile\Extras\"
$File = $Opera_Path & "gmail.hta"
$Launch =  "START /MIN " & $Browser & " " & $File
Run(@ComSpec & " /c " & Chr(34) & $Launch & Chr(34), "", @SW_HIDE)
WinWaitActive("GMAIL", "", 10) = 0 Then ShowError()
Sleep(1000)
Send("username{TAB}password{ENTER}")
Exit

Func ShowError()
  MsgBox(48, "GMAIL Login", "Warning:  Unable to launch browser.")
  Exit
EndFunc

I haven't tested this because I don't have Opera, nor the hta file - but it should work.

Share this post


Link to post
Share on other sites

Well it's one step closer, the hta file opens, now I just get this error message.

Posted Image

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Oops, forgot the If statement on the WinWaitActive line:

$Browser = "rundll32 url.dll,FileProtocolHandler"
$Opera_Path = EnvGet("AppData") & "\Opera\Opera\profile\Extras\"
$File = $Opera_Path & "gmail.hta"
$Launch =  "START /MIN " & $Browser & " " & $File
Run(@ComSpec & " /c " & Chr(34) & $Launch & Chr(34), "", @SW_HIDE)
If WinWaitActive("GMAIL", "", 10) = 0 Then ShowError()
Sleep(1000)
Send("username{TAB}password{ENTER}")
Exit

Func ShowError()
  MsgBox(48, "GMAIL Login", "Warning:  Unable to launch browser.")
  Exit
EndFunc

This one should work.

Edit: You may need to change the "GMAIL" on the WinWaitActive line to whatever the window title is for the hta file. I'm assuming that it starts with GMAIL.

Edited by Bartokv

Share this post


Link to post
Share on other sites

Cool thanks alot :ph34r:

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