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 


Auto Mouse Click V1 (Save-Load-Repeat)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Aylin
Grandmaster Cheater
Reputation: 10

Joined: 16 Feb 2017
Posts: 661

PostPosted: Tue Apr 06, 2021 4:21 pm    Post subject: Auto Mouse Click V1 (Save-Load-Repeat) Reply with quote

Over existing CE-Lua codes;
Let's do an automatic click simulation.

I've posted an example of this as a free Trainer.
I find it useful to share the code content as an add-on in this archive.

The codes used;
getMousePos()
setMousePos()
mouse_event()
keyDown()
keyUp()

Trainer usage explanation;
1) Save: Move the mouse arrow to the place to be clicked and press the F8 key.
2) Speed: Set the click speed. (1 x 10 is predicted. Accordingly, Speed (100) = 10 will be written. Default = 5 (= speed (50))
3) Repeat: Determine how long you will repeat the list. Default = 1.
4) Lock: After all settings are done, it locks the list and creates a hotkey for start.
5) Start: Press the hotkey created by locking and activate it. Default = F9.

You can edit the code below or save it to a .lua file as it is and drop it in the CE >> Autorun folder.
Here is the code;
Mouse Auto Click (M_A_Clk)
Code:

--[[
RequiredCEVersion=7.1
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
local answer = messageDialog("This encoding will work better with\nCE 7.1 and above versions.\nWould you like to go to the\nCheat Engine page to download the latest version?", mtWarning, mbYes, mbNo)
if answer == mrYes then
shellExecute("https://www.cheatengine.org/")
  closeCE()
 return caFree()
else
  closeCE()
 return caFree()
end
end
]]
--################################################################--
--################################################################--
function AutoClick1()
if AC_frm then AC_frm.Destroy() AC_frm=nil end

AC_frm=createForm()
AC_frm.Popupmode = 0;
AC_frm.width=280 AC_frm.height=195
AC_frm.Caption="Creator ByAYLIN (2021)"
AC_frm.BorderStyle="bsNone"
AC_frm.setLayeredAttributes(16711807, 255, LWA_COLORKEY | LWA_ALPHA )
AC_frm.Color=16711807
AC_frm.Position="poDesktopCenter"
AC_frm.ShowInTaskBar="stAlways"

local AC_pnl1 = createPanel(AC_frm)
AC_pnl1.left=45 AC_pnl1.top=5 AC_pnl1.width=190 AC_pnl1.height=26 AC_pnl1.Color="65280"
AC_pnl1.Caption='AutoClick Trainer V0.1' AC_pnl1.BevelColor="16711680" AC_pnl1.Cursor= -22
AC_pnl1.font.size=12 AC_pnl1.font.style="fsBold" AC_pnl1.BevelWidth=3
AC_pnl1.OnMouseDown = function() AC_frm.DragNow() end

local AC_pnl2 = createPanel(AC_frm)
AC_pnl2.left=10 AC_pnl2.top=5 AC_pnl2.width=30 AC_pnl2.height=26 AC_pnl2.Color="65280"
AC_pnl2.Caption='-' AC_pnl2.BevelColor="16711680"
AC_pnl2.font.size=34 AC_pnl2.font.style="fsBold" AC_pnl2.BevelWidth=3

local AC_pnl3 = createPanel(AC_frm)
AC_pnl3.left=240 AC_pnl3.top=5 AC_pnl3.width=30 AC_pnl3.height=26 AC_pnl3.Color="65280"
AC_pnl3.Caption='X' AC_pnl3.BevelColor="16711680"
AC_pnl3.font.size=18 AC_pnl3.font.style="fsBold" AC_pnl3.BevelWidth=3

local AC_pnl4 = createPanel(AC_frm)
AC_pnl4.left=10 AC_pnl4.top=160 AC_pnl4.width=163 AC_pnl4.height=26 AC_pnl4.Color="65280"
AC_pnl4.Caption='Creator ByAYLIN' AC_pnl4.BevelColor="16711680"
AC_pnl4.font.size=11 AC_pnl4.font.style="fsBold" AC_pnl4.BevelWidth=3

local AC_pnl5 = createPanel(AC_frm)
AC_pnl5.left=177 AC_pnl5.top=160 AC_pnl5.width=93 AC_pnl5.height=26 AC_pnl5.Color="65280"
AC_pnl5.Caption='DONATE' AC_pnl5.BevelColor="16711680"
AC_pnl5.font.size=13 AC_pnl5.font.style="fsBold"

