UI 自动化/检索文件扩展名
我的任务是从一个文件夹中检索特定文件,在该文件夹中我只能在屏幕上获取 X 和 Y。虽然在XP中我设法利用Windows资源管理器本质上是一个列表视图这一事实,并使用WM_HITTEST消息来获取有关文件的信息,但在Windows 7中,情况并非如此。
为了解决这个问题,我使用了 UI Automation,这是一个很棒的工具,唯一的问题是在这种情况下,我正在查看的窗口句柄属于桌面,并且桌面可能有多个具有相同内容的文件名称但具有不同的扩展名(并且 Windows 配置为“隐藏已知文件类型的扩展名”)UI 自动化不会将扩展名返回给我。我尝试了很多方法,但找不到任何可靠的解决方案可以让我 100% 成功。
有人试过这个吗?成功地?
I am tasked with a project that requires me to retrieve a specific file from a folder where I can only get an X and Y on the screen. While in XP I managed to use the fact that windows explorer is in essence a list view, and used the WM_HITTEST message to obtain information about the file, in Windows 7, this is not the case.
To solve this problem, I am using UI Automation, which is a great tool for such things, only problem is that in the case, the windows handle I am looking at belongs to the desktop, and the desktop might have several files with the same name but with different extensions (and windows is configured to "hide extensions of known file types") UI automation does not return the extension back to me. I have tried many things, but I cannot find any robust solution which would give me 100% success.
Has anyone tried this? successfully?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否提供有关“文件夹中的特定文件”的更多详细信息?
您将使用什么规则来手动识别文件?
我不认为通过 GUI 是处理这种情况的最佳方法。
如果有任何东西可以用于识别存储在文件/文件夹系统中的文件,我会尝试通过后端。
一个简单的示例来说明。计算文件夹中包含的文本文件总数,并存储找到的所有 Excel 文件的路径。
谢谢你,
阿尔伯特·加里耶夫
http://automation-beyond.com/
Could you provide more details regarding "a specific file from a folder"?
What rules would you use to identify a file manually?
I wouldn't say going through the GUI is the best way for such cases.
If there is anything, that you can use for recognition of a file, stored in the file/folder system, I would try going through the back-end.
A simple example to illustrate. Counting total number of text files contained in a folder, and storing a path of the all Excel files found.
Thank you,
Albert Gareev
http://automation-beyond.com/