SendKeys to specific application
I want to create an Auto Login vb.net application so i'm using this code to put username and password to the specific application which is ( wow.exe ) ( World of Warcraft )
i use this following code it works but the problem if someone uses mouse or keyboard it will break ...
Code:
Dim wowp As Process = Process.Start(TextBox3.Text & "\wow.exe")
If autologin.Checked = True Then
wowp.WaitForInputIdle()
Do
If wowp.Responding Then
AppActivate("World of Warcraft")
Thread.Sleep(250)
AppActivate("World of Warcraft")
SendKeys.SendWait(TextBox1.Text)
AppActivate("World of Warcraft")
SendKeys.SendWait("{TAB}")
AppActivate("World of Warcraft")
Thread.Sleep(100)
AppActivate("World of Warcraft")
SendKeys.SendWait(TextBox2.Text)
AppActivate("World of Warcraft")
Thread.Sleep(100)
AppActivate("World of Warcraft")
SendKeys.SendWait("{ENTER}")
AppActivate("World of Warcraft")
Exit Do
End If
Loop Until 2 = 1
so i wonder if it is possible to send keys without focusing ?
Searched a lot and never found anything.
Re: SendKeys to specific application
Re: SendKeys to specific application
You should not be bumping a thread at all, let alone after less than 2 hours. Your question is not more important than everyone else's so has no priority to be at the top of the list. If you find that your question is slipping off the first page without response then you might ask yourself what is wrong with your question and make an effort to rectify the issue. Simply deciding that your question should be seen before everyone else's is not justified.
As for the question, SendKeys is a way to simulate keyboard input. Is keyboard input specific to an application? No it is not. What you type simply gets routed to the active window. That's how SendKeys works. If you want to affect a specific window then you need to specify that window and the action, which you would do with the SendMessage API function. There are lots of examples about of using FindWindow and FindWindowEx to get the handle of a specific window and then using SendMessage to set the text in that window.
Re: SendKeys to specific application
I've seen a lot of FindWindow & FindWindowEx & SendMessage methods i just couldn't manage to make it work on wow.exe "World of Warcraft" that's why i hope someone could share similar code or maybe simply make the code, thank you and sorry about bumping.
Re: SendKeys to specific application
Or, you could show us the code you tried to use and tell us what your expectations was and what actually happened. It's my personal opinion that asking others to write all the code from scratch when you might already have it 90% done is a bit presumptuous. If nothing else, seeing the code you wrote will give us some insight into your thinking and how we can help you improve it to avoid future issues.
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
Or, you could show us the code you tried to use and tell us what your expectations was and what actually happened. It's my personal opinion that asking others to write all the code from scratch when you might already have it 90% done is a bit presumptuous. If nothing else, seeing the code you wrote will give us some insight into your thinking and how we can help you improve it to avoid future issues.
The code already exist here i type it see the post
that's all the code
path = textbox3 .text
first text = textbox1.text
second text = textbox2.text
nothing more
Edit : that's the full code already
Re: SendKeys to specific application
So it would appear, then, that when you said this:
Quote:
Originally Posted by
JadaDev
I've seen a lot of FindWindow & FindWindowEx & SendMessage methods i just couldn't manage to make it work
You meant that you hadn't actually trued to make it work. I would suggest trying first, rather than just assuming that you can't do it. I have seen many occasions where people thought that something was too hard for them but, when they actually tried it for themselves, they were able to do it. Sometimes it can take some help from others but "some help" is different to "writing all your code for you".
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
So it would appear, then, that when you said this:
You meant that you hadn't actually trued to make it work. I would suggest trying first, rather than just assuming that you can't do it. I have seen many occasions where people thought that something was too hard for them but, when they actually tried it for themselves, they were able to do it. Sometimes it can take some help from others but "some help" is different to "writing all your code for you".
You won't believe me if i tell that that i've been trying to get this for nearly 1 year, well of course not full year but at least every week was trying to get it to work...
I looked for a lot of videos tutorials and much more and specially for this wow.exe i couldn't make it to work at all, i'll also give a small note that noone could find how it could be done using the FindWindowEx in the spy++ i couldn't find any class name for it that what makes it hard and most of the tutorials around uses it .... so i'm pretty stuck here for about a year or even more
another note which is i've tested and tried a lot of tricks it works for a lot of applications like ( notepad ) and other random applications but when it comes to wow.exe it won't work .. also it's not about writing all the code but as i said wow.exe is very special and it needs a specific coding i assume not like the one around online but may a trick could do it..
thanks for the answer tho.
Re: SendKeys to specific application
I don't have WoW installed to test for myself but if there's a window then there's a window handle so you can get that and call SendMessage. If there's nothing specific to identify the window then maybe you need to call EnumWindows and identify it specifically by the fact that it has no title or name. Perhaps a screenshot of the parent and child windows of interest and another of the Spy++ tree for them.
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
I don't have WoW installed to test for myself but if there's a window then there's a window handle so you can get that and call SendMessage. If there's nothing specific to identify the window then maybe you need to call EnumWindows and identify it specifically by the fact that it has no title or name. Perhaps a screenshot of the parent and child windows of interest and another of the Spy++ tree for them.
Alright i understand you, here is the info about it
The Findwindow works but FindwindowEx doesn't as i mention before.
This is a full Screenshot :
https://image.prntscr.com/image/bGWQ...KY2ZuieQew.png
https://image.prntscr.com/image/bGWQ...KY2ZuieQew.png
https://image.prntscr.com/image/aaIy...gPIQ8tIiWg.png
Re: SendKeys to specific application
It must not be creating individual child windows then, e.g. using DirectX. You might potentially be able to find the main window location and then simulate a mouse click in the correct location to focus a particular field in the window.
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
It must not be creating individual child windows then, e.g. using DirectX. You might potentially be able to find the main window location and then simulate a mouse click in the correct location to focus a particular field in the window.
What i want exactly to send the keys / text even if the window is minimized / not focused that's the main problem..
It's been only done by Blizzard ( battle.net application ) only all the available auto login application now using my method ...
I wonder about disabling the mouse & keyboard for the time it writes the information i think this could be an idea but i think disabling it will also disable the Sendkeys method..
Re: SendKeys to specific application
Quote:
Originally Posted by
JadaDev
What i want exactly to send the keys / text even if the window is minimized / not focused that's the main problem..
That would preclude using SendKeys anyway, because it simply simulates keyboard input and you can't use the keyboard to input to a window that doesn't have focus. If that window is using DirectX or the like, which seems likely for a game, there may not be anything you can do for an inactive window and little you can do beyond what I suggested for an active window. I'm afraid there's nothing more that I can suggest that I already have as this is not something I've ever tried or researched before.
Re: SendKeys to specific application
You would think if someone was lazy enough not to want to enter their user ID and password when starting the game from your application they would be willing to wait for it to login for them.
Perhaps show a modal form (or messagebox) from your application telling them to wait and not use their keyboard and mouse until you've started the application and logged in (i.e. until you close the model form).
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
That would preclude using SendKeys anyway, because it simply simulates keyboard input and you can't use the keyboard to input to a window that doesn't have focus. If that window is using DirectX or the like, which seems likely for a game, there may not be anything you can do for an inactive window and little you can do beyond what I suggested for an active window. I'm afraid there's nothing more that I can suggest that I already have as this is not something I've ever tried or researched before.
Well Blizzard did it on their Launcher tho that makes me keep trying ..
as i said a lot of developers around and creates a lot of applicatons but they couldn't find the way blizzard uses in sending the command ;)
Thanks for helping me out i appreciate it, thanks also for the advice's i hope i got this one day.
Quote:
Originally Posted by
passel
You would think if someone was lazy enough not to want to enter their user ID and password when starting the game from your application they would be willing to wait for it to login for them.
Perhaps show a modal form (or messagebox) from your application telling them to wait and not use their keyboard and mouse until you've started the application and logged in (i.e. until you close the model form).
Well it's pretty much Launcher for this game and people is supposed not to open wow.exe and put username and password manually since something is related to application side which is the register
My application will create the account for you than after registration successfully than it will open the game and log you in using the username and password. well i think my method works so good since in every sendkey it focus the client it got chance 20% to get it wrong tho i was thinking of something similar to this if it ever exist :
Something close to this :
SendKeys("THE KEY OR TEXT", "World of Warcraft")
i wonder if there is something close to this Idea
Re: SendKeys to specific application
Quote:
Originally Posted by
JadaDev
Well Blizzard did it on their Launcher tho that makes me keep trying ..
They almost certainly didn't. They are likely communicating with the application directly. It's their application so they don't have to use hacks like you do.
Re: SendKeys to specific application
Quote:
Originally Posted by
jmcilhinney
They almost certainly didn't. They are likely communicating with the application directly. It's their application so they don't have to use hacks like you do.
Battle.NET is an application and wow.exe is another application so they use the Auto Login method simple as we use but in fact they could send keys even if you're not focusing the application or typing anything else so somehow i'm sure there is a way... i hope someone could help me with this i'm so stuck :(