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. SendInput

SendInput

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingarchitecturehelptutorialquestion
2 Posts 1 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.
  • M Offline
    M Offline
    Mark Donkers
    wrote on last edited by
    #1

    Does anyone have a solid example on how use SendInput(). All the examples that are out there, are in VB. Also, see my memcpy() statements. Am I copying a structure into a structure of a structure properly? BOOL fNumLockState; BYTE keys[255]; INPUT inp[2]; KEYBDINPUT kbi; GetKeyboardState( keys ); // NumLock handling: fNumLockState = keys[VK_NUMLOCK]; if( !fNumLockState ) // Turn numlock on { kbi.wVk = VK_NUMLOCK; kbi.wScan = 0; // not needed kbi.dwFlags = 0; // press the key down kbi.time = 0; // use the default kbi.dwExtraInfo = 0; // not needed memcpy( &(inp[0].ki), &kbi, sizeof(kbi) ); inp[0].type = INPUT_KEYBOARD; kbi.dwFlags = KEYEVENTF_KEYUP; // release the key down memcpy( &(inp[1].ki), &kbi, sizeof(kbi) ); inp[1].type = INPUT_KEYBOARD; if( SendInput( 2, inp, sizeof(inp) ) != 2 ) { TRACE(_T("SendInput error [%d]"), GetLastError() ); } } Marcus Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

    M 1 Reply Last reply
    0
    • M Mark Donkers

      Does anyone have a solid example on how use SendInput(). All the examples that are out there, are in VB. Also, see my memcpy() statements. Am I copying a structure into a structure of a structure properly? BOOL fNumLockState; BYTE keys[255]; INPUT inp[2]; KEYBDINPUT kbi; GetKeyboardState( keys ); // NumLock handling: fNumLockState = keys[VK_NUMLOCK]; if( !fNumLockState ) // Turn numlock on { kbi.wVk = VK_NUMLOCK; kbi.wScan = 0; // not needed kbi.dwFlags = 0; // press the key down kbi.time = 0; // use the default kbi.dwExtraInfo = 0; // not needed memcpy( &(inp[0].ki), &kbi, sizeof(kbi) ); inp[0].type = INPUT_KEYBOARD; kbi.dwFlags = KEYEVENTF_KEYUP; // release the key down memcpy( &(inp[1].ki), &kbi, sizeof(kbi) ); inp[1].type = INPUT_KEYBOARD; if( SendInput( 2, inp, sizeof(inp) ) != 2 ) { TRACE(_T("SendInput error [%d]"), GetLastError() ); } } Marcus Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

      M Offline
      M Offline
      Mark Donkers
      wrote on last edited by
      #2

      figured it out... the line: if( SendInput( 2, inp, sizeof(inp) ) != 2 ) should be... if( SendInput( 2, inp, sizeof(INPUT) ) != 2 ) Marcus Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

      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