Question Check for KeyPressing

MikeyJY

Member
Joined
Sep 19, 2021
Messages
11
Programming Experience
5-10
I have a RenderLoop which runs for every frame. I need to do specific things when the wasd and other keys are pressed. Preferable without an event:
C#:
void RenderLoop(){ //called 1 per frame avg 60 times/s
    if(w pressed){ 
        //MoveForward
    }
    
}
 
Your last thread indicated that you weren't using WinForms but that you did want to use an event. Now you are using WinForms but you don't want to use an event. You're not making this seem any less suspicious. I won't close this thread but I think that you ought to provide a full explanation of what you're actually doing because your last thread made it sound very much like you were creating a keylogger.
 
Sounds fishy to me... No pun intended when considering our OP's avatar and dolphin's propensity for fish.
 
This post is about a game I'm trying to develop using c# and I'm trying to create the user input. The post where I tried to check key presses with a background app was for another project where I try to steal credit card info and passcodes(just kidding). I tried to make a background app that detects when I press return + shift keys and that runs the ipconfig /flushdns in windows. I need to reset the dns cache very often and I'm trying to make a simple program that does this at the press of 2 keys and I don't want the program to have a window for my workflow to be clean. I understand that this information can be used to create fraudulent apps and I understand this forum can't help me with that.
 
If you are developing a game, it will have a UI. The UI will have the focus. This all becomes moot because if it's a Windows game, then you'll get all the key down events when it has the focus. If it's a DirectX game, you'll get all the DirectInput events when it has focus. You can always send messages to your background app from your game.

A background app sounds more like a game cheat or a trainer for someone else's game.
 
If you want to react to a specific key combination then you can use the RegisterHotKey API to receive notification for that key combination specifically. There's no need to receive all keyboard input and filter yourself.
 
I need to reset the dns cache very often
Why? Games want a stable connection to their servers. Why would you want to keep flushing the DNS cache unless you are dorking around with DNS to intercept a game's communication with the server to insert a proxy or do a man-in-the-middle attack? If it's your own game, why would you intercept your own traffic when you have ready access to it as the developer? Smells really fishy to me.
 
Okay... so why would that key check then be in your render loop as per your post #1?
 
Last edited:
What you're asking for sounds nefarious, if not downright malicious. The fact that you seem to be evasive about what you're actually trying to achieve just makes it seem even more so. If you aren't prepared to provide a FULL and CLEAR explanation of what you're trying to achieve then we are going to assume that it is nefarious and you're not going to get the help you want.
 
I need to reset the dns cache very often and I'm trying to make a simple program that does this at the press of 2 keys and I don't want the program to have a window for my workflow to be clean.
If you just need this for your workflow, install and configure AutoHotKey.
 
Back
Top Bottom