local AC_pnl6 = createPanel(AC_frm)
AC_pnl6.left=180 AC_pnl6.top=40 AC_pnl6.width=90 AC_pnl6.height=115 AC_pnl6.Color="65278"
AC_pnl6.Caption='' AC_pnl6.BevelColor=""
AC_pnl6.font.size=16 AC_pnl6.font.style="fsBold" AC_pnl6.BevelWidth=3
AC_pnl6.visible=true
-----------------------------------------------------------------------

local AC_lblx = createLabel(AC_pnl6)
AC_lblx.AutoSize=false
AC_lblx.left=5 AC_lblx.top=0 AC_lblx.height=16 AC_lblx.width=80
AC_lblx.font.size=11 AC_lblx.font.style="fsBold" AC_lblx.caption="PosX:"

local AC_lbly = createLabel(AC_pnl6)
AC_lbly.AutoSize=false
AC_lbly.left=5 AC_lbly.top=16 AC_lbly.height=16 AC_lbly.width=80
AC_lbly.font.size=11 AC_lbly.font.style="fsBold" AC_lbly.caption="PosY:"

local AC_btn1 = createButton(AC_pnl6)
AC_btn1.AutoSize=false
AC_btn1.left=5 AC_btn1.top=33 AC_btn1.height=22 AC_btn1.width=80
AC_btn1.font.size=11 AC_btn1.font.style="fsBold" AC_btn1.caption="Reset List"

local AC_lbl1 = createLabel(AC_pnl6)
AC_lbl1.AutoSize=false
AC_lbl1.left=5 AC_lbl1.top=59 AC_lbl1.height=19 AC_lbl1.width=45
AC_lbl1.font.size=11 AC_lbl1.font.style="fsBold" AC_lbl1.caption="Speed:"

local AC_edt1 = createEdit(AC_pnl6)
AC_edt1.AutoSize=false
AC_edt1.left=52 AC_edt1.top=58 AC_edt1.height=16 AC_edt1.width=30
AC_edt1.font.style="fsBold" AC_edt1.font.size=9 AC_edt1.Text="5"

local AC_lbl2 = createLabel(AC_pnl6)
AC_lbl2.AutoSize=false
AC_lbl2.left=5 AC_lbl2.top=80 AC_lbl2.height=16 AC_lbl2.width=45
AC_lbl2.font.size=10 AC_lbl2.font.style="fsBold" AC_lbl2.caption="Repeat:"

local AC_edt2 = createEdit(AC_pnl6)
AC_edt2.AutoSize=false
AC_edt2.left=52 AC_edt2.top=77 AC_edt2.height=16 AC_edt2.width=30
AC_edt2.font.style="fsBold" AC_edt2.font.size=9 AC_edt2.Text="1"

local AC_chk1 = createCheckBox(AC_pnl6)
AC_chk1.AutoSize=false
AC_chk1.left=5 AC_chk1.top=93 AC_chk1.height=23 AC_chk1.width=80 AC_chk1.checked=false
AC_chk1.font.size=11 AC_chk1.font.style="fsBold" AC_chk1.caption="Lock"

local AC_memo1=createMemo(AC_frm)
AC_memo1.left=10 AC_memo1.top=40 AC_memo1.height=114 AC_memo1.width=160
AC_memo1.font.size=9 AC_memo1.font.style="fsBold"
AC_memo1.WordWrap=false AC_memo1.ScrollBars="ssAutoBoth" AC_memo1.visible=true

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

AC_Tmr1=createTimer(false) AC_Tmr1.Interval=100
AC_Tmr1.Enabled=true

local RpT=0
local rslt=0

--################################################################--

if autoH2 then autoH2.destroy() autoH2=nil end
if autoH3 then autoH3.destroy() autoH3=nil end

AC_Tmr1.OnTimer=function(z)
x,y = getMousePos()
 AC_lblx.caption = 'PosX: '..tostring(x)
 AC_lbly.caption = 'PosY: '..tostring(y)
end

function SaveClk()
sleep(200)
if AC_memo1.Enabled==false then
showMessage("The list appears to be locked.\nPlease unlock the list first!\nListe kilitli görünüyor.\nLütfen önce listenin kilidini açın!");
else
AC_memo1.Lines.Add(">>"..AC_lblx.caption.."<< >>"..AC_lbly.caption.."<<")
end
end

autoH3=createHotkey(SaveClk, VK_F8)

