[python-win32] Find Target
I am trying to figure out how to show a specified file in explorer. I know I can call os.startfile(directory) to show the containing directory, but I would like the file to be selected also. Is there an API call that windows makes to do this? For example, right click on a shortcut and go to properties, then click on the 'Find Target' button. Any ideas? -Kyle Rickey ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Find Target
Tim, let me rephrase. I'm not trying to display the shortcut dialog, only reproduce the behavior that happens when you click 'Find Target'. For instance, I've generated a file and I want show the user that file in explorer. -Kyle Rickey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Roberts Sent: Thursday, April 03, 2008 11:42 AM To: Python-Win32 List Subject: Re: [python-win32] Find Target Rickey, Kyle W wrote: I am trying to figure out how to show a specified file in explorer. I know I can call os.startfile(directory) to show the containing directory, but I would like the file to be selected also. Is there an API call that windows makes to do this? For example, right click on a shortcut and go to properties, then click on the 'Find Target' button. Any ideas? You're talking about controlling the UI here. You could do that by finding the Explorer window, trolling through to find the list control, find the entry, simulate right-click, etc., but it would be an undocumented pain in the rear. However, everything that's in those dialogs is exposed through the shell API. Why don't you just display the dialog yourself? -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Find Target
Rickey, Kyle W wrote: Tim, let me rephrase. I'm not trying to display the shortcut dialog, only reproduce the behavior that happens when you click 'Find Target'. For instance, I've generated a file and I want show the user that file in explorer. Find Target just follows a shortcut and opens the directory containing that shortcut. The shell library has an API for fetching the target path from a shortcut file. You could just pull the path from the shortcut, and startup a new Explorer in that directory. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Find Target
Kyle, If I understand you correctly, and if your not stuck on using os.startfile(), you can use explorer.exe's command line options to do this (and more). os.system('%SystemRoot%\explorer.exe/e,/select=C:\MyFolder\subfolder\MyFile. txt') See thisfor more info: http://support.microsoft.com/kb/314853 -Scott ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Find Target
Rickey, Kyle W wrote: Tim, thanks for your patience :). I think I'm still miscommunicating to you what I need to do. Let's throw the whole shortcut idea out the window and start from scratch. My code generates a file, I want to open the directory (which is known) containing that file and select it. Since I can open the directory with os.startfile(), do I still need to get the hwnd of the explorer window and get the listctrl etc., or is there a simpler way to select a file? You're in luck! There IS a simple solution to the problem as you just stated it: explorer /select,c:\windows\notepad.exe For future reference, here's a knowledge base article that describes the command-line parameters to explorer: http://support.microsoft.com/kb/130510 -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32