| View previous topic :: View next topic |
| Author |
Message |
Negima I post too much
Reputation: 5
Joined: 22 May 2007 Posts: 2222
|
Posted: Thu Aug 14, 2008 8:02 pm Post subject: Post Message not working |
|
|
| Code: | #include <iostream>
#include <windows.h>
int main()
{
Sleep(5000);
PostMessage(NULL, WM_KEYUP, 0, 0);
return 0;
} |
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 14, 2008 8:35 pm Post subject: |
|
|
lol why is the first one NULL that should to be handle for whatever you want to send PostMessage too.. like a game or something.. it doesnt just work in air.
Also WM_KEYUP should have which key you want to press up as well you can't just do it with a invisible key!
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Thu Aug 14, 2008 8:42 pm Post subject: |
|
|
Can hWnd be NULL?
and since you're exiting right after the PostMessage you won't be able to see the results.
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Aug 14, 2008 8:49 pm Post subject: |
|
|
You obviously know nothing about messages.
That is why, it won't work.
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Aug 14, 2008 8:52 pm Post subject: Re: Post Message not working |
|
|
| Negima wrote: | | Code: | #include <iostream>
#include <windows.h>
int main()
{
Sleep(5000);
PostMessage(NULL, WM_KEYUP, 0, 0);
return 0;
} |
|
Wow 2K posts and dont know how pma works??? lol
anyways you need to have a valid handle. Returned from FindWindowA
And use VK_Whateverurkey is, and the past parm u leave 0.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Aug 14, 2008 10:02 pm Post subject: |
|
|
1. Why are you pointlessly sleeping?
2. NULL would work as far as I know, you would send a message to yourself.
but even so, you're not sending anything meaningful.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Aug 14, 2008 10:02 pm Post subject: Re: Post Message not working |
|
|
| dnsi0 wrote: | | Negima wrote: | | Code: | #include <iostream>
#include <windows.h>
int main()
{
Sleep(5000);
PostMessage(NULL, WM_KEYUP, 0, 0);
return 0;
} |
|
Wow 2K posts and dont know how pma works??? lol
anyways you need to have a valid handle. Returned from FindWindowA
And use VK_Whateverurkey is, and the past parm u leave 0. |
Post count has nothing to do with a persons knowledge.
@Negima:
http://msdn.microsoft.com/en-us/library/ms644944%28VS.85%29.aspx
Read up on how to use the API. Next time, do not just post code and say "doesnt work" as the topic name. Instead, give us some info on what doesn't work, what you are trying to accomplish, etc.
_________________
- Retired. |
|
| Back to top |
|
 |
Negima I post too much
Reputation: 5
Joined: 22 May 2007 Posts: 2222
|
Posted: Thu Aug 14, 2008 10:59 pm Post subject: |
|
|
I apologize Wiccan, what I meant to say was its not even compiling.
updated version
| Code: | #include <iostream>
#include <windows.h>
int main()
{
PostMessage( Notepad, WM_KEYUP, 0, 0 );
system("pause"); //dont flame plz
return 0;
} |
I get this error
| Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(6) : error C2065: 'Notepad' : undeclared identifier
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
}
|
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Aug 14, 2008 11:04 pm Post subject: |
|
|
HWND != text string. You need to FindWindow+FindWindowEx. Notepad Window -> Edit Control.
_________________
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 14, 2008 11:06 pm Post subject: |
|
|
c++ doesn't know what the word Notepad means..
C++ works of numbers not letters you gotta do something like
HWND hNotepad = FindWindow(NULL, "my window title");
PostMessage( hNotepad , WM_KEYUP, 0, 0 );
something like that or use FindWindowEx to go deeper
|
|
| Back to top |
|
 |
Negima I post too much
Reputation: 5
Joined: 22 May 2007 Posts: 2222
|
Posted: Thu Aug 14, 2008 11:35 pm Post subject: |
|
|
I fixed my old error but now I get a new error
| Code: | #include <iostream>
#include <windows.h>
int main()
{
HWND hNotepad=FindWindow(NULL, "Notepad");
BOOL PostMessage( hNotepad, WM_KEYUP, 0, 0 );
system("pause"); //dont flame plz
return 0;
} |
| Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(6) : error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\NegiBot.cpp(7) : error C2078: too many initializers
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Aug 14, 2008 11:38 pm Post subject: |
|
|
or just change your settings to use ANSI. Also this won't work on notepad. Once you findwindow you ahve to findwindowex for the EDIT control.
_________________
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Thu Aug 14, 2008 11:57 pm Post subject: |
|
|
| Negima wrote: | I fixed my old error but now I get a new error
| Code: | #include <iostream>
#include <windows.h>
int main()
{
HWND hNotepad=FindWindow(NULL, "Notepad");
BOOL PostMessage( hNotepad, WM_KEYUP, 0, 0 );
system("pause"); //dont flame plz
return 0;
} |
| Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(6) : error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\NegiBot.cpp(7) : error C2078: too many initializers
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
What's the point of WM_KEYUP if theres no key specified and no WM_KEYDOWN before it...
|
|
| Back to top |
|
 |
Negima I post too much
Reputation: 5
Joined: 22 May 2007 Posts: 2222
|
Posted: Thu Aug 14, 2008 11:58 pm Post subject: |
|
|
| sponge wrote: |
or just change your settings to use ANSI. Also this won't work on notepad. Once you findwindow you ahve to findwindowex for the EDIT control. | if I put the L infront of notepad it gives me this | Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(7) : error C2078: too many initializers
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
How do I change to ansi?
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Fri Aug 15, 2008 12:03 am Post subject: |
|
|
| Negima wrote: | | sponge wrote: |
or just change your settings to use ANSI. Also this won't work on notepad. Once you findwindow you ahve to findwindowex for the EDIT control. | if I put the L infront of notepad it gives me this | Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(7) : error C2078: too many initializers
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
How do I change to ansi? |
Put L in front. Take out BOOL in front of PostMessage.
|
|
| Back to top |
|
 |
|