Simulating pressing ctrl + c
-
Hi. I have problem with simulating pessing ctrl+c. I'm subclassing an listview control and I want "press" ctrl +c. This is not a problem of focus because I tryed this in such a way:
HOOKS32_API LRESULT CALLBACK MessageListProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { case WM_KEYDOWN: { int key=(int)wParam; if(key=='D' || key=='d') { PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x0001D001); PostMessage(hwnd,WM_KEYDOWN,(WPARAM)'C',(LPARAM)0x002E001); PostMessage(hwnd,WM_KEYUP,(WPARAM)VK_CONTROL,(LPARAM)0xC001D001); PostMessage(hwnd,WM_KEYUP,(WPARAM)'C',(LPARAM)0xC02E001); return 0; } } } return CallWindowProc(gfnMessageListProc, hwnd, uiMsg, wParam, lParam); }
WPARAM values are the same as I found it using spy++. (0x00000000 and for UP 0xC0000000 not working too) I want to copy in this way content of a listview item to clipboard. Probably this may fail because in control code to check if ctrl is still pressed GetKeyState(VK_CONTROL) function is used. So this a question: Is my code in some sence wrong or is there any other way of simulating ctrl +c pressing Pain is a weakness living the body -
Hi. I have problem with simulating pessing ctrl+c. I'm subclassing an listview control and I want "press" ctrl +c. This is not a problem of focus because I tryed this in such a way:
HOOKS32_API LRESULT CALLBACK MessageListProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { case WM_KEYDOWN: { int key=(int)wParam; if(key=='D' || key=='d') { PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x0001D001); PostMessage(hwnd,WM_KEYDOWN,(WPARAM)'C',(LPARAM)0x002E001); PostMessage(hwnd,WM_KEYUP,(WPARAM)VK_CONTROL,(LPARAM)0xC001D001); PostMessage(hwnd,WM_KEYUP,(WPARAM)'C',(LPARAM)0xC02E001); return 0; } } } return CallWindowProc(gfnMessageListProc, hwnd, uiMsg, wParam, lParam); }
WPARAM values are the same as I found it using spy++. (0x00000000 and for UP 0xC0000000 not working too) I want to copy in this way content of a listview item to clipboard. Probably this may fail because in control code to check if ctrl is still pressed GetKeyState(VK_CONTROL) function is used. So this a question: Is my code in some sence wrong or is there any other way of simulating ctrl +c pressing Pain is a weakness living the body -
Hi. I have problem with simulating pessing ctrl+c. I'm subclassing an listview control and I want "press" ctrl +c. This is not a problem of focus because I tryed this in such a way:
HOOKS32_API LRESULT CALLBACK MessageListProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { case WM_KEYDOWN: { int key=(int)wParam; if(key=='D' || key=='d') { PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x0001D001); PostMessage(hwnd,WM_KEYDOWN,(WPARAM)'C',(LPARAM)0x002E001); PostMessage(hwnd,WM_KEYUP,(WPARAM)VK_CONTROL,(LPARAM)0xC001D001); PostMessage(hwnd,WM_KEYUP,(WPARAM)'C',(LPARAM)0xC02E001); return 0; } } } return CallWindowProc(gfnMessageListProc, hwnd, uiMsg, wParam, lParam); }
WPARAM values are the same as I found it using spy++. (0x00000000 and for UP 0xC0000000 not working too) I want to copy in this way content of a listview item to clipboard. Probably this may fail because in control code to check if ctrl is still pressed GetKeyState(VK_CONTROL) function is used. So this a question: Is my code in some sence wrong or is there any other way of simulating ctrl +c pressing Pain is a weakness living the bodyHmm I did it here is a code
// Simulate a key press keybd_event( VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 ); keybd_event( 'C', 0x45, 0, 0 ); // Simulate a key release keybd_event( 'C', 0x45, KEYEVENTF_KEYUP, 0); keybd_event( VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
Pain is a weakness living the body