Windows 如何在“中模拟选择更改”;“文件类型”;GetSaveFileName对话框中的ComboBox是否来自单独的进程?

Windows 如何在“中模拟选择更改”;“文件类型”;GetSaveFileName对话框中的ComboBox是否来自单独的进程?,windows,winapi,common-controls,Windows,Winapi,Common Controls,我正在编写一个自定义模块来使用专有软件。(该软件已停止使用,我没有其源代码。)我的模块将作为单独的进程运行。其目标是通过该专有软件实现操作自动化。为此,我需要能够模拟保存此软件的输出。我可以通过模拟工具栏按钮单击打开其“另存为”对话框: 然后,我尝试将“另存为类型”组合框更改为所需的文件类型,添加要保存到的文件路径,并模拟单击“保存”按钮。我想出了以下代码来实现这一点: //All I have to work with are the following window handles: /

我正在编写一个自定义模块来使用专有软件。(该软件已停止使用,我没有其源代码。)我的模块将作为单独的进程运行。其目标是通过该专有软件实现操作自动化。为此,我需要能够模拟保存此软件的输出。我可以通过模拟工具栏按钮单击打开其“另存为”对话框:

然后,我尝试将“另存为类型”组合框更改为所需的文件类型,添加要保存到的文件路径,并模拟单击“保存”按钮。我想出了以下代码来实现这一点:

//All I have to work with are the following window handles:

//HWND hWndFileName = file name window handle
//HWND hWndSaveAsType = save as type window handle
//HWND hWndSaveBtn = Save button handle

DWORD dwComboIDSaveAsType = ::GetWindowLong(hWndSaveAsType, GWL_ID);
HWND hParWnd = ::GetParent(hWndSaveAsType);

//Select index for file type
int nSaveAsIndex = 3;
::SendMessage(hWndSaveAsType, CB_SETCURSEL, nSaveAsIndex, 0);
::SendMessage(hParWnd, WM_COMMAND, 
    (dwComboIDSaveAsType & 0xffff) | ((((DWORD)CBN_SELCHANGE) << 16) & 0xFFFF0000),
    (LPARAM)hWndSaveAsType);

//Set path to save
::SendMessage(hWndFileName, WM_SETTEXT, NULL, 
    (LPARAM)L"C:\\Test\\test file");

//Simulate Save button click
::SendMessage(hWndSaveBtn, BM_CLICK, 0, 0);
//我只需要处理以下窗口句柄:
//HWND hWndFileName=文件名窗口句柄
//HWND hWndSaveAsType=另存为类型窗口句柄
//HWND hWndSaveBtn=保存按钮句柄
DWORD dwComboIDSaveAsType=::GetWindowLong(hWndSaveAsType,GWL_ID);
HWND hParWnd=::GetParent(hWndSaveAsType);
//选择文件类型的索引
int nsavasindex=3;
::SendMessage(hWndSaveAsType,CB_SETCURSEL,nSaveAsIndex,0);
::SendMessage(hParWnd,WM_命令,

(dwComboIDSaveAsType&0xffff)|(((DWORD)CBN_SELCHANGE)我想我明白了。显然,我还需要将
CBN_SELENDOK
发送给家长。因此应该是这样的:

//All I have to work with are the following window handles:

//HWND hWndFileName = file name window handle
//HWND hWndSaveAsType = save as type window handle
//HWND hWndSaveBtn = Save button handle

DWORD dwComboIDSaveAsType = ::GetWindowLong(hWndSaveAsType, GWL_ID);
HWND hParWnd = ::GetParent(hWndSaveAsType);

//Select index for file type
int nSaveAsIndex = 3;
::SendMessage(hWndSaveAsType, CB_SETCURSEL, nSaveAsIndex, 0);
::SendMessage(hParWnd, WM_COMMAND, 
    MAKEWPARAM(dwComboIDSaveAsType, CBN_SELENDOK),
    (LPARAM)hWndSaveAsType);
::SendMessage(hParWnd, WM_COMMAND, 
    MAKEWPARAM(dwComboIDSaveAsType, CBN_SELCHANGE),
    (LPARAM)hWndSaveAsType);

//Set path to save
::SendMessage(hWndFileName, WM_SETTEXT, NULL, 
    (LPARAM)L"C:\\Test\\test file");

//Simulate Save button click
::SendMessage(hWndSaveBtn, BM_CLICK, 0, 0);

研究的源代码AutoHotKey@DavidHeffernan:对不起,google search给我的结果太多了。你有它的URL吗?这是google上最热门的搜索引擎,它会为你处理这样的细节。因为你似乎在使用标准的文件保存对话框,所以基础结构可用。@IInspectable:对不起,这个主题太宽泛了。你能提供一个与代码示例更相关的参考吗?