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 


Hotkey and DLL inject problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Sat Jun 18, 2011 7:57 am    Post subject: Hotkey and DLL inject problem Reply with quote

Hey, i have 2 problems with CE

First, in LUA script code i have function, for example

function setSpeed2(bla)
speedhack_setSpeed(2.00)
timer_setEnabled(t,false)
end

and

function setSpeed5(bla)
speedhack_setSpeed(5.00)
timer_setEnabled(t,false)
end

Im making standalone EXE trainer and i dont know how i can add hotkey to this functions, whats the right command for LUA code ?

Adding Hotkeys in generator dont works because its not Table Address

And second, is there a way to make dll injection for already specified EXE,and build this dll into final EXE by Add File in generator ?

Thx
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat Jun 18, 2011 8:41 am    Post subject: Reply with quote

first off, remove the timer_setEnabled lines, that is only needed if you run it from a timer (and that is only needed if you start using the onOpenProcess method, or if you want to use a timer to gradually adjust speed)

then to add a hotkey for that function specifically just use createHotkey

example a ctrl+f1 and ctrl+f2 hotkey would be:

Code:

createHotkey(setSpeed2, VK_CONTROL, VK_F1)
createHotkey(setSpeed5, VK_CONTROL, VK_F2)


check defines.lua in the ce folder for more VK_ codes

as for dll injection:
Yes, if you use add file in the exe generator part that file will be placed in the base Cheat Engine folder (or a specified subfolder if you choose to)

just basic injectDll(filename) in auto assembler and/or lua script will work, but if you want to be sure, you can make use of "getCheatEngineDir" to get the full path to the folder the trainer is running in

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Sat Jun 18, 2011 8:51 am    Post subject: Reply with quote

Thanks you so much, i didn't know there is sth like defines file with commands,will check it Very Happy
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat Jun 18, 2011 9:10 am    Post subject: Reply with quote

I also recommend checking main.lua for other command (or the scripting section in the helpfile)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Sat Jun 18, 2011 9:12 am    Post subject: Reply with quote

Hey, i have one more fast question, if i want to set a key from numpad for my hotkey, what should write instead of 1,2,3... ?

I mean i dont want to bound default numbers on my keyboard for hotkeys, but that ones on numpad Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat Jun 18, 2011 9:18 am    Post subject: Reply with quote

when numlock is on:
Code:

VK_NUMPAD0 = 96
VK_NUMPAD1 = 97
VK_NUMPAD2 = 98
VK_NUMPAD3 = 99
VK_NUMPAD4 = 100
VK_NUMPAD5 = 101
VK_NUMPAD6 = 102
VK_NUMPAD7 = 103
VK_NUMPAD8 = 104
VK_NUMPAD9 = 105
VK_MULTIPLY = 106
VK_ADD = 107
VK_SEPARATOR = 108
VK_SUBTRACT = 109
VK_DECIMAL = 110
VK_DIVIDE = 111


when numlock is off it's
VK_UP, VK_DOWN, VK_NEXT, etc... (numpads can be tricky)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Sat Jun 18, 2011 1:48 pm    Post subject: This post has 1 review(s) Reply with quote

Keep in mind that if you are going to define a function like this:
Code:
function setSpeed2(bla)
speedhack_setSpeed(2.00)
timer_setEnabled(t,false)
end


Then you should be using the param you are expecting. If you don't need the param at all, don't define one then. Like this:

Code:
function setSpeed2()
    speedhack_setSpeed( 2.00 );
    timer_setEnabled( t, false );
end

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Sun Jun 19, 2011 11:11 am    Post subject: Reply with quote

I still doing something wrong. The most important part of my code is

