Jump to content

how to open a file like doubleclick does ....


Recommended Posts

Hummm :whistle: basic question ...

I try to open file like 2click does on an icon.

( files like click an excel file or a word document .... )

I played with run command but I need the full path of the application ...

Is this a command somewhere that do that ?

:">

Link to comment
Share on other sites

First of all, you have to know the full path....Otherwise how are you goin to indicate AutoIt where the file is?

Try this and tell me :

Run(@ComSpec & "/c start " & $file ,"",@SW_HIDE)

Where $file is the full path of your file e.g.

$file="C:\Program Files\text.txt"

C ya

Edited by hgeras
Link to comment
Share on other sites

First of all, you have to know the full path....Otherwise how are you goin to indicate AutoIt where the file is?

Try this and tell me :

Run(@ComSpec & "/c start " & $file ,"",@SW_HIDE)

Where $file is the full path of your file e.g.

$file="C:\Program Files\text.txt"

C ya

<{POST_SNAPBACK}>

:">

Im please that work for you ....

Here I'm not able to open the file if along the path of the file I have folder name with space.

run( @ComSpec & " /c start C:\Program Files\txt.txt", "", @SW_HIDE )

I tried putting "" around filename but it didn't work ....

run( @ComSpec & " /c start ""C:\Program Files\txt.txt""", "", @SW_HIDE )

How are you doing it ?

:whistle:

Link to comment
Share on other sites

AutoIt Smith had it right. you do not use the run/comspec to open a text file

in this example. You use the Word/excell program followed by the text file you wish to open

$program_location = @ProgramFilesDir & "\Folder\program.exe"

$file_location = "C:\Desktop\text.txt"

Run( $program_location & " " & $file_location & "")

to find the locations

right click on the short-cut

left click properties

copy the location (ex C:\desktop\...)

copy the program location to $$program_location =

and the file location to $file_location =

hope it helps

8)

NEWHeader1.png

Link to comment
Share on other sites

Use the generic Run statement for com, lnk, exe(programs only)

FileOpen for text files

IniCreate, write, etc for Ini's

besides that Shellexecute or use Larrys Au3record to doubleclick on the desired file

<{POST_SNAPBACK}>

FileOpen is use to open a text file to read or write inside from a script .

samething for IniCreate for a .ini file.

That was not what I wanted to do :whistle:

Link to comment
Share on other sites

AutoIt Smith had it right. you do not use the run/comspec to open a text file

in this example. You use the Word/excell program followed by the text file you wish to open

$program_location = @ProgramFilesDir & "\Folder\program.exe"

$file_location = "C:\Desktop\text.txt"

Run( $program_location & " " & $file_location & "")

to find the locations

right click on the short-cut

left click properties

copy the location  (ex C:\desktop\...)

copy the program location to $$program_location =

and the file location to $file_location =

hope it helps

8)

<{POST_SNAPBACK}>

Yes but that was what I didn't want to do :-)

And, Yes you can used run comspec to simulate a double click on a file .

See next message :whistle:

Edited by JoeCool
Link to comment
Share on other sites

You mean like this

$program_location = @ProgramFilesDir & "\Folder\program.exe"

$file_location = "C:\Desktop\text.txt"

RunWait(@COMSPEC & " /c start " & $program_location & " " & $file_location & "")

should work also

8)

EDIT:

took out a space

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

First some info from Bill:

cmd info at :

http://www.microsoft.com/resources/documen.../en-us/cmd.mspx

There's interesting info on "start" command at the bottom of that page.

So now opening a file like a doubleclick How it can be do :

;an excel file

run( "cmd /c ""C:\Program Files\copy of xyz.xls""", "", @SW_HIDE )

;txt file
run( "cmd /c ""C:\Program Files\copy of txt.txt""", "", @SW_HIDE )

;generic approach 

$d = "C:\Program Files\"
$f = "blahblah.xls"

run( "cmd /c " & """" & $d & $f & """", "", @SW_HIDE )

:whistle:

PS. double quote are important things there :-)

Edited by JoeCool
Link to comment
Share on other sites

First some info from Bill:

cmd  info  at :

http://www.microsoft.com/resources/documen.../en-us/cmd.mspx

There's interesting info on "start" command at the bottom of that page.

So now  opening a file  like a doubleclick How it can be do :

;an excel file

run( "cmd /c ""C:\Program Files\copy of xyz.xls""", "", @SW_HIDE )

;txt file
run( "cmd /c ""C:\Program Files\copy of txt.xls""", "", @SW_HIDE )

;generic approach 

$d = "C:\Program Files\"
$f = "blahblah.xls"

run( "cmd /c " & """" & $d & $f & """", "", @SW_HIDE )

:whistle:

PS.  double quote are important things there :-)

<{POST_SNAPBACK}>

glad you found your answer.

Like i said

...you do not use the run/comspec to open a text file...

8) Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

tested... does not work

tested, corrected.... this works

run( "cmd /c " & " " & $d & " " & $f & " ", "", @SW_HIDE )

8)

PS... no double quotes

<{POST_SNAPBACK}>

Well it works for me :whistle:

I add two spaces to clean it a little.

$d = "C:\Program Files\"
$f = "copy of xyz.xls"
run( "cmd /c " & " """ & $d & $f & """ ", "", @SW_HIDE )
Edited by JoeCool
Link to comment
Share on other sites

Hummm  :whistle:  basic question ...

I try  to open  file  like 2click does on an icon.

( files like click  an excel file or a word document .... )

I played with run command but I need the full path of the application ...

Is this a command somewhere that do that ?

:">

<{POST_SNAPBACK}>

I'm bored, so I'll try writing a script to query a few reg keys or a Windows .dll to try and get that to work through AutoIt. I thought I saw a reg key the other day while roaming the registry that might be of use. Check back with me in a few days if I haven't re-posted here.

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

I'm bored, so I'll try writing a script to query a few reg keys or a Windows .dll to try and get that to work through AutoIt. I thought I saw a reg key the other day while roaming the registry that might be of use. Check back with me in a few days if I haven't re-posted here.

<{POST_SNAPBACK}>

Thanks but I found what I need :whistle:

$d = "C:\Program Files\"
$f = "copy of xyz.xls"
run( "cmd /c " & " """ & $d & $f & """ ", "", @SW_HIDE )

some info there from Bill

http://www.microsoft.com/resources/documen.../en-us/cmd.mspx

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...