| View previous topic :: View next topic |
| Author |
Message |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Tue Oct 09, 2007 2:06 pm Post subject: |
|
|
| read this, he had the same problem as you.
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 8:16 am Post subject: |
|
|
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 9:43 am Post subject: |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 9:49 am Post subject: |
|
|
| 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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 10:33 am Post subject: |
|
|
| 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 |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Wed Oct 10, 2007 10:34 am Post subject: |
|
|
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 10:36 am Post subject: |
|
|
| 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 |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Wed Oct 10, 2007 10:44 am Post subject: |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 11:46 am Post subject: |
|
|
| 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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 12:06 pm Post subject: |
|
|
| What compiler are you using? (I wrote and tested that using VS2005, works fine.)
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 12:41 pm Post subject: |
|
|
| Wiccaan wrote: | | What compiler are you using? (I wrote and tested that using VS2005, works fine.) |
Visual C++ 6.0
ummm
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 12:44 pm Post subject: |
|
|
| 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 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.
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 2:05 pm Post subject: |
|
|
THX VERY MUCH!
This is working
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 10, 2007 3:07 pm Post subject: |
|
|
| rEakW0n wrote: | THX VERY MUCH!
This is working
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Oct 10, 2007 3:21 pm Post subject: |
|
|
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 .
I guess I'll buy one soon.
[[CHECK THE ATTACHMENT, LOL]]
|
|
| Back to top |
|
 |
|