C
C#11mo ago
Reversal

❔ How to capture keys?

Weird question but I need to capture keys without writing into a terminal/console. I think I need to use a service but how do I know which key is pressed without writing it into a program/console/terminal whatever gui
63 Replies
Pobiega
Pobiega11mo ago
Define "capture keys"? Would your program still be in focus, or is it more or less a key logger? For a console app that still has focus, you can use var keyInfo = Console.ReadKey(true); to capture a keystroke without it being printed to the terminal
Reversal
Reversal11mo ago
Yeah, I don't want to use the term "keylogger" but it basically does kind of the same tbh. But for other purposes obviously
Pobiega
Pobiega11mo ago
You'll need to expand on those purposes 🙂
Reversal
Reversal11mo ago
need to perform a left click on another device when a key is pressed on the current device. (think I wrote that twice) tldr; When a key is pressed I need to perform a left click on the other device
Pobiega
Pobiega11mo ago
any reason why this has to be a global input listener, instead of just being a button or a local-window thing?
Reversal
Reversal11mo ago
Well...
Azrael
Azrael11mo ago
This feels oddly specific.
Pobiega
Pobiega11mo ago
I'm kinda having to drag details out of you, which makes me think you're probably up to no good to be honest.
Reversal
Reversal11mo ago
Besides that I want to know how it's possible.. I am going to use it for a game. The game does not allow autoclicker but manual clicks ofc .. or remapped keys that are pressed as a left click
Azrael
Azrael11mo ago
Do they allow virtual clicks?
Pobiega
Pobiega11mo ago
yeah, be aware that when software sends clicks, its noticable to the program receiving the click, if they care about it
Reversal
Reversal11mo ago
I mean.. if you consider left clicking with teamviewer virtual I think yes? Or even google chrome desktop thingy Hmm? I don't think they can distinguish emulated with real clicks can they?
Azrael
Azrael11mo ago
You're emulating clicks. I don't think that it's allowed.
Pobiega
Pobiega11mo ago
They can. If they bother.
Reversal
Reversal11mo ago
Teamviewer / Google desktop is emulating as well, no?
Pobiega
Pobiega11mo ago
yes
Reversal
Reversal11mo ago
Then it's 100% allowed
Pobiega
Pobiega11mo ago
Thats a curious conclusion to jump to
Reversal
Reversal11mo ago
I mean, I don't need all of this tbh if I can just plugin a keyboard that can type on 2 devices at the same time
Pobiega
Pobiega11mo ago
Do they explicitly mention that emulated/virtual clicks are ok? just get a KVM switch then
Reversal
Reversal11mo ago
They care more about user clicks rather than emulated/virtual clicks Because it's allowed to map a joystick button to a left click
Pobiega
Pobiega11mo ago
ok
Reversal
Reversal11mo ago
Does this KVM switch allow me to type on both devices at the same time?
Pobiega
Pobiega11mo ago
its a physical device, you connect your keyboard/mouse to it and it broadcasts your inputs to several computers connected to it
Reversal
Reversal11mo ago
But when I press A do I see A in both devices
Pobiega
Pobiega11mo ago
yes
Azrael
Azrael11mo ago
That's not emulation. That's called remapping.
Reversal
Reversal11mo ago
Yeah but it does a virtual click after remapping right or emulated click whatever u call it
Pobiega
Pobiega11mo ago
Depends on how the software/hardware works if the joystick driver supports remapping in it, it wont count as virtual
Azrael
Azrael11mo ago
That depends.
Pobiega
Pobiega11mo ago
but if its a pure software thing, it probably will
Azrael
Azrael11mo ago
Like he said.
Reversal
Reversal11mo ago
Again, I don't think they care about emulated clicks
Pobiega
Pobiega11mo ago
Yeah it wasnt really the core issue here. The core issue is the ethical problem, not the technical one.
Reversal
Reversal11mo ago
Yea, I mean it's up to you guys to believe me on this one. It's ok if you don't want to help me further. It will take only a bit longer Also looking on this KVM switch it doesnt look like you can type on both devices simultaniously
SinFluxx
SinFluxx11mo ago
Why would you need to type on both at once?
Azrael
Azrael11mo ago
I mean, your only solution would be to emulate them (software wise). You can do other stuff hardware wise.
Reversal
Reversal11mo ago
Alright, I guess I have to go down the rabbit hole Wanted to avoid using this dllimports and wish there was a library but I guess we have to take this path @Pobiega still got ur discord server?
Pobiega
Pobiega11mo ago
hm?
Reversal
Reversal11mo ago
Think I was in there long time ago
Pobiega
Pobiega11mo ago
The only server I "own" is my secret development lair 🙂
Pobiega
Pobiega11mo ago
Pobiega
Pobiega11mo ago
its just me and a bunch of bots 🙂 Did you perhaps mean.. uh.. Code2Gether?
Reversal
Reversal11mo ago
I think that one, u were showing us stuff with reflections and stuff
Pobiega
Pobiega11mo ago
Ah, yep. That was never my server, I just liked contributing
Reversal
Reversal11mo ago
Ahh, got link?
Pobiega
Pobiega11mo ago
Could find it if ya want, but it's not very active these days And certainly no hour of code sessions, sadly
Reversal
Reversal11mo ago
If it doesnt take much of your time I would like to be part of that server again otherwise it's fine I guess
Pobiega
Pobiega11mo ago
Dm'd
Reversal
Reversal11mo ago
This can't be true. I am pretty sure there must be a library instead of manually calling the dllimport After all those years there must be a generally accepted package
Reversal
Reversal11mo ago
GitHub
GitHub - prasannavl/WinApi: A simple, direct, ultra-thin CLR librar...
A simple, direct, ultra-thin CLR library for high-performance Win32 Native Interop - GitHub - prasannavl/WinApi: A simple, direct, ultra-thin CLR library for high-performance Win32 Native Interop
Reversal
Reversal11mo ago
Alrighty, thx folks I think we're almost done 😄
Jimmacle
Jimmacle11mo ago
This sounds like input broadcasting which for the games I play at least isn't allowed (controlling multiple instances of the game with a single action/keypress)
Reversal
Reversal11mo ago
I'm not going to control multiple instances It's close to done but all it's going to do is: send a left click when a key is pressed
SinFluxx
SinFluxx11mo ago
I thought there was a windows setting to make the num keys do mouse inputs
Reversal
Reversal11mo ago
There is BUT I am going to press a key from a different device so the keyboard is not connected to the device where it sends the left click Is it better to use tcp or udp to perform left clicks when a key is pressed
Azrael
Azrael11mo ago
TCP to ensure that it actually happens.
Reversal
Reversal11mo ago
I don't really care of it not performing a click but I do more care about the smoothness of a click so it does not really do 3-4 clicks at the same time
Azrael
Azrael11mo ago
If you're going to be performing a lot of clicks I'd still recommend TCP.
Reversal
Reversal11mo ago
Yeah I tried both tcp and udp for some reason tcp feels slightly better Even tho udp should be more performant
Jimmacle
Jimmacle11mo ago
on your local network the difference should be imperceptible
Reversal
Reversal11mo ago
Clicks feel a bit clunky tbh I feel like I need to track the time that is pressed between the buttons and then perform a click or smth 😒 This just doesnt feel right....
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts