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 


Cheat Engine Forum Index
PostGo back to topic
atom0s
Moderator
Reputation: 199
Joined: 25 Jan 2006
Posts: 8519
Location: 127.0.0.1

PostPosted: Fri Jan 21, 2022 3:21 am    Post subject:

Code:

[ENABLE]
{$lua}
_G._hotkeyTimer = createTimer();
_G._hotkeyTimer.Interval = 10;
_G._hotkeyTimer.OnTimer = function (t)
    if (isKeyPressed(22535)) then
        writeBytes('cheatengine-i386.exe', 1);
    else
        writeBytes('cheatengine-i386.exe', 0);
    end
end

{$asm}

[DISABLE]
{$lua}
if (_G._hotkeyTimer ~= nil) then
    _G._hotkeyTimer.destroy();
    _G._hotkeyTimer = nil;
end

{$asm}


Uses the right trigger button of an XInput gamepad to work.

If you only want to write the 0 when released once but still monitor, then you can add a previous state check like this:

Code:

[ENABLE]
{$lua}
_G._hotkeyTimer_PreviousState = false;
_G._hotkeyTimer = createTimer();
_G._hotkeyTimer.Interval = 10;
_G._hotkeyTimer.OnTimer = function (t)
    if (isKeyPressed(22535)) then
        writeBytes('cheatengine-i386.exe', 1);
        _G._hotkeyTimer_PreviousState = true;
    else
        if (_G._hotkeyTimer_PreviousState == true) then
            writeBytes('cheatengine-i386.exe', 0);
            _G._hotkeyTimer_PreviousState = false;
        end
    end
end

{$asm}

[DISABLE]
{$lua}
if (_G._hotkeyTimer ~= nil) then
    _G._hotkeyTimer.destroy();
    _G._hotkeyTimer = nil;
end

{$asm}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Post reviews:   Approve 1
Author Review
++METHOS
Review: Approve
Post reference:
ReviewPosted: Fri Jan 21, 2022 2:08 pm


Back to top
View user's profile Send private message
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites