views:

742

answers:

2

My ultimate goal here is to write a utility that lets me quickly set the folder on any dialog box, choosing from a preset list of 'favorites'. As I'm just a hobbyist, not a pro, I'd prefer to use .NET as that's what I know best. I do realize that some of this stuff might require something more than what I could do in C#.

I have seen some applications that are able to extend the common dialog box (specifically for Save As.. and File Open) either by adding buttons to the toolbar (eg: Dialog Box Assistant) or by putting extra buttons in the title bar beside the minimize, maximize, and/or close buttons. Either would be good option though I don't have the foggiest idea where to begin.

One approach I've tried is to 'drag' the folder name from an app I wrote to the file name textbox on the dialog box, highlighting it using a mouse hook technique I picked up from Corneliu Tusnea's Hawkeye Runtime Object Editor, and then prepending the path name by pinvoking SendMessage with WM_SETTEXT. It (sort of) works but feels a bit klunky.

Any advice on technique or implementation for this would be much appreciated. Or if there's an existing utility that already does this, please let me know!

Update: When all is said and done, I think I'll probably got with an existing utility. However, I would like to know if there is a way to do this programmatically.

+4  A: 

Sounds like a job for AutoHotkey to me.

I am a "pro" (at least I get paid to program), but I would first look at using AutoHotkeys' many well tested functions to access windows, rather then delving into C#/.NET and most likey the WinAPI via PInvoke.

AutoHotkey even provides some basic user interface controls and is free.

Here's an AutoHotkey script that is very similar to what you are asking for.

Ash
+1 on AutoHotKey, its good for all kinds of low level stuff.
Jim Burger
Thanks Ash, a good answer and I'll definitely be trying it out. I would, however, like to see if I can get a programmatic answer to this, as I know it's possible.
AR
AR: I wrote an AutoHotkey to do exactly what you want. If the sample Ash mentioned doesn't work for you, send me an email and I'll try to help you out. deanhill1971 AT gmail.com
Dean Hill
+1  A: 

For something like this you're probably going to get heavy into Win32 API calls. Working from .Net means making a lot of pinvokes. I'm afraid I can't help you much, but I do remember there being a book called " Subclassing and Hooking with Visual Basic" that might help. It was written mostly for VB 6, but I believe it had some VB.Net stuff in it.

Also, PInvoke.Net is a wiki with a lot of pinvoke signatures that you can copy and paste that might help.

When it comes down to it, you're probably going to have to learn more about how Windows operates internally (message passing, etc.) to accomplish your goal.

Spy++ will also probably be your friend.

Slapout