Page 1 of 1

LSS instructions to setup and remove hotkeys

PostPosted: Mon Feb 11, 2008 7:37 pm
by mezzo
I was under the impression that there were LSS instructions to create and remove hotkeys.. but I can't find the syntax in the help file anymore.
Any idea where it went ? (or was I daydreaming?)

PostPosted: Mon Feb 11, 2008 8:11 pm
by L. Spiro
INT RegisterHotkey(
INT iKey,
INT iMod,
INT iFunc,
DWORD dwParms[3],
BOOL bPoll)



Registers a hotkey with the system and returns its ID for use with UnregisterHotkey. The return is -1 on error. iKey is the virtual key code of the key to press (VK_*). iMod is the key modifier, for example the Alt key or Shift (MOD_*). iFunc is the ID of the function to be called when the specified keys are pressed, and dwParms are the parameters to pass to that function. bPoll determines whether the polling method is used or the standard Windows hotkey system is used.
iFunc can be any of the following:
HK_FUNC_NOTHING: No operation.
HK_FUNC_POKE: Writes a value into an address. dwParm[0] specifies the address, dwParm[1] specifies the value, and dwParm[2] speciffies the size (up to 4 bytes).
HK_FUNC_BEEP: Beeps for dwParm[0] milliseconds.
HK_FUNC_PAUSE: Pauses the target process.
HK_FUNC_RESUME: Resumes the target process.
HK_FUNC_SCRIPTFUNCTION: Calls a script function specified by dwParm[0].
HK_FUNC_CURPROCSCRIPTFUNCTION: Calls a script function specific to the current process, specified by dwParm[0].
HK_FUNC_LOADCONVERTER: Loads the Converter. This is not available in trainers.
HK_FUNC_LOADHEXEDITOR: Loads the Hex Editor. This is not available in trainers.
HK_FUNC_LOADDISASSEMBLER: Loads the Disassembler. This is not available in trainers.
HK_FUNC_LOADSCRIPTEDITOR: Loads the Script Editor. This is not available in trainers.
HK_FUNC_SUBSAMEASBEFORE: Performs a Same as Before Sub Search. This is not available in trainers.
HK_FUNC_SUBDIFFROMBEFORE: Performs a Different From Before Sub Search. This is not available in trainers.
HK_FUNC_SUBINCREASED: Performs an Increase Sub Search. This is not available in trainers.
HK_FUNC_SUBDECREASED: Performs a Decreased Sub Search. This is not available in trainers.
HK_FUNC_SUBSAMEASORIGINAL: Performs a Same as Original Sub Search. This is not available in trainers.
HK_FUNC_LOCKSTORED: Locks Stored Values whose Hotkey Key matches dwParm[0]. This is not available in trainers.
HK_FUNC_UNLOCKSTORED: Unlocks Stored Values whose Hotkey Key matches dwParm[0]. This is not available in trainers.



BOOL UnregisterHotkey(
INT iId)



Unregisters the specified hotkey by its ID.


L. Spiro

PostPosted: Tue Feb 12, 2008 4:11 pm
by mezzo
yes, that's the one ! Thanks.

