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 


[RLS / HelpMe] KeepCapsLockOn Prank.
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Apr 20, 2008 4:15 am    Post subject: Reply with quote

lurc wrote:
int SomethingElse = 1;
#define SOMETHING SomethingElse

I tried it earlier. Now I realise that it does work, and that was not where my program was going wrong. Thanks for the help!
HalfPrime wrote:
Is it even possible to change the value of a #define? And, I don't think you can call functions before main?

No, it's not. Which is why you have to declare the #define, as the value of a variable.
No you can't, I don't think, why is that relevant? Razz

Wiccaan, that's the wrong way again though. But it doesn't matter now, as I worked out my problem! Smile

HalfPrime wrote:
Why's it have to be a #define, anyways?

Because I am using the user input as part of a function. (keybd_event) Wink
If their is another way to do this, please say. =)

Does keybd_event work anyway, because in other programs, it doesn't seem to be actually sending a key or clicking? Btw, I know it's outdated, but sendinput refuses to work for me, saying, input has not been declared!

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
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: Sun Apr 20, 2008 9:12 am    Post subject: Reply with quote

Use PostMessage for anything that involves input. It will in almost all cases work where as others can be blocked, patched, or not handled.

wrote:
Wiccaan, that's the wrong way again though. But it doesn't matter now, as I worked out my problem! Smile


I wasn't posting code in relation to a question, someone mentioned defines and I gave an example.

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

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Apr 20, 2008 9:41 am    Post subject: Reply with quote

Wiccaan wrote:
Use PostMessage for anything that involves input. It will in almost all cases work where as others can be blocked, patched, or not handled.

However, with post message, do you have to send the keystrokes to a specific window? I guess I could edit it to do that, but I would prefer it to send it to the active/focused window automatically. Then again, I could program that in myself.
Wiccaan wrote:
I wasn't posting code in relation to a question, someone mentioned defines and I gave an example.

Ah ok, sowwy. Very Happy

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
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 20, 2008 9:49 am    Post subject: Reply with quote

For the hWnd Parameter of PostMessage use GetForegroundWindow() or GetActiveWindow() if you want it to use the Focused/Active window.
_________________
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Apr 20, 2008 10:06 am    Post subject: Reply with quote

Thanks Lurc. So something like this?
Code:
#include <windows.h>;
...
PostMessage(GetActiveWindow(), WM_DESTROY, 0, 0);

Or would you have to:
Code:
HWND active = GetActiveWindow();
...
PostMessage(active, WM_DESTROY, 0, 0);

Or even:
Code:
int active = GetActiveWindow();
#define ACTIVE active
PostMessage(ACTIVE, WM_DESTROY, 0, 0);

Confused

Also, to use registerhotkey(), would you need to use something like this?
Code:
RegisterHotKey(hWndA, 150, MOD_CONTROL, VK_RETURN);
UnregisterHotKey(hWndMain,150);

http://69.10.233.10/KB/system/nishhotkeys01.aspx

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
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 20, 2008 3:20 pm    Post subject: Reply with quote

It doesnt really matter where you put it, all but the last of those are valid.

you wont be able to compile if u use the int active = GetActiveWindow because GetActiveWindow returns an HWND Handle.

for RegisterHotKey

make an ATOM and then assign it using GlobalAddAtom (this will be the second parameter in RegisterHotKey)

then register the hotkey to the main form.

then filter through using WM_HOTKEY in your windows procedure, you can either filter it furthor using HIWORD(lParam) to get the Virtual key being pressed or LOWORD(wParam) to get the ATOM being used.

_________________
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Mon Apr 21, 2008 11:05 am    Post subject: Reply with quote

lurc wrote:
It doesnt really matter where you put it, all but the last of those are valid.
Ok, thanks. I'll put that in, in place of the other method now!

lurc wrote:
make an ATOM and then assign it using GlobalAddAtom (this will be the second parameter in RegisterHotKey)
then register the hotkey to the main form.
then filter through using WM_HOTKEY in your windows procedure, you can either filter it furthor using HIWORD(lParam) to get the Virtual key being pressed or LOWORD(wParam) to get the ATOM being used.

That completely baffled me, but give me a while to process it, and then I'll reply properly.

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Apr 21, 2008 1:47 pm    Post subject: Reply with quote

BOOL RegisterHotKey(
HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);

RegisterHotkey(hwnd, 1, NULL, VK_F12);
UnregisterHotkey(hwnd, 1);

Respond to WM_HOTKEY

Quote:
wParam
Specifies the identifier of the hot key that generated the message. If the message was generated by a system-defined hot key, this parameter will be one of the following values.
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Mon Apr 21, 2008 1:57 pm    Post subject: Reply with quote

slovach wrote:
Respond to WM_HOTKEY
Quote:
wParam
Specifies the identifier of the hot key that generated the message. If the message was generated by a system-defined hot key, this parameter will be one of the following values.

Slovach, thanks, now I get the registerhotkey part, but how do you specifiy what to do when it is pressed. I assume this is what WM_HOTKEY is for, but did not understand how to use it. Very Happy Embarassed

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Apr 21, 2008 2:09 pm    Post subject: Reply with quote

A console window doesn't handle windows messages like WM_HOTKEY.

Just use GetAsyncKeyState instead then, or create an actual window.
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Mon Apr 21, 2008 2:13 pm    Post subject: Reply with quote

Thanks, that was the most helpful post of this ... well ... erm ... it was very helpful anyway! Wink Thanks.
_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
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
Page 2 of 2

 
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