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 


C++ & API's

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
spectrum
Expert Cheater
Reputation: 0

Joined: 27 Mar 2007
Posts: 143

PostPosted: Sun Apr 13, 2008 11:05 am    Post subject: C++ & API's Reply with quote

Ok, so now I've learned c++ i want to really do something with it that interests me, but i've discovered that i need to know the apis to do that.
but it seems very hard to me to learn them, so if someone could wirte a simple program like that attaches to notepad when open and writes something i would appreciate that. thanks Very Happy

_________________
C++ {||||||||||}
ASM {||||||||||}
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: Sun Apr 13, 2008 11:08 am    Post subject: Reply with quote

FindWindowA/W, SendInput.
Back to top
View user's profile Send private message
spectrum
Expert Cheater
Reputation: 0

Joined: 27 Mar 2007
Posts: 143

PostPosted: Sun Apr 13, 2008 11:12 am    Post subject: Reply with quote

yea well, but how do i use them? its like i don't know nothing like where to put them. so make me the program pleeeeeeeeeeeeease Smile i'll rep and suck (?)
_________________
C++ {||||||||||}
ASM {||||||||||}
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Apr 13, 2008 11:24 am    Post subject: Reply with quote

Lmao

Code:

#include <windows.h>
#include <tchar.h>

HWND hNotepad;
HWND hNoteEdit;
TCHAR tszString[260];

int main( int argc, TCHAR *argv[] )
{
    hNotepad = FindWindow( _T("Notepad"), NULL );
    if ( !hNotepad ) return 0; // Coudnt find Notepad.
    hNoteEdit = FindWindowEx( hNotepad, NULL, _T("EDIT"), NULL );
    if ( !hNoteEdit ) return 0; // Coudnt find Notepad edit control.
   
    _tcscpy( tszString, _T("Print This") );
    for ( int i = 0; i <= _tcslen(tszString); i++ )
        PostMessage( hNoteEdit, WM_CHAR, tszString[i], 0 );

    _gettchar();
    return 0;
}


just did it in notepad, should work.

_________________
Back to top
View user's profile Send private message
spectrum
Expert Cheater
Reputation: 0

Joined: 27 Mar 2007
Posts: 143

PostPosted: Sun Apr 13, 2008 11:30 am    Post subject: Reply with quote

uh it doesn't compile, it says its missing a ")" before ";" token..i would correct it myself but i have no idea where that should be
_________________
C++ {||||||||||}
ASM {||||||||||}
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: Sun Apr 13, 2008 11:46 am    Post subject: Reply with quote

Why are you helping him? he should learn by himself, he can't just copy paste codes forever and he can't even fix simple errors.
Back to top
View user's profile Send private message
spectrum
Expert Cheater
Reputation: 0

Joined: 27 Mar 2007
Posts: 143

PostPosted: Sun Apr 13, 2008 11:49 am    Post subject: Reply with quote

ok, sorry symbol i didn't look very well into the code, i corrected it, but now really it says getchar is undeclared, that i need to use it first...
_________________
C++ {||||||||||}
ASM {||||||||||}
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Apr 13, 2008 1:29 pm    Post subject: Reply with quote

getchar is a part of stdio if I remember right.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Apr 13, 2008 3:43 pm    Post subject: Reply with quote

_gettchar is its unicode equivilent. Located in tchar.h
_________________
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Sun Apr 13, 2008 4:59 pm    Post subject: Reply with quote

Can't you use the fstream library to write to notepad, that is much easier. Now someone is going to tell me that it is a waste of resources...
_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Apr 13, 2008 6:07 pm    Post subject: Reply with quote

HornyAZNBoy wrote:
Can't you use the fstream library to write to notepad, that is much easier. Now someone is going to tell me that it is a waste of resources...


Maybe. Idk. I'm not that knowledgeable in FI/FO. You can right a notepad file(txt) with FI/FO. But I'm not sure if you could actually write to notepad itself. SendInput seems right.

@spectrum

Just go to http://www.msdn.com/ and search for your api there. It gives you a list of different explanations in full detail about the parameters and what they're spozed to do in the API as well as what the API does.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Apr 14, 2008 8:47 am    Post subject: Reply with quote

lurc wrote:
_gettchar is its unicode equivilent. Located in tchar.h


gettchar is nothing more then a macro which calls getchar, which is located in stdio.h

Fixed code that works fine.
(Updated the strcpy call to use the secure version and fixed the warnings that are given while compiling @ Lv4)

Code:
#include <windows.h>
#include <stdio.h>
#include <tchar.h>

HWND hNotepad;
HWND hNoteEdit;
TCHAR tszString[260];

int main( int argc, TCHAR *argv[] )
{
   UNREFERENCED_PARAMETER( argc );
   UNREFERENCED_PARAMETER( argv );

    hNotepad = FindWindow( _T("Notepad"), NULL );
    if ( !hNotepad ) return 0; // Coudnt find Notepad.
    hNoteEdit = FindWindowEx( hNotepad, NULL, _T("EDIT"), NULL );
    if ( !hNoteEdit ) return 0; // Coudnt find Notepad edit control.
   
    _tcscpy_s( tszString, _ARRAYSIZE(tszString), _T("Print This") );
    for ( int i = 0; i <= (int)_tcslen(tszString); i++ )
        PostMessage( hNoteEdit, WM_CHAR, tszString[i], 0 );

    _gettchar();
    return 0;
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Apr 14, 2008 10:39 am    Post subject: Reply with quote

You don't really need to know Windows APIs to make programs w/ C++. If you're using Visual C++, I believe there are pre-built classes that use APIs in the MFC libraries.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Apr 15, 2008 3:45 am    Post subject: Reply with quote

rapion124 wrote:
You don't really need to know Windows APIs to make programs w/ C++. If you're using Visual C++, I believe there are pre-built classes that use APIs in the MFC libraries.


Well you certainly can't use an API without understanding it. (Yes, you can guess and get lucky, but you will have no skill with it.)

Windows programming almost always involves some API. (Don't say some small all like x = 1 + 1; doesn't use API, cause thats not the point of my post.)

And avoid MFC at all costs if you don't know it already. It's not much of a gain to anything with programming.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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