Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Simulating pressing ctrl + c

Simulating pressing ctrl + c

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravjak
    wrote on last edited by
    #1

    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

    A R 2 Replies Last reply
    0
    • R ravjak

      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

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Use the SendInput API call James

      1 Reply Last reply
      0
      • R ravjak

        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

        R Offline
        R Offline
        ravjak
        wrote on last edited by
        #3

        Hmm 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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups