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 


Holding Buttons?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
dan013
Cheater
Reputation: 0

Joined: 30 Dec 2023
Posts: 28

PostPosted: Sat Jan 27, 2024 2:22 am    Post subject: Holding Buttons? Reply with quote

So my senario is i have a button that increase the value 0.10 of address for every click but i want to do is keep increasing the value when i hold the button. Can someone teach me how to do it. Thanks
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1516

PostPosted: Sat Jan 27, 2024 5:36 am    Post subject: Reply with quote

Code:
if f1 then f1.destroy() f1=nil end

f1 = createForm() -- your form (UDF1 or myTrainer etc.)
b1 = createButton(f1) -- your button name? (UDF1.CEButton1 etc.)
b1.Top=80 b1.Left=80 b1.Height=35 b1.Width=130
b1.Caption = "MouseDown Start"

lastIndex=1

function checkKeys(timer)
  if isKeyPressed(VK_LBUTTON) then
     -- Put your code here that increases the value by "0.10".
     -- (Must be between if..else. Not between else..end.)
      lastIndex=tonumber(lastIndex) + 1
      print(lastIndex)
  else
      lastIndex=1
      timer.Enabled = false
  end
end

if downTmr1 then downTmr1.destroy() downTmr1=nil end

downTmr1=createTimer(MainForm)
downTmr1.Interval=10
downTmr1.OnTimer=checkKeys
downTmr1.Enabled=false


b1.OnMouseDown=function(sender)
downTmr1.Enabled = true
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dan013
Cheater
Reputation: 0

Joined: 30 Dec 2023
Posts: 28

PostPosted: Sun Jan 28, 2024 9:57 pm    Post subject: Reply with quote

AylinCE wrote:
Code:
if f1 then f1.destroy() f1=nil end

f1 = createForm() -- your form (UDF1 or myTrainer etc.)
b1 = createButton(f1) -- your button name? (UDF1.CEButton1 etc.)
b1.Top=80 b1.Left=80 b1.Height=35 b1.Width=130
b1.Caption = "MouseDown Start"

lastIndex=1

function checkKeys(timer)
  if isKeyPressed(VK_LBUTTON) then
     -- Put your code here that increases the value by "0.10".
     -- (Must be between if..else. Not between else..end.)
      lastIndex=tonumber(lastIndex) + 1
      print(lastIndex)
  else
      lastIndex=1
      timer.Enabled = false
  end
end

if downTmr1 then downTmr1.destroy() downTmr1=nil end

downTmr1=createTimer(MainForm)
downTmr1.Interval=10
downTmr1.OnTimer=checkKeys
downTmr1.Enabled=false


b1.OnMouseDown=function(sender)
downTmr1.Enabled = true
end


This will help. Thanks alot
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
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