0

I have problem when trying to read keyboard input using windows service. In Windows Form it can be done easily by using global keyboard hook and read eventargs.

But in windows service how do I set so my service can detect event when I press key in keyboard?

nb: I try to pass data from barcode scanner to my apps, my barcode scanner using keyboard wedge and the process from reading barcode scanner till save to db need to be done in background. As what I read, keyboard wedge the same as typing in keyboard. That's why I ask this question sir. If u know how to, please kindly tell me, already stuck in this since 2 days ago

  • 1
    A service is designed to be a piece of software without any ui or user interaction. What are you wanna do? – Mighty Badaboom Jul 20 '17 at 06:46
  • He tries to build a service level keylogger. This would make it possible to sniff login passwords. But still a valid question if you provided any code and describe your specific problem – Romano Zumbé Jul 20 '17 at 06:49
  • A service isn't connected to a desktop session - of which there may be zero, one or multiple. You don't get access to any of their keyboards. – Damien_The_Unbeliever Jul 20 '17 at 06:51
  • I try to pass data from barcode scanner to my apps, my barcode scanner using keyboard wedge and the process from reading barcode scanner till save to db need to be done in background. As what I read, keyboard wedge the same as typing in keyboard. That's why I ask this question sir. If u know how to, please kindly tell me, already stuck in this since 2 days ago – Felix Prawira Azali Jul 20 '17 at 06:53
  • If you need to interact with a keyboard, what thought process led to you deciding to write a service? You already know what to do - write a normal windows form application instead. – Damien_The_Unbeliever Jul 20 '17 at 06:55
  • It needs to be done in background sir, and I'm not really typing in keyboard but using barcode scanner that use keyboard wedge – Felix Prawira Azali Jul 20 '17 at 06:57
  • You can run a "normal" application without a window. Why isn't that "background" enough? – Romano Zumbé Jul 20 '17 at 07:08
  • I have an application that is very similar. The PC is in a sealed NEMA box with no keyboard, no mouse, no human interaction at all besides the barcode scanner and an LED light. LED is easy, since its serial, but USB scanner ... its causing problems. And no - auto-login to desktop isn't really an answer either. – jklemmack Oct 25 '17 at 20:19

0 Answers0