|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
A93ntZ3r0 How do I cheat? Reputation: 0
Joined: 17 Jan 2017 Posts: 2
|
Posted: Tue Jan 17, 2017 6:59 pm Post subject: New to scripting, need help |
|
|
Hello,
This is the first time trying to script in CE and i am seeking your help
I need the script to act like this:
On hotkey1:
Press escape
do hot key1
pres escape
On hotkey2:
Press escape
do hot key2
pres escape
Where exactly should i put KeyDown(VK_ESCAPE) and KeyUp(VK_ESCAPE) in this Auto generated code:
Code: | --TRAINERGENERATORSTART--
--This is autogenerated code. Changing code in this block will
--get erased and rewritten if you regenerate the trainer code
--Uncomment the following line if this is a Cheat Table format trainer and you don't want CE to show (Tip, save as .CETRAINER alternatively)
--hideAllCEWindows()
RequiredCEVersion=6.6
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
closeCE()
end
addresslist=getAddressList()
memrec0=addresslist.getMemoryRecordByID(0)
memrec0_hotkey0=memrec0.getHotkeyByID(0)
memrec0_hotkey1=memrec0.getHotkeyByID(1)
function onHotkey0(Hotkey)
--Executed before the hotkey is handled
CETrainer.CHEAT0.setActive(true, 1500)
if gPlaySoundOnAction then
playSound(gActivateSound)
end
end
memrec0_hotkey0.onHotkey=onHotkey0
function onHotkey1(Hotkey)
--Executed before the hotkey is handled
CETrainer.CHEAT1.setActive(true, 1500)
if gPlaySoundOnAction then
playSound(gActivateSound)
end
end
memrec0_hotkey1.onHotkey=onHotkey1
CETrainer.SEPERATOR.Visible=false
getAutoAttachList().add("DyingLightGame.exe")
gPlaySoundOnAction=false
CETrainer.show()
function AboutClick()
showMessage(gAboutText)
end
gAboutText=[[This trainer was made by Cheat
Engine]]
function CloseClick()
--called by the close button onClick event, and when closing the form
closeCE()
return caFree --onClick doesn't care, but onClose would like a result
end
--TRAINERGENERATORSTOP-- |
Appreciate your help.
|
|
Back to top |
|
|
A93ntZ3r0 How do I cheat? Reputation: 0
Joined: 17 Jan 2017 Posts: 2
|
Posted: Sun Jan 22, 2017 9:35 pm Post subject: |
|
|
Hello again,
So i think i know how things work now.
Here is the latest code i could think of:
Code: |
memrec0=addresslist.getMemoryRecordByID(1)
memrec0_hotkey0=memrec0.getHotkeyByID(0)
memrec0_hotkey1=memrec0.getHotkeyByID(1)
function Button1Click(sender)
KeyDown(VK_ESCAPE)
KeyUp(VK_ESCAPE)
memrec0_hotkey0.doHotkey()
KeyDown(VK_ESCAPE)
KeyUp(VK_ESCAPE)
end
createHotkey(Button1Click,VK_F1)
function Button2Click(sender)
KeyDown(VK_ESCAPE)
KeyUp(VK_ESCAPE)
memrec0_hotkey1.doHotkey()
KeyDown(VK_ESCAPE)
KeyUp(VK_ESCAPE)
end
createHotkey(Button2Click,VK_F2)
getAutoAttachList().add("DyingLightGame.exe")
gPlaySoundOnAction=false
FormMain.show()
function CloseClick()
closeCE()
return caFree
end
|
The problem is that although the cheat is working perfectly, the key presses are not working in game, but working anywhere else.
I tried "DoKeyPress" and also using sleep() but same problem.
Any suggestions would be appreciated.
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 54
Joined: 01 Oct 2008 Posts: 941
|
Posted: Sun Jan 22, 2017 11:29 pm Post subject: |
|
|
May try this setup, may the test tell the usage clear enough, bye~
add a callStepGroup function here http://forum.cheatengine.org/viewtopic.php?p=5714395#5714395
Code: |
--
function callnext(n,f,...)
local pk,upk,t,p = table.pack,table.unpack,createTimer()
if type(n)~='number'then n,f,p=1,n,pk(f,...)else p = pk(...)end
t.Interval,t.OnTimer = n,function(tm)
tm.Destroy()
pcall(f,upk(p))
end
return t
end
function callstep(n)
assert(type(n)=='number' and n>0,"Input not a positive number: "..tostring(n))
local pk,upk,p = table.pack,table.unpack,{}
local function collect(f,...)
if f == nil then
for i=1,#p do if p[i][1] then callnext(1+(i-1)*n,p[i][1],upk(p[i],2)) end end
else
p[1+#p]= pk(f,...)
return collect
end
end
return collect
end
-- for test
local hk = createHotkey(function()-- the function to do on hotkey
callstep(1000) -- timer interval between each step
(keyDown,VK_A) -- call in 1*1000 ms later
(keyUp,VK_A) -- step 2
(doKeyPress,VK_SPACE)-- step 3
(keyDown,VK_W) -- step 4
(keyUp,VK_W) -- step 5
(doKeyPress,VK_SPACE)-- step 6
(keyDown,VK_S) -- call in 7*1000 ms later etc.
(keyUp,VK_S)
(doKeyPress,VK_SPACE)-- equal to call: doKeyPress(VK_SPACE) , but scheduled
(keyDown,VK_D)
(keyUp,VK_D)
(doKeyPress,VK_SPACE)
(false) -- skip a step
(doKeyPress,VK_SPACE)
(false) -- skip a step
(doKeyPress,VK_SPACE)
()--end setup func list, and call func in sequence from now on
end,
VK_NUMPAD0)
-- destroy the hotkey 20sec later so that not confuse in next test
callnext(20000,function()
hk.Destroy()
print("destroying")
end)
|
NOTE:
there may be some overhead on callnext, too small the step interval may not work as expected.
ADDED:
1.changed the callstep so that the 1st step is executed almost at once as the sequence start.
2.use "false" in place a function position to skip a step.
--------
try to apply callStepGroup on Button1Click
Code: |
function Button1Click(sender)
callStepGroup(10) -- scale
( 0,{doKeyPress, VK_ESC})
( 1,{memrec0_hotkey0.doHotkey})
( 2,{doKeyPress, VK_ESC})
() -- fire
end
createHotkey(Button1Click, VK_F1)
|
@"... the key presses are not working in game, but working anywhere else"
I guess the key press should work on the windows getting focus.
_________________
- Retarded. |
|
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
|
|