Sending key presses to other applications without Windows Forms
Because I'm working with the Godot game engine for the graphics interface, I'm kinda restricted with their Mono implementation. That prevents me from using the windows forms stuff. So I've tried the solutions using user32.dll but they only work when I move my mouse. I assume that is happening because of the following: I have a touchscreen with a button. When that button is pressed, there should be the according key action. I think that because of the touch input, it's doing some funky stuff with the window focus and that results in the behaviour described above. Code looks as follows:
34 Replies
hmmm what, I am not sure I understood what is going on, you're using godot to write an application and not a game and your complaining it lack certain supports u would normally have?
I'm not complaining I'm simply stating that I'm having issues. But effectively, yes, I'm saying that I'm missing certain features due to the fact that I'm using Godot for this
ok but you're using it to write an application instead of a game? why was there no framework that could aid u?
Cause I don't have much time outside of school to learn something entirely new just because of this one thing. I tried Windows Forms once and hated it and I am simply not at a point where I want to invest significant time into this. It's a project for myself only and I'm not gonna rewrite everything because of this
That prevents me from using the windows forms stuff.by that I assume you mean using winform libraries?
Yes, at least thats what I've experienced. I tried adding the System.Windows.Forms dll to the project but it just won't compile. I've read that it's supposedly because of the way Godot integrates C#
yes
so you're trying to sendkeys from your godot to another application?
Yes. Imagine it as a sort of digital stream deck where pressing a button should execute a key combination (or just a single key) on another program
sure but streamdeck is linux base
what you're doing is accessing windows only api to send keys
so it would not work on any other platform
Yes and as I mentioned it's for personal use only and I'm on Windows so thats not a problem
and what are u trying to control because depending on what this would not work regardless not it being an issue with touch screen
all sorts of applications. Discord, Firefox, games like DCS or ETS 2
so essentially you want to send keys to other games so type of automation
yes
StreamDeck is hardware not Software
I'm aware, thank you
streamdeck doesn't matter he wants it for windows and at this point I am not sure I can further assist him due to break of TOS
Why did you choose to make it in Godot may I ask? Like why a game engine for an app?
Considering the game engine redraws even if the UI hasn't been changed, so you basically waste resources continuously, which is important for streamers.
See the previous conversation. I know how to use it, it provides a quick way to set up a graphical user interface and my experience with winforms was horrible
Avalonia is an option
@Citizen of Pluto he is writing bots to automate games
honestly I don't care about that little performance impact
It isn't little.
I have not experienced even the slightest drop in fps while the application was running. It's a personal use project only so nobody else is impacted by this
You do you, but as Leowest pointed out. Unfortunately we cannot help unless you have proof that you are not automating games that forbids it by the ToS.
So you are not sure whether I'm trying to cheat is basically what you are saying?
@Kaenguruu24 We don't allow help for any type of game automation because of the gray area.
Please understand it's difficult to discern the rare case where it's okay compared to the thousands of times it's not allowed and why it's a blanket statement.
Kinda sad im gonna be honest. Have a good day then
Thank you for understanding, sorry about that
well he left the server heh
s'alright. He seemed reasonable so I didn't nuke immediately.
yeah I mean its fine, I just didnt proceed to help him because he clearly stated it was for games
and the reason I was suspicious was because the game had protection against sending keys
thus why it was not working and he thou it was something else
š
oof