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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With