C/C++ Windows API

Moderators: Lundin
Number of threads: 443
Number of posts: 1215

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Handle on Firefox and more Posted by fragmad on 20 Sept 2008 at 6:02 PM
Hi.

I got some experience with win32 programming but I fell I'd like some pointers for this.
I'm doing this program for fun and to learn.

Program: I'm gonna do a program/bot that automates the mouse movement and clicks instead of a human actually touching the mouse. So my friend has made a flash game and the bot is going to get a highscore on it (since it can execute more precise/faster then a human).

Anyways, the first thing I would like to know is, how do I get a handle on the Firefox window?

FindWindow get's handle on Firefox, and FindWindowEx gets handle on something I have no idea what it is. Is there an easy way to get handle on right windows?

And also, if anyone have done a similar program before. It would be awesome if you wanted to share pointers or source code. :)

Thanks.


Edit(!):
Like often, ppl answer their own questions. I used Spy++ to get a window handle on the correct window. But how do I use that information?

I got this, 006D03A6.
Usually you would use FindWindow and put it in a variable, and use the variable. I'm confused.


Usually:
Variable to handle: HDC hdc = GetDC(HWND);

Why can't I do this?
HDC hdc = GetDC(001E0F04); <--- info I got from Spy++.
Report
Re: Handle on Firefox and more Posted by Ed Hall on 21 Sept 2008 at 8:03 AM
First, I've only done a little in this area, but I have two thoughts to provide:

First, have you tried the hexadecimal 0x006D03A6 in your GetDC() call?

Second, to find a window, don't you need to supply the full title, i.e. for this window, I would need to use "Programmer's Heaven - Post Reply - Mozilla Firefox" as the title for the FindWindow() function.

Hope this was helpful.

Take Care,
Ed
Report
Re: Handle on Firefox and more Posted by Lundin on 22 Sept 2008 at 5:33 AM
Generally, handles to other programs are worthless, Windows won't usually allow you to send messages to them. In order to alter things in other programs as you describe, you will most likely have to run your code from within the other program.

There are several ways to do this, like injecting a dll in the other program or through hooks. I'm just a novice in that area so I can't help much. There is a lot of advanced examples on codeproject.com for this... some even work.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.