|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Mon Apr 15, 2013 11:52 am Post subject: control_getCaption , CEEdit control instructions |
|
|
hey
Im trying to figure out how to work with CEEdit boxes.
I have a clickbox that enables/desables a function.
This is the clickbox timer configuration
Code: | function CECheckbox1Click(sender) -- if Game timer option is clicked
Timer_enabledOrDisabled = (checkbox_getState(sender)==1)
timer_setEnabled(StopTimerStatus_Timer, Timer_enabledOrDisabled) -- creates a timer if clicked true
end |
This is its timer
Code: | if StopTimerStatus_Timer~=nil then object_destroy(StopTimerStatus_Timer) -- Game Timer object destruction conditions
StopTimerStatus_Timer=nil
end
StopTimerStatus_Timer = createTimer(nil,false) -- Game Timer timer starting conditions
timer_onTimer(StopTimerStatus_Timer, myONtimerFunc)-- Starts StopTimerStatus_Timer creation function at myONtimerFunc event
timer_setInterval(StopTimerStatus_Timer,150)-- restarts every 0.1s |
Now, i have 2 CEEdit boxes CEEdit1, CEEdit 4 and this is how i have them set.
Code: |
function CEEdit1Change(sender)
local TimerShortcutKey1=Control_getCaption(UDF2_CEEdit1)
end
function CEEdit4Change(sender)
local TimerShortcutKey2=Control_getCaption(UDF2_CEEdit4)
end
if TimerShortKey~=nil then object_destroy(TimerShortKey);TimerShortKey=nil;end
local TimerShortKey = createHotkey(function ()
timer_setEnabled(StopTimerStatus_Timer, not timer_getEnabled(StopTimerStatus_Timer) )
end, TimerShortcutKey1, TimerShortcutKey2 ) |
What i want is to enable keyshotcuts where Timerkey1 + TimerKey2 would make 1 keyshortcut like :
CRL(Key1)+D(Key2)=Clickbox1 enable/disable
But i keep getting an error:
Error:[string "--\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\..."]:136: attempt to call global 'Control_getCaption' (a nil value)
i was trying to use the same timer to enable/desable the keys.
This could work (if code is properly writen, but still forces us to write a "string", maybe i could have him read key input and print on CEEdit1, and CEE1 on change would do myONtimerfunc.
Dont know, but i could use some help
Last edited by iroku on Mon Apr 15, 2013 3:46 pm; edited 1 time in total |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Apr 15, 2013 2:36 pm Post subject: |
|
|
you forget what I wrote: Lua is case-sensitive.
If you see this error message:
Code: | attempt to call global 'Control_getCaption' (a nil value) |
or this
Code: | attempt to call global 'timer_OnTimer' (a nil value) |
You can be 100% sure you made a typo. Because it should be
control_getCaption (first char must me lowercase)
and
timer_onTimer (the same here, o must be lowercase o)
Because functions like those, don't exist:
Control_getCaption, control_GetCaption, control_getcaption, control_Getcaption
And createHotkey usage is createHotkey(function, key1, key2, ....).
Those key are integer values, VK codes:
http://msdn.microsoft.com/pl-pl/library/windows/desktop/dd375731%28v=vs.85%29.aspx
Your hotkey creation should look like this:
createHotkey(function, VK_CONTROL, VK_D)
As you see, you cannot use string type (text type).
_________________
Last edited by mgr.inz.Player on Mon Apr 15, 2013 2:42 pm; edited 2 times in total |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Mon Apr 15, 2013 2:38 pm Post subject: |
|
|
Code: | Error:[string "--\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\..."]:136: attempt to call global 'Control_getCaption' (a nil value) |
maybe because you used
And it suppose to be
its case sensitive.
Grr mgr.inz.Player has answered it before I did >.<
mgr.inz.Player wrote: | you forget what I wrote: Lua is case-sensitive.
If you see this error message:
Code: | attempt to call global 'Control_getCaption' (a nil value) |
or this
Code: | attempt to call global 'timer_OnTimer' (a nil value) |
You can be 100% sure you made a typo. Because it should be
control_getCaption (first char must me lowercase)
and
timer_onTimer (the same here, o must be lowercase o)
Because functions like those, don't exist:
Control_getCaption, control_GetCaption, control_getcaption, control_Getcaption
And createHotkey usage is createHotkey(function, key1, key2, ....).
Those key are integer values, VK codes:
http://msdn.microsoft.com/pl-pl/library/windows/desktop/dd375731%28v=vs.85%29.aspx
You hotkey creation should look like this:
createHotkey(function, VK_CONTROL, VK_D)
As you see, you cannot use string type (text type). | [/quote]
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Apr 15, 2013 2:48 pm Post subject: |
|
|
I forget to mention, defines.lua is loaded after launching CE.
So VK_CONTROL already is integer 17, and VK_D is 68.
_________________
|
|
Back to top |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Sun Apr 21, 2013 8:21 am Post subject: |
|
|
well, before, i was trying to use an already made function timer, from: CEClickbox(sender)
Code: |
function CECheckbox1Click(sender) -- if Game timer option is clicked
Timer_enabledOrDisabled = (checkbox_getState(sender)==1)
timer_setEnabled(StopTimerStatus_Timer, Timer_enabledOrDisabled) -- creates a timer if clicked true
end |
and this next code wasnt working (i was told) becouse of ((checkbox_getState(sender)==1) from previous code)
Code: |
function CEEdit1Change(sender)
local TimerShortcutKey1=control_getCaption(UDF2_CEEdit1)
end
function CEEdit4Change(sender)
local TimerShortcutKey2=control_getCaption(UDF2_CEEdit4)
end
if TimerShortKey~=nil then object_destroy(TimerShortKey);TimerShortKey=nil;end
local TimerShortKey = createHotkey(function ()
timer_setEnabled(StopTimerStatus_Timer, not timer_getEnabled(StopTimerStatus_Timer) )
end, TimerShortcutKey1, TimerShortcutKey2 )
-- doesn't work because of (checkbox_getState(sender)==1 |
so i made a new code with new timers and was trying a simple test with just "CONTROL" "F1"
Code: |
function CEEdit1Change(sender)
TimerShortcutKey1= (control_getCaption(UDF2_CEEdit1)=="CONTROL")
timer_setEnabled(If_timer_key1_changed, TimerShortcutKey1)
end
function CEEdit4Change(sender)
TimerShortcutKey2= (control_getCaption(UDF2_CEEdit4)=="F1")
timer_setEnabled(If_timer_key2_changed, TimerShortcutKey2)
end
CONTROL_F1= TimerShortcutKey1==("CONTROL") and TimerShortcutKey2==("F1")
CONTROL_F1_true= CONTROL_F1==true and isKeyPressed(VK_CONTROL, VK_F1)==true
function check_for_key_CONTROL_F1()
if CONTROL_F1_true==true then
checkbox_setState(UDF2_CECheckbox1, 1)
create_CONTROL_F1= createHotkey(check_for_key_CONTROL_F1, VK_F1, VK_CONTROL)
timer_getEnabled(If_timer_key1_changed)
If_timer_key1_changed = createTimer(nil,false)
timer_onTimer(If_timer_key1_changed, check_for_key_CONTROL_F1)
timer_setInterval(If_timer_key1_changed,100)
If_timer_key2_changed = createTimer(nil,false)
timer_onTimer(If_timer_key2_changed, check_for_key_CONTROL_F1)
timer_setInterval(If_timer_key2_changed,100) |
but seems to have the same result. maybe due to checkbox_setState(UDF2_CECheckbox1, 1) as well.
i could really use pointers to get this working. There is no error what so ever and hotkey is never created, with or without CEEdit boxes with text. but even if i do type CONTROL F1 it doesn't create the hotkey :/
|
|
Back to top |
|
|
Gniarf Grandmaster Cheater Supreme Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
Posted: Mon Apr 22, 2013 11:39 am Post subject: Re: control_getCaption , CEEdit control instructions |
|
|
iroku wrote: | I have a clickbox that enables/desables a function.
This is the clickbox timer configuration
[...]
What i want is to enable keyshotcuts where Timerkey1 + TimerKey2 would make 1 keyshortcut like :
CRL(Key1)+D(Key2)=Clickbox1 enable/disable | If I understand correctly you have 2 separate goals:
1-Have a clickbox (aka checkbox) start and stop a timer. For that your CECheckbox1Click looks correct, except that I recommend using OnChange instead of OnClick (see why below).
2-Have user definable hotkeys. For that you use 2 editbox (not bad for a start, better have custom controls that detects what key is pressed in the final version), but the fact of changing hotkeys shouldn't trigger any timer, instead you should just change the keys that make up your hotkey. I mean something like that: Code: | FirstKey=VK_F1;
SecondKey=nil;
ToggleCheckBoxHotkey=createHotkey(ToggleCheckBoxStatus,VK_F1);
function CEEdit1Change(sender) --when changing the key in UDF2_CEEdit1...
if (control_getCaption(UDF2_CEEdit1)=="CONTROL") then
FirstKey=VK_CONTROL;
end
--...redefine the key that make up ToggleCheckBoxHotkey
generichotkey_setKeys(ToggleCheckBoxHotkey, FirstKey, SecondKey);
end
function CEEdit2Change(sender)
if (control_getCaption(UDF2_CEEdit2)=="F1) then
SecondKey=VK_F1;
end
generichotkey_setKeys(ToggleCheckBoxHotkey, FirstKey, SecondKey);
end
function ToggleCheckBoxHotkey(sender) --will change the state of the checkbox, which will trigger a call to its OnChange event handler.
checkbox_setState(UDF2_CECheckbox1, not checkbox_getState(UDF2_CECheckbox1));
end | Disclaimer: I didn't test this.
.......Or perhaps I simply didn't understand what you wanted to do.
|
|
Back to top |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Mon Apr 22, 2013 1:53 pm Post subject: Re: control_getCaption , CEEdit control instructions |
|
|
Gniarf wrote: |
If I understand correctly you have 2 separate goals:
1-Have a clickbox (aka checkbox) start and stop a timer. For that your CECheckbox1Click looks correct, except that I recommend using OnChange instead of OnClick (see why below).
2-Have user definable hotkeys. For that you use 2 editbox (not bad for a start, better have custom controls that detects what key is pressed in the final version), but the fact of changing hotkeys shouldn't trigger any timer, instead you should just change the keys that make up your hotkey.
.......Or perhaps I simply didn't understand what you wanted to do. |
yes thats it.
i tried but there seems to be an access violation with function
Code: | function ToggleCheckBoxHotkey(sender)
checkbox_setState(UDF2_CECheckbox1, not checkbox_getState(UDF2_CECheckbox1));
end |
Its weird because it got me confused as well. I did not know we could do that. How would it know what sender is of a non Lua object ? Same goes for ToggleCheckBoxStatus. Nowhere in the script is ToggleCheckBoxStatus defined, maybe this is why i get the acess error ?
im at (code attached)
i did change the CeckBox to OnChange event.
I like this approach since it does not need timers. ill look into this a bit thanks
Description: |
|
Download |
Filename: |
Hotkey.lua |
Filesize: |
1.92 KB |
Downloaded: |
778 Time(s) |
|
|
Back to top |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Tue Apr 23, 2013 8:07 am Post subject: |
|
|
mm seems to be the same problem as before.
He gets confused when he need to read the clickbox state...
i tried changing the function
function ToggleCheckBoxHotkey(sender)
Code: | function ToggleCheckBoxHotkey(sender) --will change the state of the checkbox, which will trigger a call to its OnChange event handler.
local state = checkbox_getState(UDF2_CECheckbox1)
checkbox_setState(UDF2_CECheckbox1, 1 - state)
end |
i even tried defining ToggleCheckBoxStatus to no avail
And changed (sender) to just
function ToggleCheckBoxHotkey()
always the same acess error :/
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Tue Apr 23, 2013 8:40 am Post subject: |
|
|
I think the problem is that you haven't defined a form named UDF2 with a checkbox names CECheckbox1
Also, keep in mind that checkbox_getState returns one of these 3 values: cbUnchecked (0) , cbChecked (1) and cbGrayed (2)
And checkbox_setState takes one of those 3 values
_________________
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 |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Tue Apr 23, 2013 8:56 am Post subject: |
|
|
Dark Byte wrote: | Keep in mind that checkbox_getState returns one of these 3 values: cbUnchecked (0) , cbChecked (1) and cbGrayed (2)
And checkbox_setState takes one of those 3 values |
i have:
Code: | checkbox_setAllowGrayed(UDF2_CECheckbox1, false) |
at form opening settings, i was under the impression that (2) would never return
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Tue Apr 23, 2013 8:57 am Post subject: |
|
|
2 never returns, but you can still set it (and 1-0 is not the same as 0)
Just make sure the variable names you use actually exist (check that they are not nil)
_________________
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 |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Tue Apr 23, 2013 9:58 am Post subject: |
|
|
Dark Byte wrote: | 2 never returns, but you can still set it (and 1-0 is not the same as 0) |
MM, how would it set to 2 ? do you mean 1-1 is not the same as 0 ?
if state = 0 (1-0=1, checked) if state =1 (1-1=0,unchecked)
if it state never returns 2 then i don't see how setState can set to 2(with this scenario)... i might be reading it wrong, as usual when it comes to this :/
Quote: |
anyhow, try changing UDF2_CECheckbox1 to sender |
still no good
Quote: |
I think the problem is that you haven't defined a form named UDF2 with a checkbox names CECheckbox1 |
when i click on the clickbox1 on UDF2 it does its function, so i though that UDF2 with a clickbox named CECheckbox1 was defined...
if its not tho, how do i make sure it is ?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Tue Apr 23, 2013 10:02 am Post subject: |
|
|
Check the name property of the checkbox in the form that has as name UDF2
To access that checkbox you must then use UDF2_name
_________________
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 |
|
|
iroku Advanced Cheater Reputation: 0
Joined: 18 Oct 2012 Posts: 54
|
Posted: Tue Apr 23, 2013 10:35 am Post subject: |
|
|
Dark Byte wrote: | Check the name property of the checkbox in the form that has as name UDF2
To access that checkbox you must then use UDF2_name |
Form name= UDF2 (same as caption)
CECheckbox1: TCECheckBox
the checkbox is inside a panel, that is olso inside another pannel.
do i have to call UDF2_CEPanel1_CEPanel4_CECheckbox1 ?
Description: |
|
Filesize: |
61.4 KB |
Viewed: |
18511 Time(s) |
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Tue Apr 23, 2013 11:48 am Post subject: |
|
|
UDF2_CECheckbox1 should work then (assuming it's defined at the time the script runs)
Are you sure setting the state is the cause of the crash an not another line? (Try some prints)
What you could also use is setProperty( UDF2_CECheckbox1, "checked", trueorfalse)
_________________
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
Last edited by Dark Byte on Tue Apr 23, 2013 12:02 pm; edited 1 time in total |
|
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
|
|