bumsbomber Posted May 15, 2011 Share Posted May 15, 2011 HiI want to open a selected file of a windows dialog with a special program.Example: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? Link to comment Share on other sites More sharing options...
smartee Posted May 15, 2011 Share Posted May 15, 2011 hi bumsbomber, Welcome to the forums Your explanation of your problem is not very explicit, but perhaps these functions will be of interest: FileOpenDialog(),ShellExecute(). -smartee Link to comment Share on other sites More sharing options...
bumsbomber Posted May 15, 2011 Author Share Posted May 15, 2011 (edited) Ok, please try this code, you you will understand what I do and what I want to do 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. expandcollapse popup; 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}" Init() Func Init() While 1 Sleep(100) If WinExists($OpenDialogTitle) Then OpenExternal() EndIf If Not WinExists("[CLASS:Notepad]") Then Exit WEnd EndFunc Func OpenExternal() ; This opens the preferences of a selected file, just as example. $FileNameOld = False While WinExists($OpenDialogTitle) Sleep(100) $FileNameNew = CheckForFiles() If $FileNameNew <> False Then If $FileNameOld <> $FileNameNew[0] Then $FileNameOld = $FileNameNew[0] Send("{APPSKEY}{I}") EndIf EndIf WEnd EndFunc Func CheckForFiles() ; This looks for filenames in the open dialog of notepad $DialogText = WinGetText($OpenDialogTitle) $FileName = StringRegExp($DialogText, $FileNameRegex, 1) Return $FileName EndFunc 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 May 15, 2011 by bumsbomber Link to comment Share on other sites More sharing options...
crislivinitup Posted March 14, 2012 Share Posted March 14, 2012 Hi bumsbomber. I recently had the same problem as you. I did find somewhat of an answer. Please look at my post:(The title has a typo .) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now