The reason I didn't find it anymore, is because at work I can't download the full .rar archive (archives are blocked by our proxy) and the help file that is a separate download (http://www.memoryhacking.com/MemHack/MHS Help.chm) seems to be an older version that doesn't contain that function yet.

Could you possibly update it, please ?

PostPosted: Tue Feb 12, 2008 5:51 pm
by L. Spiro
It will all be updated in the next release.

Bad news is that I have gotten a few blue screens of death after fixing my anti-anti-cheat.

I am not yet sure what the cause is and I think I want to study it more before releasing. It may still be this week however.


L. Spiro

PostPosted: Tue May 27, 2008 7:44 am
by liqmysaq
how would i write this? if i wanted to register ctrl+z to be the hotkey that would run a script function thats HK_20 would it be like:

INT RegisterHotkey(
INT VK_Z,
INT MOD_CONTROL,
INT HK_FUNC_CURPROCSCRIPTFUNCTION,
DWORD 0x14,0x0,0x0,
BOOL bPoll)

also for the Poll option, do i replace bPoll with FALSE or do i put something like bPoll = FALSE? when i try to compile it gives me an error at the DWORD line no matter how i put it.

PostPosted: Tue May 27, 2008 9:51 am
by L. Spiro
INT iId = RegisterHotkey( VK_Z, MOD_CONTROL, HK_FUNC_CURPROCSCRIPTFUNCTION, 20, FALSE );


L. Spiro

PostPosted: Tue May 27, 2008 10:29 pm
by liqmysaq
ok one more thing plz, i get error Unable to set the initialization data for global "iId". am i supposed to put in a certian place or do i need to type [global] or something like that.

Undeclared identifier (VK_Z).
Call to undefined function or incompatible argument lists (“RegisterHotkey”).
Unable to set the initialization data for global “iId”.

also, if i wanted to put hotkeys to each hack in a trainer would i just put the register hotkey code below one another or do they need to be near the hotkey code?

PostPosted: Wed May 28, 2008 9:37 am
by L. Spiro
Code: Select all
INT g_iId = -1;

// Registers the Hotkey every time a process is opened.
VOID On_OpenProcess() {
    DWORD dwParms[] = { 20, 0, 0 };
    g_iId = RegisterHotkey( 'Z', MOD_CONTROL, HK_FUNC_CURPROCSCRIPTFUNCTION, dwParms, FALSE );
}

// Removes the Hotkey every time the process is closed.
VOID On_CloseProcess() {
    UnregisterHotkey( g_iId );
    g_iId = -1;
}



If you want more hotkeys, call RegisterHotkey() more times.


L. Spiro

PostPosted: Thu May 29, 2008 12:04 am
by liqmysaq
great, thanks alot. :)

how come u changed the HK_# with dwParms and added in the DWORD dwParms[] = { 20, 0, 0 }; ? does this mean if i want a different HK_# i need to type in the DWORD line again and rename dwParms to dwParms1 or something? or will it work if i take out the DWORD line and change dwParms to 20 like u showed in the previous post.

also why do you not need the VK_ now?

PostPosted: Thu May 29, 2008 3:34 am
by mezzo
liqmysaq wrote:how come u changed the HK_# with dwParms and added in the DWORD dwParms[] = { 20, 0, 0 }; ? does this mean if i want a different HK_# i need to type in the DWORD line again and rename dwParms to dwParms1 or something? or will it work if i take out the DWORD line and change dwParms to 20 like u showed in the previous post.


Depends if you want to assign a new hotkey in the same void or not.
The dwParms is declared locally in that void, so either declare a new array with a different name eg

DWORD dwParms1 = ... // one set per hotkey
DWORD dwParms2 = ...

Or simply reuse the array. Just enter new values in the array and use the name again. eg

dwParms[] = { 30, 0, 0 };
// register hotkey 1
dwParms[] = { 50, 0, 0 };
// register hotkey 2

PostPosted: Thu May 29, 2008 10:07 am
by L. Spiro
liqmysaq wrote:how come u changed the HK_# with dwParms

I didn’t. Your Hotkey function is On_HK_20, so you put 20 there.

liqmysaq wrote:and added in the DWORD dwParms[] = { 20, 0, 0 }; ?

Because you need an array of 3 DWORD values.



mezzo wrote:Or simply reuse the array. Just enter new values in the array and use the name again. eg

dwParms[] = { 30, 0, 0 };
// register hotkey 1
dwParms[] = { 50, 0, 0 };
// register hotkey 2

This won’t work in L. Spiro Script; I support aggregations only on declaration.
The best route is to reuse the array you already declared, but do it this way:
Code: Select all
dwParms[0] = 30;

dwParms[1] = 50;



L. Spiro

PostPosted: Thu May 29, 2008 4:31 pm
by mezzo
This won’t work in L. Spiro Script; I support aggregations only on declaration.
The best route is to reuse the array you already declared, but do it this way:

thanks, that's good to know :-)