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 


Linking Hotkey to button in a ce trainer (need help)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 3:40 pm    Post subject: Linking Hotkey to button in a ce trainer (need help) Reply with quote

Hello! Im currently trying to create some simple buttons that is linked with hotkeys (Since it would be easier using buttons instead of 20+ hotkeys)

But i need some help linking Buttons with the hotkeys.

For an example: Press CEBUTTON1 = LCtrl + F1 hotkeys used?

I tried
Code:
function CEButton1Click(sender)
createHotkey(CEButton1Click, VK_LCONTROL,VK_F1)
end

But i guess im missing something since it does not work?
I just need it to be simple and im kinda new to using lua.

Any help/advice is apprechiated
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 3:57 pm    Post subject: Reply with quote

I have absolutely no idea what you're trying to do here. What do you mean by buttons "linked with hotkeys"? Do you mean you want to trigger multiple buttons with one hotkey? Are you trying to make a button assign a hotkey to another button?
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:05 pm    Post subject: Reply with quote

ParkourPenguin wrote:
I have absolutely no idea what you're trying to do here. What do you mean by buttons "linked with hotkeys"? Do you mean you want to trigger multiple buttons with one hotkey? Are you trying to make a button assign a hotkey to another button?


I want to be able to click a button instead of pressing leftshift + F1 for an example.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 4:09 pm    Post subject: Reply with quote

Whatever function that is assigned to the OnClick event of the button will be called to run when you click on said button. For example:
Code:
form1 = createForm()
btn1 = createButton(form1)
btn1.Caption = "Click Me"
btn1.OnClick = function(sender) print("Button Clicked") end

Using the form designer, click on the button, go to the "Events" tab in the object inspector, and assign something to the OnClick event.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:26 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Whatever function that is assigned to the OnClick event of the button will be called to run when you click on said button. For example:
Code:
form1 = createForm()
btn1 = createButton(form1)
btn1.Caption = "Click Me"
btn1.OnClick = function(sender) print("Button Clicked") end

Using the form designer, click on the button, go to the "Events" tab in the object inspector, and assign something to the OnClick event.


This is assigned to onclick
Code:
function CEButton1Click(sender)
createHotkey(CEButton1Click, VK_LCONTROL,VK_F1)
end


Pls bare with me ^^
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 4:28 pm    Post subject: Reply with quote

Yes. And that code does nothing (pretty much).

What do you want the button to do?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:33 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Yes. And that code does nothing (pretty much).

What do you want the button to do?


oh :c

I will try to explain it as good as i can.

I created a trainer for a game. I got alot of coordinates (xyz) for teleportation. But i thought it would be easier to use the trainer if there were buttons instead of pressing the actual hotkeys shift + F1, shift + F2 and so on.

So i thought that if id press the button it would simulate the pressing of the hotkeys (in this case shift + F1).

Alternative i would want the buttons to set values (xzy) to the needed value. But i thought it would be easier to simulate key presses when you press an button Razz

Hope you can understand what im trying to do
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 4:38 pm    Post subject: Reply with quote

The createHotkey function creates a hotkey; it doesn't activate one.

It would be more direct to just do whatever the hotkey does, but you can call the hotkey to run if you want to. Was the hotkey created in Lua, or was it assigned to a memory record? If it was assigned to a memory record, does it activate a script or are there multiple hotkeys that operate on different addresses at once?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:42 pm    Post subject: Reply with quote

ParkourPenguin wrote:
The createHotkey function creates a hotkey; it doesn't activate one.

It would be more direct to just do whatever the hotkey does, but you can call the hotkey to run if you want to. Was the hotkey created in Lua, or was it assigned to a memory record? If it was assigned to a memory record, does it activate a script or are there multiple hotkeys that operate on different addresses at once?


The hotkeys are bound from the adress list like this:

x pointer: Shitf + F1 - Setvalue = 100
z pointer: Shift + F1 - Setvalue = -4000
y pointer: Shift + F1 - Setvalue = -40

So same hotkeys is bound to three different pointers.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 4:45 pm    Post subject: Reply with quote

In that case, it's better to write to those addresses directly.
Code:
function CEButton1Click(sender)
  writeInteger(0x0412A020, 100)
  writeInteger(0x0412A024, -4000)
  writeInteger(0x0412A028, -40)
end

Use writeFloat or writeDouble if it's a different data type.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:48 pm    Post subject: Reply with quote

ParkourPenguin wrote:
In that case, it's better to write to those addresses directly.
Code:
function CEButton1Click(sender)
  writeInteger(0x0412A020, 100)
  writeInteger(0x0412A024, -4000)
  writeInteger(0x0412A028, -40)
end

Use writeFloat or writeDouble if it's a different data type.


Okay, writeInteger(Pointer, Value)

How do i write the pointer correctly instead of an adress? :p
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 4:51 pm    Post subject: Reply with quote

If the base address is game.exe+ABCD1234 and the offsets are 1DF, 24, and C:
Code:
writeInteger("[[[game.exe+ABCD1234]+1DF]+24]+C", 100)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 4:55 pm    Post subject: Reply with quote

ParkourPenguin wrote:
If the base address is game.exe+ABCD1234 and the offsets are 1DF, 24, and C:
Code:
writeInteger("[[[game.exe+ABCD1234]+1DF]+24]+C", 100)


So like this?

Code:
writeInteger("[[[game.exe+1EF20008]+308]+c]+18]+658]+38", 40)


Last edited by lothe23 on Sat May 28, 2016 5:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4293

PostPosted: Sat May 28, 2016 5:00 pm    Post subject: Reply with quote

You should edit your post and change that exe name to something else. http://forum.cheatengine.org/faq.php#0

The square brackets should be balanced: for each opening square bracket, there should be an ending square bracket.
Code:
writeInteger("[[[[[game.exe+1EF20008]+308]+c]+18]+658]+38", 40)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
lothe23
Advanced Cheater
Reputation: 0

Joined: 28 May 2016
Posts: 51

PostPosted: Sat May 28, 2016 5:09 pm    Post subject: Reply with quote

ParkourPenguin wrote:
You should edit your post and change that exe name to something else.

The square brackets should be balanced: for each opening square bracket, there should be an ending square bracket.
Code:
writeInteger("[[[[[game.exe+1EF20008]+308]+c]+18]+658]+38", 40)


Okay so it should look like this?

Code:
function CEButton1Click(sender)
writeInteger("[[[[[game.exe+0084E4BC]+308]+c]+18]+658]+38", -157.1600037)
writeInteger("[[[[[game.exe+0084E4BC]+2e8]+0]+24]+690]+24", 81.05522919)
writeInteger("[[[[[game.exe+0084E4BC]+7c]+2ac]+150]+51c]+24", -8921.415039)
end


and when i check the pointer it looks like this in the bottom: "game.exe"+0084E4BC -> 1EF20008

what of that am i supposed to use?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 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