| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri May 09, 2008 1:11 pm Post subject: [help] Moving focus from one window to another |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri May 09, 2008 1:31 pm Post subject: |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri May 09, 2008 2:00 pm Post subject: |
|
|
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
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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri May 09, 2008 2:11 pm Post subject: |
|
|
Sending messages doesn't require the window to be focused, but you can simply send message to the foreground window. (HWND parameter - GetForegroundWindow() )
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri May 09, 2008 10:09 pm Post subject: |
|
|
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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat May 10, 2008 2:23 am Post subject: |
|
|
In C++ there aren't that many options
| 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 |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sat May 10, 2008 2:31 am Post subject: |
|
|
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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat May 10, 2008 3:02 am Post subject: |
|
|
The class name isn't edit then.
I told you how you can get the class name.
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sat May 10, 2008 3:04 am Post subject: |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat May 10, 2008 3:17 am Post subject: |
|
|
| Symbol wrote: | In C++ there aren't that many options
|
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 |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sat May 10, 2008 4:15 am Post subject: |
|
|
| 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 |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
|