|
In the name of code reuse, does anyone have pointers to articles that give examples of how to automate another app?
Scenario: I'm writing an app that helps me do part of my job much faster. However, I must still manually copy and paste data from an existing .NET app into mine.
Therefore, I'm looking for code examples of how to programmatically control the other app the way I would do so manually.
Ex:
1) F4, enter data, press enter
2) Copy from fields
3) etc.
Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it.
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
-- modified at 23:47 Monday 27th March, 2006
|
|
|
|
|
Tom Archer - MSFT wrote: Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it.
Is this[^] what you want?
Nibu thomas
Software Developer
|
|
|
|
|
Thanks Nibu. That gets me the SendKeys bit, but the hardest part is getting the data from other app. Generally, that's not too difficult with a standard Windows app. However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on.
Therefore, what I'm looking for is an example of a C++ program driving a .NET application and basically screen scraping from the .NET apps windows.
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
|
|
|
|
|
Tom Archer - MSFT wrote: However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on.
With a .NET Framework-based application, the window messages and classes intercepted by Spy++ don't correspond to anything useful. You want to see managed events and property values. See here for more.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Yep. I remembered this article last night. It's not 100% what I wanted in that it doesn't show how to find a particular window or what I'm capable of searching for, but it's definitely a start.
Thanks David.
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
|
|
|
|
|
Can anyone tell me what are the diiferences between Visual C++ and Managed Extensions for Visual C++, in terms of code, not architecture? I'm relatively new to VC++.
|
|
|
|
|
Are you looking for MC++ or CLI?
MC++ is the original Managed Extensions syntax for writing .NET code with C++
C++/CLI is the new syntax introduced with Visual C++ 2005
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
|
|
|
|
|
I want to write a program to capture the displaying content on entire screen, whatever it's displayed by OpenGL, DirectX, or Window GDI. I wonder it might be a hard-to-slove issue, maybe need to write a Display-Card drive, anyway, i have no idea. Please help.
|
|
|
|
|
no its possible and easy to do. check this[^] article for how to do it. Dont get confused with section about directx, using GDI will be sufficient directx is just another way to do it.
-Saurabh
|
|
|
|
|
Thank you for your replying. Yeah, before i post i've been already read this article. Actually, it's a bit out of my question, that's it's just for capturing screen contents that diaplyed by DirectX or Windows GDI, but doesn't work if displayed by OpenGL as i think and many friends suggested so. Is there any only one way to capture the screen's content whatever where they're come from? Thanks a lot!
|
|
|
|
|
So sorry that i just realized the article you suggested can solve my question for both DirectX drawing or OpenGL drawing, i guess maybe the DirectX Way of captuing captures the content directly from Displaying-Card, so great! Thank you!
|
|
|
|
|
I have a set of custom controls (for pushbutton, checkbox and radiobutton) originally written in C++ and using standard GDI. Last year I added support for UxTheme API, and everything seems to work okay.
Right now, I'm adding GDI+ support, and most things seem to work fine. The only problem is that I can't get UxTheme API and GDI+ to work together perfectly. It's *almost* right, but not quite.
The code for this looks roughly like:
hdcScrn = BeginPaint( hwnd, &ps );<br />
hdcOffscreen = CreateCompatibleDC( hdcScrn );<br />
hbmpBuffer = CreateCompatibleBitmap( hdcScrn, nWidth, nHeight );<br />
SelectObject( hdcOffscreen, hbmpBuffer );<br />
<br />
<br />
DrawThemeBackground( hTheme, hdcOffscreen, BP_PUSHBUTTON, nState, lprcClient, NULL );<br />
<br />
BitBlt( hdcScrn, 0, 0, nWidth, nHeight, hdcOffscreen, 0, 0, SRCCOPY );<br />
The new GDI+ version is pretty similar, except that I'm using Graphics* and Bitmap* objects. When I get to the part for DrawThemeBackground, I'm doing this:
hdcReal = hGrfx->GetHDC();<br />
DrawThemeBackground( hTheme, hdcReal, BP_PUSHBUTTON, nState, lprcClient, NULL );<br />
hGrfx->ReleaseHDC( hdcReal );<br />
The problem is, when I draw the offscreen buffer back to the screen, the edges of the pushbutton are too dark. It looks almost as if UxTheme call is not using alpha correctly, so the outer edges are too dark.
I'm not sure if there's a good way to post screenshots on the site, so I've posted them on my own site.
std GDI version
GDI+ version
As you can see, the dialog background is a custom texture, so I don't think I can call DrawThemeParentBackground.
Anyone hints or help on this would be greatly appreciated.
--
Warner Young
|
|
|
|
|
I am about to switch to using VC++ 2005 Standard as my main development platform, and after reading a previous blog on the new Visual Studio 2005 I know I need to...
1) Patch the STL header directly by doing the following to fix the major STL stream leak bug. This saves having to rebuild the CRT library and then shipping this with your app :
1) Open up istream in \Program Files\Microsoft Visual Studio 8\VC\Include<br />
2) Before line 29, insert the following code<br />
<br />
explicit __CLR_OR_THIS_CALL basic_istream(_Mysb *_Strbuf, bool _Isstd, bool _Noinit)<br />
: _Chcount(0)<br />
{
if (!_Noinit)<br />
_Myios::init(_Strbuf, _Isstd);<br />
}<br />
<br />
3) In the same file (istream), look for the following line:<br />
<br />
: basic_istream<_Elem, _Traits>(_Strbuf, false),<br />
<br />
and change it to:<br />
<br />
: basic_istream<_Elem, _Traits>(_Strbuf, false, true),<br />
2) Due to built-in search being slow, use a macro so searches can be performed using Google or MSDN2 from within the IDE
See the following link for more info
http://www.r2musings.com/GoogleMSDNSearchWithinVisualStudio2005.aspx
Is there anything else (tips, problems) that's worth knowing ?
|
|
|
|
|
My program(.exe) is running in Win2K or XP Service Mode.
But some users has killed my process by decending the Service T_T;
i did that some process rescued my process (by excuting) but my process is killed in safe mode.
HOW DO I DO THAT~~~!!!
please give me a answer...
|
|
|
|
|
this is how the earth rounds in windows' world
|
|
|
|
|
I have a WindowsXP memory question. I have a program with one thread and a windows messageloop that runs in mainprocessthread. I create two windows. The memory usage is about 1mb, I minimize one window, and the same memory usage. But when I minimize the second widow so all windows are minimized the memory usage goes down to 200k. I have tried to simulate this programmaticaly (minimize all windows) but I have only managed to get WindowsXP to cache away the memory when I minimize the windows manually... anyone got any info on this?
-----------------------------
I am out of scope
|
|
|
|
|
|
My script language app (in C++) can create Toolbars using either system image list icons or app image list icons. Depending on the app control script code, an app toolbar is created in a loop that adds buttons as needed, by sending a TB_ADDBUTTONS message. A little later in the code I send a TB_ADDBITMAP message. This all works fine, and has done for years.
I now want to set a custom button icon by creating a bitmap (of the appropriate size) in memory, then specify this as the button bitmap, rather than loading a Resource. It seems simple enough: in the TBADDBITMAP structure, set the hInst to NULL , and the nID to the handle of the bitmap I created. Then send TB_ADDBITMAP message as before.
I note that the TB_ADDBITMAP message returns a 2. When I add an image from a Resource image list, it returns a 1. Not sure if this is important or not. The message "Returns the index of the first new image". The result is that my toolbar does not display the image I created, instead I get the default button Icon from my script.
I've been through all the TB_ messages to see if I've missed something, and tried a lot of stuff that still won't work.
Is replacing a toolbar icon resource image with a synthesized image actually possible?
Alternatively, is it possible to draw in the toolbar button image? Various test code ideas seems to suggest not.
Stewart DIBBS
|
|
|
|
|
I had exactly the same problem last week. Though it was not when adding a bitmap it was adding text. It may be the same for you. Try creating the toolbar with an extra button, you may find that on your second call to TB_ADDBITMAP, you are actually creating a new button.
You need to create your TBBUTTONS struct, complete with text and bitmaps before calling createtoolbar/createwindow. If you are having any other problems, show me the code you are using to create the toolbar.
|
|
|
|
|
Dear All;
I am trying to create a child dialog on a dialog parent which contains an activex control (ie. microsoft web browser). Upon clicking the button which creates the child dialog, the child appears quickly and then disappears forever.
I dont know but it looks like the activex control is overriding the child dialog !!!
any ideas ?
void CParentDlg::OnBnClickedButton3()
{
// TODO: Add your control notification handler code here
ChildDlg child;
child.DoModal();
//child.ShowWindow(SW_SHOW);
}
llp00na
|
|
|
|
|
Do you see the ActiveX control? Have you called CoInitialize() ?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yes i see the activex control. And no i have not called CoInitialize(). What is it for ?
llp00na
|
|
|
|
|
It appears that the child dialog is encountering an error which is causing it to abort the DoModal() call. Try single-stepping into the DoModal() call with the debugger to see what is causing it to abort.
CoInitialize() is used to initialise COM support in your application. It should be called in any thread that uses COM. Use CoInitializeEx() instead if your application is multi-threaded.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
okey, i tried single stepping into DoModal() but i could not specify the problem. Besides that, whenever the parent dialog is minimised and maximised again i get the dialog child shown !!!
I am developing a single threaded application.
llp00na
|
|
|
|
|
another things i wana point out. I have tried placing the child window (by specifyin the x, y) in such a way that half of the child dialog is covered by the activex control and the other half is on the parent client area. and guess what ?
half of the child dialog (strictly talking about the part that is on the parent client area) is shown and the other half (being covered by the activex control) is not shown.
Any ideas ???
llp00na
|
|
|
|
|