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 


I'm damn new to C++
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Tue Oct 09, 2007 2:06 pm    Post subject: Reply with quote

read this, he had the same problem as you.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 8:16 am    Post subject: Reply with quote

Okay, so ty at all@@!!

but what is wrong with this:?
Code:
#include <windows.h>
#include <iostream.h>
#include <string.h>

#define WA_PLAY  0x9C6D
#define WA_STOP  0x9C6F

int main ()

{
   char frag[8];

HWND hWindow = FindWindow(NULL, "Winamp 5.35");
cout<<"Enter something: ";
cin.getline(frag, 8);

if (frag="play")
{
SendMessage(hWindow, WM_COMMAND, WA_PLAY, NULL);
}
if (frag="stop")
{
SendMessage(hWindow, WM_COMMAND, WA_STOP, NULL);
}
}
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: Wed Oct 10, 2007 9:43 am    Post subject: Reply with quote

Use the class of Winamp when using FindWindow. It has not changed, ever.

Code:
HWND WinampWindow = FindWindow("Winamp v1.x", NULL);


Using the window name wont work because Winamp puts the song name into the window title while it plays.
Back to top
View user's profile Send private message Visit poster's website
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 9:49 am    Post subject: Reply with quote

Wiccaan wrote:
Use the class of Winamp when using FindWindow. It has not changed, ever.

Code:
HWND WinampWindow = FindWindow("Winamp v1.x", NULL);


Using the window name wont work because Winamp puts the song name into the window title while it plays.


yea. But this wasnt my problem, try to compile the code I've posted ^^. It says an error. But I dont understand it.
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: Wed Oct 10, 2007 10:33 am    Post subject: Reply with quote

Code:
#include <windows.h>
#include <iostream>
using namespace std;

#define WA_PLAY  0x9C6D
#define WA_STOP  0x9C6F

int main ()
{
   char szInput[8];
   HWND hWindow = FindWindow(L"Winamp v1.x", NULL);

   cout << "Enter something: ";
   cin.getline(szInput, sizeof(szInput));

   if ( stricmp(szInput, "play") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_PLAY, NULL);
   }
   if ( stricmp(szInput, "stop") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_STOP, NULL);
   }
}
Back to top
View user's profile Send private message Visit poster's website
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Wed Oct 10, 2007 10:34 am    Post subject: Reply with quote

What's the error message?

Your main function states to return an int, but nothing is returned.
You used the assignment operator "=" to compare instead of using the comparison operator "==".
You compared char arrays with an operator instead of a function such as strcmp.

_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
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: Wed Oct 10, 2007 10:36 am    Post subject: Reply with quote

DeltaFlyer wrote:
What's the error message?

Your main function states to return an int, but nothing is returned.
You used the assignment operator "=" to compare instead of using the comparison operator "==".
You compared char arrays with an operator instead of a function such as strcmp.


The main error was due to his includes.

#include <iostream.h> does not work in VS2005, instead, just need #include <iostream>

Next, as you pointed out, the comparing operators were incorrect as they were attempting to set the value.
Back to top
View user's profile Send private message Visit poster's website
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Wed Oct 10, 2007 10:44 am    Post subject: Reply with quote

Ah, didn't read the whole thread.
_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 11:46 am    Post subject: Reply with quote

Wiccaan wrote:
Code:
#include <windows.h>
#include <iostream>
using namespace std;

#define WA_PLAY  0x9C6D
#define WA_STOP  0x9C6F

int main ()
{
   char szInput[8];
   HWND hWindow = FindWindow(L"Winamp v1.x", NULL);

   cout << "Enter something: ";
   cin.getline(szInput, sizeof(szInput));

   if ( stricmp(szInput, "play") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_PLAY, NULL);
   }
   if ( stricmp(szInput, "stop") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_STOP, NULL);
   }
}


But this isn't working for me too.
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: Wed Oct 10, 2007 12:06 pm    Post subject: Reply with quote

What compiler are you using? (I wrote and tested that using VS2005, works fine.)
Back to top
View user's profile Send private message Visit poster's website
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 12:41 pm    Post subject: Reply with quote

Wiccaan wrote:
What compiler are you using? (I wrote and tested that using VS2005, works fine.)


Visual C++ 6.0
ummm
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: Wed Oct 10, 2007 12:44 pm    Post subject: Reply with quote

rEakW0n wrote:
Wiccaan wrote:
What compiler are you using? (I wrote and tested that using VS2005, works fine.)


Visual C++ 6.0
ummm


That would be why Mad some changes since the two. Give me a little bit, busy working, and I will rewrite it for 6.

Whoops, >.> my fault on that one for the compile issues as well. Forgot the return, as for your other issues. VC6 compiles in Multibyte by default so remove the L infront of the the class name.

Code:
#include <windows.h>
#include <iostream>
using namespace std;

#define WA_PLAY  0x9C6D
#define WA_STOP  0x9C6F

int main ()
{
   char szInput[8];
   HWND hWindow = FindWindow("Winamp v1.x", NULL);

   cout << "Enter something: ";
   cin.getline(szInput, sizeof(szInput));

   if ( stricmp(szInput, "play") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_PLAY, NULL);
   }
   if ( stricmp(szInput, "stop") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_STOP, NULL);
   }
   return 0;
}


That should do it. Smile
Back to top
View user's profile Send private message Visit poster's website
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 2:05 pm    Post subject: Reply with quote

THX VERY MUCH!
This is working Smile

How can I get back on the beginning, after I entered play that it shows again "Enter Something" ?

btw, Should I use VS2005 ?
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: Wed Oct 10, 2007 3:07 pm    Post subject: Reply with quote

rEakW0n wrote:
THX VERY MUCH!
This is working Smile

How can I get back on the beginning, after I entered play that it shows again "Enter Something" ?

btw, Should I use VS2005 ?


I suggest that you update to VS2005 as VS6 is a bit outdated and such.

As for going back to the top, I never did much with console apps, but goto's should work fine.

Code:
#include <windows.h>
#include <iostream>
using namespace std;

#define WA_PLAY  0x9C6D
#define WA_STOP  0x9C6F

int main ()
{
   char szInput[8];
   HWND hWindow = FindWindow("Winamp v1.x", NULL);

start:
   cout << "Enter something: ";
   cin.getline(szInput, sizeof(szInput));

   if ( stricmp(szInput, "play") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_PLAY, NULL);
   }
   if ( stricmp(szInput, "stop") == 0 )
   {
      SendMessage(hWindow, WM_COMMAND, WA_STOP, NULL);
   }
   if( stricmp(szInput, "exit") == 0 )
   {
      goto exit;
   }
   goto start;

exit:
   return 0;
}
Back to top
View user's profile Send private message Visit poster's website
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Oct 10, 2007 3:21 pm    Post subject: Reply with quote

wohooo, thx!! You're so nice.

I start loving C++. I already looked up for some c/c++ books to lend them from the school-library, but they only got delphi and VB books Sad.

I guess I'll buy one soon.

[[CHECK THE ATTACHMENT, LOL]]



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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