问题描述
我想我可能已经过去问过类似的问题,但我仍然停留...
I think I may have asked a similar question in the past, but I am still stuck...
作为自动化过程的一部分,我必须进口的媒体文件的特定子集到一个封闭源代码的第三方应用程序(标枪鱼公司,柜面它很重要)。 这里的情况是:
As part of an automated process, I must "import" a specific subset of media files into a closed-source third-party application (Dartfish, incase it matters). Here is the situation:
- 媒体(视频)文件都是一个文件夹中(也有他们的1000,重组是不是一种选择,不幸)。
- 在我写剧本的任何给定的迭代中,只有13的具体的文件必须导入到应用程序。
- 有一个在必须接收文件的应用程序没有导入功能。
- 此相同的应用程序的确实的让你DRAP文件拖放到特定的窗格,这可以让你从根本上导入。
- The media (video) files are all in one folder (there are 1000s of them, and reorganization is not an option unfortunately).
- On any given iteration of the script I am writing, only 13 specific files must be imported into the application.
- There is no import function in the app that must receive the files.
- This same app does allow you to drap and drop files into a specific pane, and this allows you to essentially import them.
我使用目前的解决方法是非常不稳定的,丑陋的,并使用正则表达式查询一个复杂的过程,将文件隔离在Xplorer2,然后使用AutoIt的选择它们,最后将它们拖动到应用程序。
The current workaround I am using is very unstable and ugly, and uses a complex procedure of regex queries to isolate the files in Xplorer2, and then uses AutoIT to select them, and then finally drag them into the application.
建议的解决方案:
我需要一种方法来拖放视频文件的特定子集,我需要在任何时候进入这个应用程序,preferably没有自动点击和移动光标(在此设置有失败的方式太多了点)
I need a way to drag and drop the specific subset of video files I need at any given time into this application, preferably without automating clicks and cursor movement (there are way too many points of failure in this setup).
我基本上只是路过的文件名列表应用程序(通过拖动它们),所以我算起来也一定是自动化这个拖的办法,并在code纯粹的下降 - 或许是使用C / C# / C ++和Windows API?奖励积分,如果该解决方案可以被移植到Python莫名其妙......但没有必要的。
I am essentially just passing a list of filenames to the application (by dragging them there), so I figure there has got to be a way of automating this drag and drop purely in code - perhaps using C/C#/C++ and the windows API? Bonus points if the solution can be ported to Python somehow... but not necessary.
如果任何人都可以点我在这个正确的方向(编程语言并不重要,我会学到什么,我需要知道),和preferably给我我该怎么完成一个基本的轮廓或示例这样的任务,我真的AP preciate吧!这已被我逼疯了一年多了!
If anyone can point me in the right direction with this (programming language doesn't matter; I'll learn whatever I need to know), and preferably give me a basic outline or example of how I can accomplish such a task, I would really appreciate it! This has been driving me nuts for over a year now!
推荐答案
1)注入到目标进程
2)获取目标窗口的下降目标
2) Get IDropTarget of target window
function GetDropTargetFromWnd(AWnd: HWND): IDropTarget;
var Unknow: IUnknown;
begin
Unknow := IUnknown(GetProp(AWnd, PChar(GlobalFindAtom('OleDropTargetInterface'))));
if Assigned(Unknow) then
Unknow.QueryInterface(IDropTarget, Result)
end;
3)与您的文件创建的IDataObject
3) Create IDataObject with your files
4)调用IDropTarget.DragEnter
4) Call IDropTarget.DragEnter
5)呼叫IDropTarget.Drop
5) Call IDropTarget.Drop
更新算法:
1)注册您的使用RegisterWindowMessage唯一的消息
1) Register your unique message with RegisterWindowMessage
2)和SetWindowsHookEx与WH_CALLWNDPROC型安装全局钩子(需要额外的DLL)
2) Install global hook with SetWindowsHookEx with WH_CALLWNDPROC type (additional dll is required)
3)与13名创建固定的文件
3) Create fixed file with 13 names
4)送在steip 1注册到目标窗口唯一的消息
4) Send unique message registered in steip 1 to target window
5)你钩子将被加载到目标进程
5) You hook will be loaded into target process
6)内部钩子程序检查消息
6) Inside hook procedure check message
7)如果消息是你唯一的消息
7) If message is your unique message
7.1)获取目标窗口的下降目标
7.1) Get IDropTarget of target window
7.2)与固定文件加载名
7.2) Load names from fixed file
7.3)与您的文件创建的IDataObject
7.3) Create IDataObject with your files
7.4)呼叫IDropTarget.DragEnter
7.4) Call IDropTarget.DragEnter
7.5)呼叫IDropTarget.Drop
7.5) Call IDropTarget.Drop
8)如果所有的文件还没有处理,然后去3
8) If all files don’t processed yet then go to 3
9)卸载全局钩子
更新2
您也可以尝试发送WM_DROPFILES消息给目标窗口,从你钩子DLL。
Also you can try send WM_DROPFILES message to target window from you hook dll.
这篇关于模拟窗口拖动和code降?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!