|
Sorry DavidCrow,
i did digit the code BAD.
The true code is like you digit : parentWindow=FindWindow(NULL, "Untitled - Notepad");
But now, how can i do? Can you suggest me some solution or paper?
Very tnx
|
|
|
|
|
Ismaele.Jr wrote: But now, how can i do? Can you suggest me some solution or paper?
Does the clipboard contain data in CF_TEXT format? Does SendMessage() return anything (WM_PASTE doesn't)?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Mister,
i think that i did explain bad :
My problem isn't HOW send message to objects with a handle, BUT find the 'exactly handle' of the "Edit" control of dialogbox of notepad.exe with the 'FindWindowEx' function.
It's only my fault : i'm some donkey in english language (unfortunately i'm italian !)
If you have other patience and charity for reply again, very very tnx !
|
|
|
|
|
Try edit in upper case.
childWindow=FindWindowEx(parentWindow, NULL, "EDIT", NULL);
|
|
|
|
|
Tnx but nothing,
the clipboard write again on the "Edit" control of mainwindow...not on the "Edit" control of the child dialogbox.
I'm crazyng ! 
|
|
|
|
|
So you have a dialog box open in notepad and you want to write to an edit box in that dialog?
If so, you need to get the handle to the dialog after you get the handle to notepad and then get the handle to the edit box.
HANDLE notepad = FindWindow(0, _T("Untitled - Notepad"));
HANDLE dialog = FindWindowEx(notepad, 0, 0, _T("Open"));
HANDLE edit = FindWindowEx(dialog, 0, _T("EDIT"), 0);
::SetWindowText(edit, _T("ABRACADABRA"));
|
|
|
|
|
Good morning Superman ! (or Supercoder !!!)
Very, you centred my objective.
Very tnx for the code that yuo posted me, but he doesn't compile with "Borland C++ Builder 3" under Windows XP : why?
I disclose that i admire your knowlege in C/C++ ! It's enviable
The code after your suggestion :
//---------------------------------------------------------------------------
#include <condefs.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
HANDLE notepad = FindWindow(0, _T("Untitled - Notepad"));
HANDLE dialog = FindWindowEx(notepad, 0, 0, _T("Open"));
HANDLE edit = FindWindowEx(dialog, 0, _T("EDIT"), 0);
::SetWindowText(edit, _T("ABRACADABRA"));
return(0);
}
//---------------------------------------------------------------------------
The compiler write me that : [C++Error] provaIndiano.cpp(11): Call to undefined function '_T'.
|
|
|
|
|
_T is a macro to support both UNICODE and NON-UNICODE builds.
Try without that.
int main(int argc, char **argv)
{
HANDLE notepad = FindWindow(0, "Untitled - Notepad");
HANDLE dialog = FindWindowEx(notepad, 0, 0, "Open");
HANDLE edit = FindWindowEx(dialog, 0, "EDIT", 0);
::SetWindowText(edit, "ABRACADABRA");
return 0;
}
|
|
|
|
|
something with _T being unicode or something. I read about it somewhere, but i'm not too uber leet with coding. All I know is that you must replace _T with Text("")
so it should be this...
int main(int argc, char **argv;
{
HANDLE notepad = FindWindow(0, Text("Untitled - Notepad"));
HANDLE dialog = FindWindowEx(notepad, 0, 0, Text("Open"));
HANDLE edit = FindWindowEx(dialog, 0, Text("EDIT"), 0);
::SetWindowText(edit, Text("ABRACADABRA"));
return(0);
}
That should fix your problem. I also know that if you can define _T, then it will work, but try to read up somewhere else. Sorry I don't know much, but that should get you moving.
|
|
|
|
|
Not according to Spy++.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Ismaele.Jr wrote: i wish i want to write on the "Edit" control conteined in the dialogbox "type of character", accessible by the 'notepad.exe' main menu
Hi Ismaele,
I don't see this menu option when I open Notepad. Can you show me how you are opening this child dialog?
Best Wishes,
-David Delaune
|
|
|
|
|
Adam,
if you want to help me, please read :
http://www.codeproject.com/Messages/3244725/Re-FindWindowEx-handle-and-notepad-exe.aspx
and next
http://www.codeproject.com/Messages/3244045/Re-FindWindowEx-handle-and-notepad-exe.aspx
I'm disabled and too often i wrong in writing english : excuse me !
|
|
|
|
|
i hope you want to automate the a scenario where
you copy file name in clipboard and want to open that file in notepad wthout human interaction.
is it your requirement.
if so reply so that i can help you.
Величие не Бога может быть недооценена.
|
|
|
|
|
Yes,
it is like you described !
Superman posted me this code (after the last include) :
------------------------------------
#include <condefs.h>;
#include <windows.h>;
#include <stdio.h>;
#include <string.h>;
int main(int argc, char **argv)
{
HANDLE notepad = FindWindow(0, _T("Untitled - Notepad"));
HANDLE dialog = FindWindowEx(notepad, 0, 0, _T("Open"));
HANDLE edit = FindWindowEx(dialog, 0, _T("EDIT"), 0);
::SetWindowText(edit, _T("ABRACADABRA"));
return(0);
}
------------------------------------
but the compiler show me this error : [C++Error] provaIndiano.cpp(11): Call to undefined function '_T'.
|
|
|
|
|
i think above steps may be not enough for your requirements, if you have the same requirements as i mentioned above reply then following steps are enough for your goal.
1. FindWindowEx to find the notepad mentioned above.
2. Use SetCursor and mouse_event APIs to create a automated click on the menu File.
3. Generate anotherClick to get open from the menu.
4. GetWindowFromPoint API to get the handle of the open Window.
5. Get the handle of open window, from which you can find Edit for file input.
6. Get the handle of the edit as mentioned above code and set text to the edit as mentioned above code.
Величие не Бога может быть недооценена.
modified on Thursday, October 22, 2009 7:04 AM
|
|
|
|
|
Adam Roderick J 09 wrote: 2. Use SetCursor and mouse_event APIs to create a automated click on the menu File.
Using what coordinates?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Coordinates are the offset from Notepad's ( top , left ) till Menu "File". Which is a fixed value for all the notepad's.
Величие не Бога может быть недооценена.
|
|
|
|
|
Adam Roderick J 09 wrote: Which is a fixed value for all the notepad's
Assuming a certain screen resolution and font size.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
1. YES
2. NO, on the menu "Formato" (i don't know what is the english equivalent - in italian language 'Formato' mean for 'format')
3. YES
5. YES, but for the edit-field 'type of character'
6. YES
Tnx !
|
|
|
|
|
Adam Roderick J 09 wrote:
2. Use SetCursor and mouse_event APIs to create a automated click on the menu File.
3. Generate anotherClick to get open from the menu.
4. GetWindowFromPoint API to get the handle of the open Window.
That sure sounds like alot of work. Here is how I would have recommended opening the second menu item in Notepad:
HWND pWnd;
pWnd = ::FindWindow(NULL, "Untitled - Notepad");
if(NULL != pWnd)
{
::PostMessage(pWnd, WM_COMMAND, MAKEWPARAM(2,0), 0);
}
Best Wishes,
-David Delaune
|
|
|
|
|
Yes i support this answer.
I suggest to use answer from Randor, which is more accurate.
Величие не Бога может быть недооценена.
|
|
|
|
|
|
|
Hi,
I am wondering if you have a derived CDialog
Class and call the default CDialog class thru a
intializer list passing the nidTemplate would
that create a Window handle ...m_hWnd and in that case the only reason to call
::Create is to make it modless
Thankx
|
|
|
|