|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 9:19 am Post subject: After create the hotkey how bound it |
|
|
after i do createHotkey(CECheckbox1(),VK_P,VK_C) how i can make the checkbox with the hotkey boundable ? |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Fri Mar 06, 2020 11:23 am Post subject: |
|
|
Do you mean how to make it do something?
Code: | function toggle_checkbox(cb)
cb.Checked = not cb.Checked
end
createHotkey(toggle_checkbox, key1, key2, key3, ...)
|
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 11:35 am Post subject: |
|
|
i got Error:attempt to call a nil value |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Fri Mar 06, 2020 2:12 pm Post subject: |
|
|
It may bind an object (the checkbox) to a function, to create a new function provided for createHotkey, like this
Code: |
function bind1(fn,o)return function(...) return fn(o,...) end end
function toggle_checkbox(cb, hko)
cb.Checked = not cb.Checked
if hko then -- optional, hko can be omit in function argument list
-- ... do stuff specific for hotkey object if need
end
end
createHotkey(bind1(toggle_checkbox, cb_the_check_box_object ), key1, key2, key3, ...)
|
_________________
- Retarded. |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 2:58 pm Post subject: |
|
|
I am a beginner can you send me an .exe with the code so that I can see more clearly |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Fri Mar 06, 2020 3:03 pm Post subject: |
|
|
This an example on an Edit control.
1. create a Form named UDF1, create 2 Edit named CEEdit1 and CEEdit2
2. Assign both Edit OnChange event function to HexOnChange
3. Add following script
Code: |
function bind1(fn,o)return function(...) return fn(o,...) end end
function HexOnChange(me, hko)
if not tonumber(me.Text,16)then me.Text = '0' end--normalize hex text
-- hko stuff start
local v, hkAction = tonumber(me.Text,16)
if hko==INC1 or hko==RIGHT1 then
v,hkAction = v+1,'INC'
elseif hko==DEC1 or hko==LEFT1 then
v,hkAction = v-1,'DEC'
end
-- update possible change from hko
me.Text = v >= 0 and string.format("%X",v) or string.format("-%X",-v)
-- hko stuff end
-- do response on change --
GetMainForm().Caption = (hkAction or 'normal')..' '..me.Text..' on '..me.Name
end
-- bind UDF1.CEEdit1 to HexOnChange
local bound1 = bind1(HexOnChange, UDF1.CEEdit1)
if INC1 then INC1=nil,INC1.Destroy()end
INC1 = createHotkey(bound1, VK_UP, VK_LSHIFT, VK_LCONTROL)
if DEC1 then DEC1=nil,DEC1.Destroy()end
DEC1 = createHotkey(bound1, VK_DOWN, VK_LSHIFT, VK_LCONTROL)
-- bind UDF1.CEEdit2 to HexOnChange
local bound2 = bind1(HexOnChange, UDF1.CEEdit2)
if RIGHT1 then RIGHT1=nil,RIGHT1.Destroy()end
RIGHT1 = createHotkey(bound2, VK_RIGHT, VK_LSHIFT, VK_LCONTROL)
if LEFT1 then LEFT1=nil,LEFT1.Destroy()end
LEFT1 = createHotkey(bound2, VK_LEFT, VK_LSHIFT, VK_LCONTROL)
UDF1.Show()
|
_________________
- Retarded.
Last edited by panraven on Fri Mar 06, 2020 3:21 pm; edited 1 time in total |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 3:13 pm Post subject: |
|
|
i got this
Error:[string "..."]:5: bad argument #1 to 'tonumber' (string expected, got nil) |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Fri Mar 06, 2020 3:23 pm Post subject: |
|
|
dport80 wrote: | i got this
Error:[string "..."]:5: bad argument #1 to 'tonumber' (string expected, got nil) |
My example use an Edit control, which has .Text property.
CheckBox does not has .Text property.
May paste your script?
Also check the ui/function names match. _________________
- Retarded. |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 4:03 pm Post subject: |
|
|
Code: | function bind1(fn,o)return function(...) return fn(o,...) end end
function CETrainer_CECheckbox1Change(me, hko)
if not tonumber(me.Checked)then me.Checked = true end--normalize hex text
local v, hkAction = tonumber(me.Checked)
if hko==INC1 or hko==RIGHT1 then
v,hkAction = true, 'INC1'
elseif hko==DEC1 or hko==LEFT1 then
v,hkAction = false,'DEC'
end
end
-- new function binding the CEEdit1 to UDF1_CEEdit1Change as hotkey handler
-- define hotkeys
local bound1 = bind1(CECheckbox1Change, CETrainer.CECheckbox1)
if INC1 then INC1=nil,INC1.Destroy()end
INC1 = createHotkey(bound1, VK_UP, VK_LSHIFT, VK_LCONTROL)
if DEC1 then DEC1=nil,DEC1.Destroy()end
DEC1 = createHotkey(bound1, VK_DOWN, VK_LSHIFT, VK_LCONTROL)
local bound2 = bind1(CECheckbox1Change, CETrainer.CECheckbox1)
if RIGHT1 then RIGHT1=nil,RIGHT1.Destroy()end
RIGHT1 = createHotkey(bound2, VK_RIGHT, VK_LSHIFT, VK_LCONTROL)
if LEFT1 then LEFT1=nil,LEFT1.Destroy()end
LEFT1 = createHotkey(bound2, VK_LEFT, VK_LSHIFT, VK_LCONTROL)
CETrainer.Show()
|
When i execute keybind that do that error
`Error:[string "..."]:2: attempt to call a nil value (upvalue 'fn')` |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Fri Mar 06, 2020 4:30 pm Post subject: |
|
|
dport80 wrote: |
--code
...
function CETrainer_CECheckbox1Change(me, hko)
-- tonumber not need for check box
-- if not tonumber(me.Checked)then me.Checked = true end--normalize hex text
local v, hkAction = me.Checked -- remove tonumber
if hko==INC1 or hko==RIGHT1 then
v,hkAction = true, 'INC1'
elseif hko==DEC1 or hko==LEFT1 then
v,hkAction = false,'DEC'
end
-- update change
me.Checked = v
end
-- new function binding the CEEdit1 to UDF1_CEEdit1Change as hotkey handler
-- define hotkeys
local bound1 = bind1(CECheckbox1Change, CETrainer.CECheckbox1)...
...
--/code
When i execute keybind that do that error
`Error:[string "..."]:2: attempt to call a nil value (upvalue 'fn')` |
Check the names?
Also check the event handler assigned in ui designer is matching. _________________
- Retarded. |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Fri Mar 06, 2020 5:06 pm Post subject: |
|
|
Code: | function CETrainer_CECheckbox1Change(me, hko)
if not tonumber(me.Checked)then me.Checked = true end--normalize hex text
local v, hkAction = tonumber(me.Checked)
if hko==INC1 or hko==RIGHT1 then
v,hkAction = true, 'INC1'
elseif hko==DEC1 or hko==LEFT1 then
v,hkAction = false,'DEC1'
end
end
-- new function binding the CEEdit1 to UDF1_CEEdit1Change as hotkey handler
-- define hotkeys
local bound1 = bind1(CECheckbox1Change, CETrainer.CECheckbox1)
if INC1 then INC1=nil,INC1.Destroy()end
INC1 = createHotkey(bound1, VK_C)
if DEC1 then DEC1=nil,DEC1.Destroy()end
DEC1 = createHotkey(bound1, VK_C)
local bound2 = bind1(CECheckbox1Change, CETrainer.CECheckbox1)
if RIGHT1 then RIGHT1=nil,RIGHT1.Destroy()end
RIGHT1 = createHotkey(bound2, VK_C)
if LEFT1 then LEFT1=nil,LEFT1.Destroy()end
LEFT1 = createHotkey(bound2, VK_O)
CETrainer.Show() |
the hotkey not work and name match, and event i only have on Checkbox Event bind1 to OnChange |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Sat Mar 07, 2020 3:35 am Post subject: |
|
|
i got that :
Error:[string "function CECheckbox1Change(sender)..."]:2: attempt to index a nil value (global 'CECheckbox1')
Code: | function CECheckbox1Change(sender)
local state = CECheckbox1 getState(CECheckbox1.Checked)
setProperty(CECheckbox1, "checked", true or false)
end
createHotkey(CECheckbox1Change,VK_P) |
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Sat Mar 07, 2020 5:51 am Post subject: |
|
|
dport80 wrote: | i got that :
Error:[string "function CECheckbox1Change(sender)..."]:2: attempt to index a nil value (global 'CECheckbox1')
Code: | function CECheckbox1Change(sender)
local state = CECheckbox1 getState(CECheckbox1.Checked)
setProperty(CECheckbox1, "checked", true or false)
end
createHotkey(CECheckbox1Change,VK_P) |
|
Need this change?
CECheckbox1 -> CETrainer.CECheckbox1
Code: |
function CECheckbox1Change(sender)
CETrainer.CECheckbox1.Checked = not CETrainer.CECheckbox1.Checked
end
createHotkey(CECheckbox1Change,VK_C)
|
_________________
- Retarded. |
|
Back to top |
|
|
dport80 Newbie cheater Reputation: 0
Joined: 06 Mar 2020 Posts: 12
|
Posted: Sat Mar 07, 2020 6:32 am Post subject: |
|
|
Thank you for being patient to help me
Error:[string "function CECheckbox1Change(sender)..."]:2: C stack overflow
i got that when i bound it while im on generated trainer but it work while im on
go back to generated trainer
Code: |
function CECheckbox1Change(sender)
CETrainer.CECheckbox1.Checked = not CETrainer.CECheckbox1.Checked
end
createHotkey(CECheckbox1Change,VK_C)
createHotkey(CECheckbox1Change,VK_O) |
|
|
Back to top |
|
|
|
|
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
|
|