I have successfully sent keys to focused dos program, but anyway to pop up another window (while sending keys to dos) so that the dos is not visible by user? any example codes?thanks
Printable View
I have successfully sent keys to focused dos program, but anyway to pop up another window (while sending keys to dos) so that the dos is not visible by user? any example codes?thanks
What eactly are u trying to do? You have sent keys to a dos program with focus but you now want to send keys to one with out focus? It cant be done, unless you knew the memory location of where you are typeing in dos because the send key funtion or what not only sends keys to one with focus
what i wanted to do is send virtual keys to a dos program(is is still focused), but covered by another non-active windows.
the purpose is to avoid user to touch on the dos program so that the key sending not disturded.
just make the form the size of the screen, and have it cover the screen. I think there is an api to disable the keyboard, and then just send keys all day to that dos prompt...never mind you will lose focus hmm...there may be an ontop of command some chat programs have that where they will stay on top and so does xp and 2k when you hit ctrl alt delete and you go to the task manager...could try that make ur program the size of the screen, tell it to say on top and use the find window command to switch focus to the dos program and then disable the keyboard and start sending keys.
There are a couple of ways to send keystrokes to another program.
The first and by far the easiest is to use SENDKEYS.
SendKeys will only send keystrokes to the active application but will work if the active application is not in the foreground.
the other method requires a little API knowledge.
You will need to know the KeyCodes for the keys you want to send and, the handle of the window you are sending the keys to.
Using the PostMessage or SendMessage API calls together with the WM_CHAR windows message, you can pass the keycode of the key you want to send.
you will need to make seperate calls each time you want to send a keystroke, bt you will be able to send keys to any running proggram window using its handle. The window does not need to have the focus or even be visible.
I can post an example if anyone is interested.
Bane
I would really appreciate a complete example.
What I need is to send keystrokes to an specific program (in my case, Ultima Online - a rpg game in case you don't know what it is) but without activating the aplication.
For example, the program i'm thinking of sends a keystroke every given time (this part is covered, i know how to handle the timers) but at the same time allow me to navigate the web or do other stuff without it constantly focusing the game. This was why Sendkeys didn't work for me.
Any help would be greatly appreciated.
Thanx in advance.
Zeta
You could use the ShowWindow API and hide the console window.
Zeta,
funny you mention UO, because 2 years ago I wanted to do the same thing, so I wrote a program called MrMacro.
Lets you script macros that use sendkeys to inactive windows. It used to also have an interface to UOAssist to fire its macros and get feedback directly, but ive since removed it from the main app to make it a more generic macro program.
I'll maybe re-add this as a component later on.
Soon as I finish the current version, youre welcome to have a Beta copy if you'd like?
Thanx Bane. As soon as you have a working (or semi-working) version i'd greatly appreciate you send it to me.
Either post ir here or send it to [email protected] please.
Thanx
Zeta,
if youre looking for similar UO tools then take a look at www.easyuo.com (i think thats the correct address).
EasyUO was written specifically for Ultima Online, and uses the old peek and poke on memory addresses to fool the UO client into doing stuff just like you were sat there playing.
Thanx, but i need this to do it myself cause i need it to send the keystrokes to two diferents windows on diferent timers... i've got all done except sending specific keys to the program
I know about POSTMESSAGE, but i dunno know how to send keys, all the examples are sending WM_CLOSE.....
If you could tell me how to send F4 and F3 i'll greately appreciate it.
Thanx
See the attached example project on how to use the PostMessage and WM_CHAR windows message for sending keystrokes to inactive windows.
Its possible to do the same with mouse coords aswell, but Id need to look back at my code to remember how I did it.
Thank you very much, i finally managed to do it !!
:D:D
Could you please send me too the example of sending the keys to inactive window?
and also if you have a link to some macro-coders forum of www.eve-online.com I'll very appreciate it.
anyway i can get an example of this as well??
Quote:
Originally Posted by Bane
Yes, yes, Bane, examples, please! :p
Gosh - why don't you guys post the scripts when you're done? This is so frustrating. I feel like I've been working on this problem for months, and I get the same stuff.... Something about API and then something about WVCH. Ahg. Something so simple shouldn't take years of experience scripting. It should be instantaneous.
It looks like you forgot to attach the project.Quote:
Originally Posted by Bane
This thread is 5+ years old ;)
lol that explains a lot.
Gahhh, dang Yoda. You and your pointing-out-the-obvious stuff.
I keep getting errors when I try to do this. I have so many applications for it.
Why not just shell a batch file with the window hidden? What is it your trying to process?
I dunno, Yoda. You really make that sound easy. I guess shelling is like a jump to and hidden is obvious. Anyway, the programs I'd like to do this with aren't all available in the command line, though I did find a few command-line-oriented browsers.
It is no longer my path, Master Yoda.
I have found the beauty of c++.
I turned off warnings, my includes were iostream and Windows.h, using namespace std. The pragma comment was a lib, user32.lib.
With int main, I basically followed what was given, above. I used HWND, cout, and SendMessage, which were damned hard to understand. I had to look everywhere for guides with examples. I'd give the code, but now that I'm finished. I wish I could translate it to VB, but it seems we've parted paths. Maybe full understanding of the code comes side-by-side with its compilation, anyway.
I think that a perfect example would be simple, 'Run notepad > run notepad2 > send "Hello world" to notepad without interrupting the activity in notepad2 or making notepad the active window'.
From there, it's a simple step-by-step. After scouring the web and posting on many forums, I've yet to find the complete script. Only people who indicate that they might be capable, in theory, to generate the scripts, but how do they really know, without making the scripts?
I believe them as much as they believe themselves, but I think it's horse radish, the whole thing. Me, I'll be able to get my books, at last, without countless hours waiting, and I'll be able to do other things. Anyone else who figures it all out will be able to plug something into their games and in exchange have lives. When I really think about how many cheats I've needed, even to beat Excite Bike, I sure am glad there are people working hard on new ones.
Anyway, thanks for the feedback. Let me know if you're interested in the c++ version.
I'm not into gaming but here on VBF we dont support creating cheats or hacks for cheating at games. ;)
Well, hey, Yoda, whatever, Master. No one's saying you guys weren't capable of doing it. ;) No one's saying none of the other scripters from the other sites couldn't, either.
Anyway - it should be considered that this isn't exclusively for gaming, anymore. This is just straight-up useful. I'm glad you're keeping one kid from gaming at the expense of degrading the quality of your forums to the level of others. No offense. But about those other forums, there aren't any good guides for this stuff available. You could write a book on this one script's applications. As a matter of fact, I could think of a few ways this could prevent cheating (though I don't think I'll be making any games complex enough that they'd need prevention methods). I should be saying, 'Who cares about my views?' I usually get banned for them, though I intend them to be neutral. I think the laws of the good make the fall to evil ever-more painful, and the result of evil more hateful (like the frustration from trying to develop cheats, where help isn't available), and I think that it frustrates people in general and prevents people in general from finding equal interest to those around them. Of course, nothing can push someone toward the decline into dissonance or steepen the slope like evil. You're a good guy. *shrug*
Anyway, I don't think that the commands were intended for gaming, when they were created. I know that you can use these same commands to do things like change Winamp songs and get back the song names so that they appear in your own personally-created plugins for... whatever. Usually the story, then, is, 'we don't support notepad or Winamp or whatever they might plug into,' though.... ;) The truth is, if people think about legit examples and theoretical explanations, there's no going wrong.
Anyway - I don't think this is a good topic for the forums, anyway. I get the feeling that this is what skiers call an 'expert-only' run. There are books with the commands listed. They just require a little prior knowledge.
Programming isn't like breathing - if you want to be able to do it you have to put in the time and effort to learn to do it. If you want someone else to do it for you, you're at the wrong site. Try Rent-A-Coder. You pay in effort or you pay in money, but you pay.Quote:
Originally Posted by Fisthankbeta