Jump to content
Sign in to follow this  

Open selected file in Windows-dialog with shell programs

Recommended Posts


I want to open a selected file of a windows dialog with a special program.


Open-File-Dialog of notepad.

Single-click on a random file.

I want AutoIt to open it e.g. in Firefox, without doing else with the dialog.

At moment, I watch the dialog window to detect if a file got selected. This works fine, I can open a clicked file immediately by doing a send({enter}). But as I want to open the clicked file with an external program (it's registered in the shell), I want to know how this could work. I can open the clicked file e.g. with Send("{APPSKEY}{DOWN 5}{ENTER}"), because the program I want to open it in has an context menu entry. But this way is kinda slow and unreliable, so I look for a more direct method.

Do you have an idea?

Share this post

Link to post
Share on other sites

hi bumsbomber,

Welcome to the forums :unsure:

Your explanation of your problem is not very explicit, but perhaps these functions will be of interest: FileOpenDialog(),ShellExecute().


Share this post

Link to post
Share on other sites

Ok, please try this code, you you will understand what I do and what I want to do :unsure:

Remember to change the first two variables due to localization issues. E.g. set "Open" in the 1st, "File" in the 2nd.

Start notepad first, then the script.

; Please replace "Öffnen" below with the title name of the open dialog of notepad
global $OpenDialogTitle = "[TITLE:Öffnen;CLASS:#32770]"
; Please replace "Datei" below with the correct "file type" label you get as visible text (e.g. just "File")
global $FileNameRegex = "(?s).*name:(.*\w{3}(?-s))(?s).*Datei{1}"


Func Init()
    While 1
        If WinExists($OpenDialogTitle) Then
        If Not WinExists("[CLASS:Notepad]") Then Exit

Func OpenExternal() ; This opens the preferences of a selected file, just as example.
    $FileNameOld = False
    While WinExists($OpenDialogTitle)
        $FileNameNew = CheckForFiles()

        If $FileNameNew <> False Then
            If $FileNameOld <> $FileNameNew[0] Then
                $FileNameOld = $FileNameNew[0]

Func CheckForFiles() ; This looks for filenames in the open dialog of notepad
    $DialogText = WinGetText($OpenDialogTitle)
    $FileName = StringRegExp($DialogText, $FileNameRegex, 1)
    Return $FileName

Instead of opening the properties window with some keystrokes, I want to open the file with a shell registered program. So when I e.g. click on a file like "hello.text", it get opened immediately in Firefox through the shell. If I double click the file, it should get opened in both, Firefox and in notepad.

Edited by bumsbomber

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...