Code:
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed2(bla)
  speedhack_setSpeed(2.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed5(bla)
  speedhack_setSpeed(5.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed10(bla)
  speedhack_setSpeed(10.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed20(bla)
  speedhack_setSpeed(20.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed50(bla)
  speedhack_setSpeed(50.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed100(bla)
  speedhack_setSpeed(100.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed200(bla)
  speedhack_setSpeed(200.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed500(bla)
  speedhack_setSpeed(500.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)

end

strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed1(bla)
  speedhack_setSpeed(1.00)
  timer_setEnabled(t,false)
end

function onOpenProcess(pid)
  t=createTimer(nil)
  timer_onTimer(t, setSpeed)
  timer_setInterval(t,1)
  timer_setEnabled(t, true)


I know there shouldnt be so many strings add and timers, but it all have worked when i assined those functions to each buttons in Generator and if i run it in game with Alt tab to generated trainer and choose one of those speeds ( cllicking on button), it works in game

But i still cant bind hotkeys to them

i add that code at the end of script :
Code:
 createHotkey(setSpeed2, VK_CONTROL, VK_F1)


But it dont work in game

Later i deleted timer code, it doesnt work too, then i changed (bla) from setSpeed2(bla) to (), and it doesnt work anyway.

I tried also
Code:
CreateHotkey(setSpeed2, 97)
to bind Speed2 to 1 on my numpad but it also failed,

I really dont know what i am doing wrong Sad
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sun Jun 19, 2011 12:11 pm    Post subject: Reply with quote

tip: Do not blindly copy paste scripts without knowing how they work

1: Get rid of all your timer commands as you're not using a timer but hotkeys

2: You have defined 9 onOpenProcess function may only have 1

3: You are adding ut3.exe 9 times to the auto attach list, you only need 1

4: createHotkey, not CreateHotkey

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Sun Jun 19, 2011 12:36 pm    Post subject: Reply with quote

So finnaly looks like
Code:
strings_add(getAutoAttachList(), "UT3.exe")

function setSpeed2(bla)
  speedhack_setSpeed(2.00)
end

function onOpenProcess(pid)


end


function setSpeed5(bla)
  speedhack_setSpeed(5.00)
end





function setSpeed10(bla)
  speedhack_setSpeed(10.00)
end





function setSpeed20(bla)
  speedhack_setSpeed(20.00)
end



function setSpeed50(bla)
  speedhack_setSpeed(50.00)
end




function setSpeed100(bla)
  speedhack_setSpeed(100.00)
end



function setSpeed200(bla)
  speedhack_setSpeed(200.00)

end


function setSpeed500(bla)
  speedhack_setSpeed(500.00)
end




function setSpeed1(bla)
  speedhack_setSpeed(1.00)
end

createHotkey(setSpeed2, VK_CONTROL, VK_F1)


But id dont works, even if i replace last part with
Code:
createHotkey(VK_CONTROL, VK_F2, setSpeed5)
or
Code:
createHotkey(setSpeed10, 116)


Nevermind, it can be trainer without hotkeys at the end Sad
Back to top
View user's profile Send private message
GH*master
Expert Cheater
Reputation: 8

Joined: 10 Jan 2008
Posts: 159

PostPosted: Sun Jun 19, 2011 11:16 pm    Post subject: Reply with quote

Sc00rpY, try this my Lua code:

Code:

speed = 1.0

function IncSpeed(hotkey)
   speed = speed + 1
   speedhack_setSpeed(speed)
end
 
function DecSpeed(hotkey)
   speed = speed - 1
   speedhack_setSpeed(speed) 
end

function ResetSpeed(hotkey)
   speed = 1.0
   speedhack_setSpeed(1.0)
end


function SetHotKey(func, hotkey)
   local objectHotKey =  createHotkey(func, hotkey)
   generichotkey_setKeys(objectHotKey, hotkey)
   generichotkey_onHotkey(objectHotKey, func)
end

 
function onOpenProcess(processid)
   SetHotKey(IncSpeed, VK_F2)
   SetHotKey(DecSpeed, VK_F3)
   SetHotKey(ResetSpeed, VK_F4)
end
 
local aalist = getAutoAttachList()
stringlist_add(aalist, "UT3.exe")
Back to top
View user's profile Send private message
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Mon Jun 20, 2011 9:57 am    Post subject: Reply with quote

Your script worls perfectly, thanks !

Now i can modifty it to my speeds Smile

There is one disadvantage in this code - if you reduce game speed too much, the game will freeze ( speed under 0 )

I think there is no way to block set game speed as 0 ?

THX !
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Jun 20, 2011 10:11 am    Post subject: Reply with quote

Guess there's a problem with createhotkey init I'll look into it for nextversion.

as for the speed 0 thing try this:
Code:

function DecSpeed(hotkey)
   if (speed - 1) > 0 then
     speed = speed - 1
     speedhack_setSpeed(speed)
   end
end

in short: If the new speed is bigger than 0 then decrease the speed, else do nothing

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Sc00rpY
How do I cheat?
Reputation: 0

Joined: 18 Jun 2011
Posts: 6

PostPosted: Mon Jun 20, 2011 11:36 am    Post subject: Reply with quote

Will check if it works, thx !
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Jun 20, 2011 12:40 pm    Post subject: Reply with quote

tip: you can also decrease in steps of 0.5, and 0.1
so if you want to go lower than 1 (slow motion) just decrease with 0.5 for half speed, and 0.1 for 1/10th speed
(0 is obviously freeze, and negative will make the time go backwards, not many games support that though)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
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