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 


Post Message not working
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Negima
I post too much
Reputation: 5

Joined: 22 May 2007
Posts: 2222

PostPosted: Thu Aug 14, 2008 8:02 pm    Post subject: Post Message not working Reply with quote

Code:
#include <iostream>
#include <windows.h>

int main()
{
   Sleep(5000);
    PostMessage(NULL, WM_KEYUP, 0, 0);
   return 0;
}
Back to top
View user's profile Send private message Visit poster's website
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Thu Aug 14, 2008 8:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Aug 14, 2008 8:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Aug 14, 2008 8:49 pm    Post subject: Reply with quote

You obviously know nothing about messages. Rolling Eyes
That is why, it won't work.

_________________
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Aug 14, 2008 8:52 pm    Post subject: Re: Post Message not working Reply with quote

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Aug 14, 2008 10:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Aug 14, 2008 10:02 pm    Post subject: Re: Post Message not working Reply with quote

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
View user's profile Send private message Visit poster's website
Negima
I post too much
Reputation: 5

Joined: 22 May 2007
Posts: 2222

PostPosted: Thu Aug 14, 2008 10:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Thu Aug 14, 2008 11:04 pm    Post subject: Reply with quote

HWND != text string. You need to FindWindow+FindWindowEx. Notepad Window -> Edit Control.
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Thu Aug 14, 2008 11:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Negima
I post too much
Reputation: 5

Joined: 22 May 2007
Posts: 2222

PostPosted: Thu Aug 14, 2008 11:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Thu Aug 14, 2008 11:38 pm    Post subject: Reply with quote

Code:
L"Notepad"


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
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Aug 14, 2008 11:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Negima
I post too much
Reputation: 5

Joined: 22 May 2007
Posts: 2222

PostPosted: Thu Aug 14, 2008 11:58 pm    Post subject: Reply with quote

sponge wrote:
Code:
L"Notepad"


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
View user's profile Send private message Visit poster's website
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Fri Aug 15, 2008 12:03 am    Post subject: Reply with quote

Negima wrote:
sponge wrote:
Code:
L"Notepad"


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
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 1, 2, 3  Next
Page 1 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