flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
Azu 16 Jan 2009, 15:37
baldr wrote: The problem is that most windows don't have title or unique window class. Finding and putting in the name of the window isn't my problem, whoever uses my program will do that. I am just trying to find a way to send key strokes to windows/programs (without activating them). Any ideas?? Attempting to manually reverse engineer every single possible program in existence and put custom code in them for my program like I did with the notepad example is obviously out of the question, it was just an example.. |
|||
![]() |
|
baldr 16 Jan 2009, 19:39
Azu,
Again: most windows don't have title and/or unique class name. If you can't find window, you can't send/post something to it. Active or not. If you can, do as you wish. keybd_event()/SendInput() simulate keystrokes, they go to the system-wide message queue, then (through the thread message queue) to the window that has focus. Inactive windows can't have focus. This is by design. May be hooks can help to track which window lost focus when program's main window was deactivated… I'll try to concoct something in that way. There was at least one game that pause itself when I Alt-Tabbed from it. BTW, I was wrong about DispatchMessage() -- it's innocent (or at least appears to be). Message given by GetMessage() is already directed to particular window (unless it's from PostThreadMessage()). _________________ "Don't belong. Never join. Think for yourself. Peace." – Victor Stone. |
|||
![]() |
|
Azu 17 Jan 2009, 02:31
Sorry what I meant was, there is no problem finding the name of the window. It shows up in the task bar. The problem is that although this seems to work for all games, which a lot of applications the GetDlgItem is needed, and I would have to put custom code for every application that exists, since the value for GetDlgItem is different for each one it seems.
So I am trying to ask if anybody has a clue how to get around this. Sorry if I didn't explain that clearly enough the first dozen times. I'm bad at asking questions I guess =/ |
|||
![]() |
|
baldr 17 Jan 2009, 20:37
Azu,
Let's make it clear. There are two distinct types of windows: overlapped/popup and child. Former can be owned by another overlapped/popup window, latter should have parent overlapped/popup/child window. That is the hierarchy. You need some language to describe owner/owned and parent/child relations between target window and [one of] top-level window[s] to find it run-time. Alternatively, you may employ WH_CALLWNDPROC hook with SetWindowHookEx() to track which window had lost focus when process became inactive (look for WM_KILLFOCUS). Any of that methods will give you handle to window to SendMessage() to. _________________ "Don't belong. Never join. Think for yourself. Peace." – Victor Stone. |
|||
![]() |
|
Azu 18 Jan 2009, 02:50
I'm not having any problems getting the handles of the windows. I'm having problems sending keystrokes to them without activating them and without making custom code for each one.
|
|||
![]() |
|
baldr 18 Jan 2009, 11:43
Azu,
You don't have problems with getting handle to window that will get focus upon activation? I mean, when window is still inactive? |
|||
![]() |
|
Azu 19 Jan 2009, 07:54
baldr wrote: Azu, Actually I'm not even sure anymore. I'm starting to think what I'm saying is just all wrong. Just go look at the two examples in the first post on the thread yourself okay because I think I am getting the words for this wrong and I'm confusing everyone and myself trying to explain it. Basically without the invoke GetDlgItem,eax,0x0000000F line it doesn't work in notepad.. with it it doesn't work in WoW.. (very simple example, this kind of problem applies to pretty much all programs I try it with not just these two). |
|||
![]() |
|
revolution 19 Jan 2009, 10:45
Azu: In my experience with sending keystrokes I found that each program has it's own way of dealing with keyboard input. You will have to customise your code for each program you want to inject into.
When activating windows you generally only need to activate the parent and Windows (with a capital W) will then also activate the child windows that are on top of the parent. It is sometimes the case that you cannot easily distinguish between child windows by window name or class name and thus you may not be able to figure out which window is receiving the keyboard strokes. For simple programs like Notepad that never open more than one child window your task is easy, but other programs may not be so friendly. Some programs don't even run the message loop so trying to send WM_* messages into those programs will have no effect at all. Some programs run the message loop but ignore all keystrokes and use other methods to detect which keys are pressed, so again, putting keystrokes into those programs will have no effect at all. Do you see the problem? |
|||
![]() |
|
Azu 19 Jan 2009, 20:17
revolution wrote: Azu: In my experience with sending keystrokes I found that each program has it's own way of dealing with keyboard input. You will have to customise your code for each program you want to inject into. Since Windows knows which windows to activate, I think it is possible. I'm just not sure how. I don't even know which function to use now.. ![]() |
|||
![]() |
|
revolution 19 Jan 2009, 20:26
Azu wrote: I don't even know which function to use now. |
|||
![]() |
|
Azu 24 Jan 2009, 16:05
revolution wrote:
![]() P.S. one more question. If there is something I have to do per program to find out what method or whatever to use, why can't a function be made to do that instead of me donig it? I don't understand =/ |
|||
![]() |
|
revolution 24 Jan 2009, 16:14
Azu wrote: If there is something I have to do per program to find out what method or whatever to use, why can't a function be made to do that instead of me donig it? I don't understand =/ Windows has a few ways to indicate to programs when keys are pressed (and released). So unless your injection code covers all the possibilities then some programs may fall through the holes and not see your injected keystrokes. |
|||
![]() |
|
baldr 24 Jan 2009, 21:50
revolution,
He may dig deeper and use KM code to inject ![]() Azu, I'll try to intercept WM_KILLFOCUS and present a sample later. _________________ "Don't belong. Never join. Think for yourself. Peace." – Victor Stone. |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.