-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PressBackground not working #3
Comments
Make sure you are compiling your app as x86 Justin Schuhmann
|
I am sure, anyway sending background doesn't work, program runs, but reciever in my case notepad++ doesn't recieve anything. |
The pid is likely wrong, I know when I used this I had to send it to a child process of the main app. Spy++ is your friend
|
I'm having a similar problem. Built as x86 in VS 2010. BackgroundKeyboardDemo works great at sending all the text to the richtextbox it creates, but it partially fails on some external programs. In the BackgroundKeyboardDemo source, I commented out the "var procId = Process.GetCurrentProcess().MainWindowHandle;" line and added "var procId = (IntPtr) 0x010A076C;" which is the window handle of an open Cmd window (according to Spy++). This also works just fine. "hello world" is sent followed by an Enter which naturally results in an error, then the Cmd window receives the "sent one key at a time" text. However, when I run the demo using the window handle of an open Notepad window, I get the "hello world" text from SendChatTextSend(), but it doesn't receive the Enter or the "sent one key at a time" text. Just to be thorough, I tried all three of the window handles of Notepad exposed in Spy++ (title bar, edit, and status bar). Only the Edit window receives text, but it only gets partial text. Anything you could suggest? |
It appears notepad doesn't accept VK_RETURN as a SendMessage, it does accept it in a PostMessage. Meaning for some reason using: Messaging.SendChatTextPost(notepadTextbox, "hello world!!!");
Messaging.SendChatTextPost(notepadTextbox, "test!!!"); this will work, partly. In notepad you don't actually need to send the keystrokes individually and can use I should probably clean this library up so that it is a little cleaner, since a lot of what I just mentioned don't have easy fixes without changing the base library which means it is not as extensible as I would like.. |
Looks like PostMessage() can handle Enter, but not shift (upper case letters appear as lower and symbols as numbers). I think I can hobble together a way to automate various programs by using SendMessage() for text and symbols, and then PostMessage() for special keys like enter and tab, but I'll keep an eye on this if you rework it! |
This code has some issues (unessecary recursions e.g.). The one you are referring to is the mismatch of the shift key codes. I tried to refactor it but got near a complete rewrite and it's even not working correctly yet. I finally gave up. (I'm about to use InputSimulator). Nevermind: According to MSDN shift values are as follows:
In Messaging.cs ALT is mistaken with SHIFT. I hope this helps a bit. |
You can't use post message or send message to do any of those system keys.
Only the keyboard which effects the global keyboard works on that
…On Fri, Dec 2, 2016 at 9:35 AM Tobias Gärtner ***@***.***> wrote:
This code has some issues (unessecary recursions e.g.). The one you are
referring to is the mismatch of the shift key codes. I tried to refactor it
but got near a complete rewrite and it's even not working correctly yet. I
finally gave up. (I'm about to use InputSimulator
<https://www.nuget.org/packages/InputSimulator/1.0.4>).
Nevermind: According to MSDN
<https://msdn.microsoft.com/en-us/library/ms646329.aspx> shift values are
as follows:
[Serializable, Flags]
public enum ShiftType
{
NONE = 0x0,
SHIFT = 0x1,
CTRL = 0x2,
SHIFT_CTRL = SHIFT | CTRL,
ALT = 0x4,
SHIFT_ALT = ALT | SHIFT,
CTRL_ALT = CTRL | ALT,
SHIFT_CTRL_ALT = SHIFT | CTRL | ALT
}
In Messaging.cs
<https://github.com/EasyAsABC123/Keyboard/blob/master/Keyboard/Messaging.cs#L372>
ALT is mistaken with SHIFT.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw-4D5zZQIpB_i1j0frLBKiaA3GFPCvks5rECycgaJpZM4J1kIH>
.
|
updated codes |
Unfortunately
still doesn't work : ( Trying to send keys to notepad2 using a 64-bit application. |
Sure the code that picks the hwnd
…On Tue, Sep 18, 2018 at 2:27 PM IneedHelp ***@***.***> wrote:
Unfortunately
var key = new Key(Messaging.VKeys.KEY_1);
var success = key.PressBackground(hWnd: windowHandle);
still doesn't work : (
Trying to send keys to notepad2 using a 64-bit application.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw-4K_KkvTfwwMDhF5nK6svsy2fubBuks5ucTsLgaJpZM4J1kIH>
.
|
Yes, the hwnd is good because it works when used with PressForeground (although it only works if the window is not minimized, only if it's in the background or focused), but PressBackground has no effect (no matter what state the window is in: minimized, in the background or focused), yet it returns true. |
They work differently and forgive works with any hwnd in the process at all
background doesn't
…On Tue, Sep 18, 2018 at 2:39 PM IneedHelp ***@***.***> wrote:
Yes, the hwnd is good because it works when used with *PressForeground*
(although it only works if the window is not minimized, only if it's in the
background or foxused), but *PressBackground* has no effect, yet it
returns true.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw-4J5x1o2HWcki9Q3aUPbfH-XnwO1sks5ucT3lgaJpZM4J1kIH>
.
|
So it's possible that it might not work at all? What other hwnd can I get for background than the window hwnd? |
The textarea hwnd, you can find this with Spy++
…On Tue, Sep 18, 2018 at 2:44 PM IneedHelp ***@***.***> wrote:
So it's possible that it might not work at all? What other *hwnd* can I
get for background than the window *hwnd*?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw-4HiaJm4GbRjRCyUAnGcgaa-renwTks5ucT78gaJpZM4J1kIH>
.
|
I understand, thank you for the help. |
One more question regarding Because I am trying it with Discord and Spotify and it doesn't when using However, |
This might not work with all apps it was developed for aion online and I
just decided why not share it. Definitely no guarantees about all apps.
Background keypresses aren't the simplistic items there are. If you need a
fool proof method you'd want to dll inject a keyboard hook that manages
keyboard state. Then it needs to have an api that listens for messages and
injects the keys onto the keyboard state
…On Fri, Sep 21, 2018 at 6:20 AM IneedHelp ***@***.***> wrote:
One more question regarding PressBackground, is it known that application
developed with Atom like Discord and Spotify don't accept any messages when
not focused?
Because I am trying it with Discord and Spotify and it doesn;t seem to
work when using PressBackground and this time I'm getting the correct
window handles, there's just 2 of them:
[image: image]
<https://camo.githubusercontent.com/73227da6c56be6c467587ac577f8b46325abc55d/68747470733a2f2f692e696d6775722e636f6d2f6f68514a6551572e706e67>
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw-4F37IRSeS-z_trStU4DvFQ9KyleUks5udL1RgaJpZM4J1kIH>
.
|
I understand. Thank you for the information. |
I tried with visual studio 2015 (run as administrator), windows 10, sending keys in background application like notepad++ or wordpad or calculator and it doesn't work. nothing shows in these apps
The text was updated successfully, but these errors were encountered: