Posts: 53
Threads: 18
Joined: Feb 2014
03-02-2018, 05:50 PM
(This post was last modified: 03-02-2018, 05:51 PM by Valentin.)
Hello,
What would be the best and quickest way to open a file with a different application than the default one?
Thank you.
Posts: 12,071
Threads: 140
Joined: Dec 2002
Function
OpenFileWith
;/
function $file $program
opt noerrorshere 1
run program F"''{_s.expandpath(file)}''"
example
OpenFileWith "$my qm$\qm log.txt" "winword.exe"
Posts: 53
Threads: 18
Joined: Feb 2014
Great.
Thank you
With the following code, you can open selected file with a different program than the default.
find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
int hwnd2=b.HWND; err continue
if(hwnd=hwnd2) goto g1
ret
g1
get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
enumerate selected items
foreach fi sfw.SelectedItems
out fi.Path
str SS=fi.Path
OpenFileWith SS "C:\Program Files\S\S.exe"