bberrry Posted October 1, 2012 Posted October 1, 2012 Hey guys, hopefully you'll help me despite being new around here. I'm trying to make a simple little script that opens the selected file in Windows Explorer with an alternate program upon pressing CTRL+Enter. For example, I was hoping to use this to open JPEGs in Irfanview by default but open them in Photoshop when i press CTRL+Enter. I'm unfortunately not coming up with any way to get the path of the selected file. Is there a way? Any help would be much appreciated!
Moderators JLogan3o13 Posted October 1, 2012 Moderators Posted October 1, 2012 Hi, bberrry, welcome to the forum. You could always start by opening a FileOpenDialog box. That will give you the full path. Try something like this to get you started. $var = FileOpenDialog("My File Open Test", "C:", "All (*.*)") MsgBox(0, "Test", $var) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MilesAhead Posted October 1, 2012 Posted October 1, 2012 (edited) The easiest way is to test an Explorer window is the active window. If so, send ^c to copy the selected files/folders names to the clipboard. See ClipGet() in the help. If you want to save the clipboard contents call ClipGet() before sending ^c and ClipPut() to restore after you copy files out. If multiple files/folders are selected the paths will be separated by a LF character. Here's a starting point detecting that the active window is an Explorer window. Explorer uses one of two class names. So you need to test for both. See SetHotKey() in the help for setting a function to fire when Control-Enter is pressed. Func GetExplorerSelection() Local $saveClip = "" Local $filesFolders = "" Local $handle = _WinAPI_GetForegroundWindow() Local $className = _WinAPI_GetClassName($handle) If $className = "ExploreWClass" Or $className = "CabinetWClass" Then $saveClip = ClipGet() Send("^c") Sleep(50) ; give clipboard time to react $filesFolders = ClipGet() ClipPut($saveClip) ; test if $filesFolders contains @LF and split if so etc.. ; code to call StringSplit() etc.. EndIf EndFunc Edited October 1, 2012 by MilesAhead My Freeware Page
bberrry Posted October 1, 2012 Author Posted October 1, 2012 Ah, I didn't think to use clipboard Thank you for your help
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