如何以编程方式操作任何 Windows 应用程序的通用对话框?

发布于 2024-07-05 15:39:52 字数 824 浏览 11 评论 0 原文

我的最终目标是编写一个实用程序,让我可以在任何对话框上快速设置文件夹,从预设的“收藏夹”列表中进行选择。 由于我只是一个业余爱好者,而不是专业人士,所以我更喜欢使用 .NET,因为这是我最了解的。 我确实意识到,其中一些东西可能需要比我在 C# 中能做的更多的东西。

我见过一些应用程序能够通过向工具栏添加按钮来扩展通用对话框(特别是“另存为...”和“文件打开”)(例如:对话框助手)或在标题栏中最小化、最大化和/或关闭按钮旁边放置额外的按钮。 尽管我不知道从哪里开始,但两者都是不错的选择。

我尝试过的一种方法是将我编写的应用程序中的文件夹名称“拖动”到对话框上的文件名文本框,使用我从 Corneliu Tusnea 的 Hawkeye Runtime Object Editor,然后添加路径通过使用 WM_SETTEXT 调用 SendMessage 来命名。 它(有点)有效,但感觉有点笨拙。

任何有关技术或实施的建议将不胜感激。 或者,如果现有实用程序已经执行此操作,请告诉我!

更新:当一切都说了又做了之后,我想我可能会使用现有的实用程序。 但是,我想知道是否有办法以编程方式执行此操作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尬尬 2024-07-12 15:39:52

对于这样的事情,您可能会大量进行 Win32 API 调用。 在 .Net 上工作意味着要进行大量的 pinvoke。 恐怕我帮不了你太多,但我记得有一本书叫做 " 子类化和挂钩使用 Visual Basic” 可能会有所帮助。 它主要是为 VB 6 编写的,但我相信其中有一些 VB.Net 的东西。

另外,PInvoke.Net 是一个 wiki,其中包含大量 pinvoke 签名,您可以复制并粘贴这些签名,这可能会有所帮助。

归根结底,您可能需要更多地了解 Windows 内部如何运行(消息传递等)才能实现您的目标。

Spy++ 也可能是你的朋友。

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.

赤濁 2024-07-12 15:39:52

对我来说,听起来像是 AutoHotkey 的工作。

我是一名“专业人士”(至少我是通过编程获得报酬的),但我首先会考虑使用 AutoHotkeys 的许多经过良好测试的函数来访问窗口,而不是深入研究 C#/.NET 以及最有可能通过 PInvoke 的 WinAPI。

AutoHotkey 甚至提供了一些基本的用户界面控件,并且是免费的。

这是一个 AutoHotkey 脚本,与您所要求的非常相似。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文