function LoadClk()
keyUp(VK_F9)
RpT=tonumber(RpT) + 1
RpT1=tonumber(AC_edt2.Text)
local spd2=tonumber(AC_edt1.Text) * 10
if AC_edt1.Text=="" then spd2=50 end
sleep(200)
local SL = createStringlist()
SL.Text=AC_memo1.Lines.Text
local finiss=strings_getCount(AC_memo1.Lines)-1
for i=0, strings_getCount(SL)-1 do
sleep(tonumber(spd2))
Px2=SL[i]:match(">>PosX: (.-)<< ")
--print("Px2: "..Px2)
Py2=SL[i]:match("<< >>PosY: (.-)<<")
--print("Py2: "..Py2)
if Px2~=nil then
setMousePos(Px2,Py2)
mouse_event(MOUSEEVENTF_LEFTDOWN)
mouse_event(MOUSEEVENTF_LEFTUP)
end
if i==finiss then
rslt=tonumber(rslt) + i + 1
--print(RpT.." / "..RpT1)
if RpT==RpT1 then
showMessage("Auto Click Finished!\nTotal Click: "..rslt)
else
keyDown(VK_F9)
end
end
end
SL=nil
end

AC_chk1.OnChange=function()
if AC_edt2.Text=="" then AC_edt2.Text="1" end
if AC_chk1.checked==true then
rslt=0
RpT=0
AC_memo1.Enabled=false
AC_btn1.Enabled=false
AC_edt1.Enabled=false
AC_edt2.Enabled=false
AC_chk1.caption="Un-Lock"
if autoH2 then autoH2.destroy() autoH2=nil end
autoH2=createHotkey(LoadClk, VK_F9)
else
if autoH2 then autoH2.destroy() autoH2=nil end
AC_memo1.Enabled=true
AC_btn1.Enabled=true
AC_edt1.Enabled=true
AC_edt2.Enabled=true
AC_chk1.caption="Lock"
end
end

AC_btn1.OnClick=function()
AC_memo1.Lines.Text=""
end

--################################################################--
AC_pnl2.OnClick=function()
AC_frm.WindowState = "wsMinimized"
end

AC_pnl3.OnClick=function()
  AC_frm.Close()
  --closeCE()
  --return caFree
end

AC_pnl5.OnClick=function()
shellExecute("https://www.paypal.com/xclick/business=dark_byte%40hotmail.com&no_note=1&tax=0&lc=US")
end

function panelcap(item2) --Effect
 item2.BevelColor=16728064
 item2.Cursor= -21
 item2.BevelInner="bvRaised" item2.BevelWidth=3
item2.Font.Style="fsBold"
item2.OnMouseMove=function() item2.BevelColor=0xffffff end
item2.OnMouseLeave=function() item2.BevelColor=16728064 end
end

panelcap(AC_pnl2) panelcap(AC_pnl3) panelcap(AC_pnl5)
end

--AutoClick1()

if miAClick then miAClick.Destroy() end
local mf = getMainForm()
local mainMenu = mf.Menu.Items
miAClick = createMenuItem(mf.MainMenu)
   miAClick.Caption = 'M_A_Clk'
   miAClick.OnClick=AutoClick1
   mainMenu.insert(mainMenu.Count-1,miAClick)


A visual is presented here:

Link


Enjoy it. Cool
If you like it, don't forget to leave +1 reputation. Wink
See you in another archive. Idea Idea Idea

_________________
Hi Hitler Take control of your trainer
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 MSN Messenger
Csimbi
I post too much
Reputation: 77

Joined: 14 Jul 2007
Posts: 2762

PostPosted: Sun Apr 25, 2021 4:30 am    Post subject: Reply with quote

Pretty neat.
You could add an 'auto repeat' checkbox to the list (above and below) and that way you don't need to copy-paste.
Rinse and repeat until the next F9 Wink

Or, add a 'Run count' box, too where you can enter how many times the list is repeated.

Better yet, do both Wink
Back to top
View user's profile Send private message
Aylin
Grandmaster Cheater
Reputation: 10

Joined: 16 Feb 2017
Posts: 661

PostPosted: Sun Apr 25, 2021 5:45 am    Post subject: Reply with quote

Thanks @Csimbi. It's nice to be in control of the masters.
If you watched the code from the video, yes I did copy-paste to repeat it.
But in the code I shared above, I left a box for "Repeat".
The repeat box defaults to 1, but clicking "F9" will continue clicking until the value entered in the "Repeat" box.
Please test the code.
Thanks again for the return.

_________________
Hi Hitler Take control of your trainer
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 MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions 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