Re: keybd_event,clipboard problem
On Mar 26, 9:59 pm, Norbert Unterberg <nunterb...@newsgroups.nospam>
wrote:
lencastro schrieb:
This is what i'm doing....
::keybd_event(VK_CONTROL,0,0 , 0);
::keybd_event('C',0,0, 0);
::keybd_event('C',0,KEYEVENTF_KEYUP,0);
::keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
if (::OpenClipboard(NULL))
Since Windows is a multitasking operating system, I bet that your application
tries to open the clipboard before the explorer had any chance to handle the
keyboard events that you send.
I guess you should stop after sending the keyboard events, and then wait until
the clipboard contents has actually changed. You could hook into the clipboard
viewer chain and handle the WM_DRAWCLIPBOARD message (see SetClipboardViewer
function).
Norbert
You are probably right Mr.Norbert on my problem.
I dont know about hooking concepts.
I implemented successfully in the following way.
IShellBrowser* iSB=NULL;
IShellView* iSV=NULL;
IDataObject* iDO=NULL;
HWND hwnd=FindWindowEx(NULL,NULL,"IEFRAME",NULL);
if(!hwnd)
hwnd=FindWindowEx(NULL,NULL,"CabinetWClass",NULL);
if(!hwnd)
hwnd=FindWindowEx(NULL,NULL,"ExploreWClass",NULL);
if(SUCCEEDED(iSB=(IShellBrowser*)::SendMessage(hwnd, WM_USER+7 ,
0,0)))
{
if(SUCCEEDED(iSB->QueryActiveShellView(&iSV)) )
{
if(SUCCEEDED(iSV->GetItemObject(SVGIO_SELECTION,IID_IDataObject,
(void**)&iDO)))
{
FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL };
STGMEDIUM stg;
stg.tymed = TYMED_HGLOBAL;
if (SUCCEEDED(iDO->GetData(&fmt, &stg)))
{
HDROP hDrop = (HDROP) GlobalLock ( stg.hGlobal );
UINT uNumFiles = DragQueryFile ( hDrop, 0xFFFFFFFF, NULL, 0 );
for(UINT i = 0; i < uNumFiles; i++)
{
TCHAR path[MAX_PATH];
memset(path,0x0,sizeof(path));
DragQueryFile(hDrop, i, path, MAX_PATH);
MessageBox(path,"File or Folder",NULL);
}
GlobalUnlock ( stg.hGlobal );
ReleaseStgMedium ( &stg );
}
}
}
}