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 


Hotkey activating auto click

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

Joined: 27 Oct 2015
Posts: 59

PostPosted: Mon Apr 06, 2020 1:32 am    Post subject: Hotkey activating auto click Reply with quote

Hello, I'm trying to make a hotkey in my trainer that will activate an auto click for every 1 second. Can anybody show me an example?


What I have right now:


Code:
form_show(UDF1)
UDF1.centerScreen();

getAutoAttachList().add("Game.exe")
--AboutText=[[description]]

--UDF1.OnClose = CloseClick
--addresslist=getAddressList()





function SendMouseClick()
 sleep(1000)
  mouse_event(MOUSEEVENTF_LEFTDOWN)
  sleep(100)
  mouse_event(MOUSEEVENTF_LEFTUP)
end



function toggleAutoClicker()
         UDF1.lblStatus.Font.Color=0x00ff00
         UDF1.lblStatus.Caption="[ON]"
         SendMouseClick()
  else
         UDF1.lblStatus.Font.Color=0xff0011
         UDF1.lblStatus.Caption="[OFF]"
         -- Autoclicker Stop Code
  end
end

if AutoClickHotkey and AutoClickHotkey.destroy then
AutoClickHotkey.destroy()
end

AutoClickHotkey = nil
AutoClickHotkey = createHotkey(toggleAutoClicker,VK_NUMPAD1)
AutoClickHotkey.DelayBetweenActivate = 1000

Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1531

PostPosted: Mon Apr 06, 2020 5:13 am    Post subject: Reply with quote

CEF is built-in code.
The current setting is one click per second.
Note: To slow down, write a high number in the box. Wink

Enjoy it!

Code:
local f=createForm(true)
f.Position = poDesktopCenter
f.Width = 200
f.Height = 100
local e1=createEdit(f) e1.Left=85 e1.Top=38 e1.Width=45 e1.Text="1000"
local l1=createLabel(f) l1.Left=25 l1.Top=15 l1.caption="AutoClick (Start: F8 - Stop: F8)"
local l2=createLabel(f) l2.Left=88 l2.Top=64 l2.caption="Stop.."

if myhotkey then
  myhotkey.Destroy()
  myhotkey = nil
end

function killmytimer()
  if mytimer then
    mytimer.Destroy()
    mytimer = nil
    l2.caption="Stop.."
--showMessage("AutoClick Close")
  end
end

myhotkey = createHotkey(function()
  if mytimer then
    killmytimer()
  else
    mytimer=createTimer()
    mytimer.interval=e1.Text
    mytimer.OnTimer=function()
    l2.caption="Play.."
      mouse_event(MOUSEEVENTF_LEFTDOWN)
      mouse_event(MOUSEEVENTF_LEFTUP)
--      print("bla")
    end
  end
end, VK_F8)

_________________
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
yy5202071314
How do I cheat?
Reputation: 0

Joined: 30 Mar 2020
Posts: 3

PostPosted: Tue Apr 07, 2020 8:50 am    Post subject: Re: Hotkey activating auto click Reply with quote

switch_switch = true
switch_switch2 = true

function switch2()
while switch_switch2 do

--Your code
sleep(500)--Reduce CPU usage
end
end


function switch()
if switch_switch then
switch_switch = false
switch_switch2 = true
createNativeThread(switch2)--Create thread
else
switch_switch = true
switch_switch2 = false
end
end

createHotkey(switch,{key})--Key=Key code
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Tue Apr 14, 2020 1:18 am    Post subject: Reply with quote

Aylin wrote:
CEF is built-in code.
The current setting is one click per second.
Note: To slow down, write a high number in the box. Wink

Enjoy it!

Code:
local f=createForm(true)
f.Position = poDesktopCenter
f.Width = 200
f.Height = 100
local e1=createEdit(f) e1.Left=85 e1.Top=38 e1.Width=45 e1.Text="1000"
local l1=createLabel(f) l1.Left=25 l1.Top=15 l1.caption="AutoClick (Start: F8 - Stop: F8)"
local l2=createLabel(f) l2.Left=88 l2.Top=64 l2.caption="Stop.."

if myhotkey then
  myhotkey.Destroy()
  myhotkey = nil
end

function killmytimer()
  if mytimer then
    mytimer.Destroy()
    mytimer = nil
    l2.caption="Stop.."
--showMessage("AutoClick Close")
  end
end

myhotkey = createHotkey(function()
  if mytimer then
    killmytimer()
  else
    mytimer=createTimer()
    mytimer.interval=e1.Text
    mytimer.OnTimer=function()
    l2.caption="Play.."
      mouse_event(MOUSEEVENTF_LEFTDOWN)
      mouse_event(MOUSEEVENTF_LEFTUP)
--      print("bla")
    end
  end
end, VK_F8)


thank you this worked perfect, but I was wondering if it would be possible to target the clicks inside my game instead of everywhere else on the pc. I only want to send mouse clicks every 1 second inside a game window
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Apr 14, 2020 7:21 am    Post subject: Reply with quote

ZxPwds wrote:
[ but I was wondering if it would be possible to target the clicks inside my game instead of everywhere else on the pc. I only want to send mouse clicks every 1 second inside a game window


Use findWindow() or getForegroundWindow()

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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