Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[help] Moving focus from one window to another

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri May 09, 2008 1:11 pm    Post subject: [help] Moving focus from one window to another Reply with quote

i'm trying to move the focus from one window to other but i have few problems.
i killed the focus to the focused window and then set the focus to the window i wanted
well it was a little wierd though, it did set the focus on the window i wanted
but it was also still focused on the previous window as well, i saw the cusor on the new window (which means that this window got the focus)
but when i wanted to write something in it nothing of the keyboard keys was responsing (like there was no keyboard focus) :S i hope you understood the problem XD

_________________
Stylo
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri May 09, 2008 1:17 pm    Post subject: Reply with quote

SetFocus
The SetFocus function sets the keyboard focus to the specified window.
- http://msdn.microsoft.com/en-us/library/ms646312(VS.85).aspx


SetActiveWindow
The SetActiveWindow function activates a window.
- http://msdn.microsoft.com/en-us/library/ms646311(VS.85).aspx


SetForegroundWindow
The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.
- http://msdn.microsoft.com/en-us/library/ms633539(VS.85).aspx

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri May 09, 2008 1:31 pm    Post subject: Reply with quote

awesome!! thx
but when i wanna write something on the window that got the focus with postMessage:
PostMessage(hwnd,0x102,0x5A,0); // 0x102 = wm_char, 0x5A = 'z'
nothing is written to the window (it's notepad btw)

_________________
Stylo
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri May 09, 2008 2:00 pm    Post subject: Reply with quote

Notepad is the window, so when you send text using WM_CHAR its being sent to its WINDOW but what you want to send text to is its EDIT control Wink

So using FindWindow and FindWindowEx you won't even need to Set any focus.

Code:

TCHAR tszText[MAX_PATH];
_tcscpy( tszText, _T("This is my message") );
HWND hNotepad = FindWindow( _T("Notepad"), NULL );
HWND hNotepadEdit = FindWindowEx( hNotepad, NULL, _T("EDIT"), NULL );

for ( int i = 0; i <= _tcslen(tszText); i++ )
   PostMessage( hNotepadEdit, WM_CHAR, (WPARAM)tszText[i], 0 );

_________________
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri May 09, 2008 2:11 pm    Post subject: Reply with quote

Sending messages doesn't require the window to be focused, but you can simply send message to the foreground window. (HWND parameter - GetForegroundWindow() Razz )
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri May 09, 2008 10:09 pm    Post subject: Reply with quote

oh now i got it thank you very much guys
but how can i know the name of the edit class on each window?
for example the messenger is it still "EDIT" ? or it can be changed?

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat May 10, 2008 2:23 am    Post subject: Reply with quote

In C++ there aren't that many options Razz
Code:
System class Meaning
BUTTON Designates a small rectangular child window that represents a button the user can click to turn it on or off. Button controls can be used alone or in groups, and they can either be labeled or appear without text. Button controls typically change appearance when the user clicks them. For more information, see Buttons.

For a table of the button styles you can specify in the dwStyle parameter, see Button Styles.
 
COMBOBOX Designates a control consisting of a list box and a selection field similar to an edit control. When using this style, an application should either display the list box at all times or enable a drop-down list box. If the list box is visible, typing characters into the selection field highlights the first list box entry that matches the characters typed. Conversely, selecting an item in the list box displays the selected text in the selection field.

For more information, see Combo Boxes. For a table of the combo box styles you can specify in the dwStyle parameter, see Combo Box Styles.
 
EDIT Designates a rectangular child window into which the user can type text from the keyboard. The user selects the control and gives it the keyboard focus by clicking it or moving to it by pressing the TAB key. The user can type text when the edit control displays a flashing caret; use the mouse to move the cursor, select characters to be replaced, or position the cursor for inserting characters; or use the BACKSPACE key to delete characters. For more information, see Edit Controls.

For a table of the edit control styles you can specify in the dwStyle parameter, see Edit Control Styles.
 
LISTBOX Designates a list of character strings. Specify this control whenever an application must present a list of names, such as file names, from which the user can choose. The user can select a string by clicking it. A selected string is highlighted, and a notification message is passed to the parent window. For more information, see List Boxes.

For a table of the list box styles you can specify in the dwStyle parameter, see List Box Styles.
 
MDICLIENT Designates an MDI client window. This window receives messages that control the MDI application's child windows. The recommended style bits are WS_CLIPCHILDREN and WS_CHILD. Specify the WS_HSCROLL and WS_VSCROLL styles to create an MDI client window that allows the user to scroll MDI child windows into view.

For more information, see Multiple Document Interface.
 
RichEdit Designates a Microsoft Rich Edit 1.0 control. This window lets the user view and edit text with character and paragraph formatting, and can include embedded Component Object Model (COM) objects. For more information, see Rich Edit Controls.

For a table of the rich edit control styles you can specify in the dwStyle parameter, see Rich Edit Control Styles.
 
RICHEDIT_CLASS Designates a Rich Edit 2.0 control. This controls let the user view and edit text with character and paragraph formatting, and can include embedded COM objects. For more information, see Rich Edit Controls.

For a table of the rich edit control styles you can specify in the dwStyle parameter, see Rich Edit Control Styles.
 
SCROLLBAR Designates a rectangle that contains a scroll box and has direction arrows at both ends. The scroll bar sends a notification message to its parent window whenever the user clicks the control. The parent window is responsible for updating the position of the scroll box, if necessary. For more information, see Scroll Bars.

For a table of the scroll bar control styles you can specify in the dwStyle parameter, see Scroll Bar Control Styles.
 
STATIC Designates a simple text field, box, or rectangle used to label, box, or separate other controls. Static controls take no input and provide no output. For more information, see Static Controls.

For a table of the static control styles you can specify in the dwStyle parameter, see Static Control Styles.


For example, a button in delphi would be TButton.

You could also make a program that shows class names using:
GetCursorPos
WindowFromPoint
ChildWindowFromPoint
GetClassNameA/W
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat May 10, 2008 2:31 am    Post subject: Reply with quote

ok so from what i can see here the name of class for TextBox will be Edit, on every window?
when i get the handle to the conversation window in MSN i call FindWindowEx(hwnd,NULL,"Edit",NULL);
i get nothing :\

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat May 10, 2008 3:02 am    Post subject: Reply with quote

The class name isn't edit then.
I told you how you can get the class name.
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sat May 10, 2008 3:04 am    Post subject: Reply with quote

MSN is like an exception I think. The conversation window doesn't have any child windows for some reason. MSN just made their own type of textboxes or something.
By the way, if you want the (class)names of windows and child windows, I recommend AutoItWindowInfo. It's a little tool that comes with AutoIt. (You can find it on google, it's free)
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat May 10, 2008 3:17 am    Post subject: Reply with quote

Symbol wrote:
In C++ there aren't that many options Razz


http://msdn.microsoft.com/en-us/library/bb773173.aspx

1qaz wrote:
oh now i got it thank you very much guys
but how can i know the name of the edit class on each window?
for example the messenger is it still "EDIT" ? or it can be changed?


Just use SPY++
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat May 10, 2008 3:27 am    Post subject: Reply with quote

i used spy ++ already but it cant find the edit window :S
i'm using winspector spy not spy ++ i think they're the same
but all i get from that is DirectUIHWND
anyway i'll try to get the class name through the functions that symbol post before.. i hope i'll get it Confused

_________________
Stylo
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sat May 10, 2008 4:15 am    Post subject: Reply with quote

When I tried to write to the msn window I had the same problem, it'll say DirectUIHWND and no child windows...
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat May 10, 2008 4:33 am    Post subject: Reply with quote

x0r that's what i ment to
but what you have in your picture is the edit class for notepad
i'm looking for the msn conversation window one Surprised

_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites