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 clicker

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

Joined: 27 Jul 2016
Posts: 78

PostPosted: Sat Aug 19, 2017 7:59 pm    Post subject: auto clicker Reply with quote

Hello all member CE
I have the following problem hope to help.
My code is as follows
Code:
if mytimer2 == nil then
  mytimer2 = createTimer(nil, false)
end
mytimer2.OnTimer = function(timer)
  mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP)
end
mytimer2.Interval = 500

if myhotkey then
  myhotkey.Destroy()
end
myhotkey = createHotkey(function()
  mytimer2.Enabled = not mytimer2.Enabled
end, VK_F1)

Its function is auto clicker. I'm really annoyed when naughty children, they naughty my computer when I'm gone. Deflector pointer that I activate F1 before.
My question is there is a way to keep a fixed position when I press F1?
Tks ALL Very Happy
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 348

PostPosted: Sat Aug 19, 2017 8:28 pm    Post subject: Reply with quote

Presumably calling setMousePos(x,y) inside the OnTimer function would work.

Though if you're really worried about people messing with it then you'll probably need to worry about them pressing the power button to reset it once they realize they can't use the mouse, not sure how to handle that (especially holding down the power) but...also for older children they'll probably eventually figure out which key toggles it so you might want to use inputQuery to ask for a password and stringToMD5String to generate a hash from the input to compare to one saved in the script (that way they can't simply find the script and read the password, all they get is the hash).

Over time you may also need to worry about someone opening a command prompt or something that might let them cancel the script by killing CE, if you can open something on top of where the mouse is clicking then it'd keep the focus because the mouse is constantly clicking on it. Using the win api SetForegroundWindow may help with that, example usage

Code:
local hwnd = findWindow(nil, '... - VLC media player') -- I was watching a movie lol
if hwnd ~= 0 and getForegroundWindow() ~= hwnd then -- found window and not foreground
  local success = executeCodeLocal('SetForegroundWindow',hwnd) ~= 0
end


Ultimately it depends on just how far you want to go, it's possible that other programs already exist that might help, though I haven't done any google searches to find out Smile
Back to top
View user's profile Send private message
Sting9x
Advanced Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 78

PostPosted: Sat Aug 19, 2017 8:46 pm    Post subject: Reply with quote

FreeER wrote:
Presumably calling setMousePos(x,y) inside the OnTimer function would work.

Though if you're really worried about people messing with it then you'll probably need to worry about them pressing the power button to reset it once they realize they can't use the mouse, not sure how to handle that (especially holding down the power) but...also for older children they'll probably eventually figure out which key toggles it so you might want to use inputQuery to ask for a password and stringToMD5String to generate a hash from the input to compare to one saved in the script (that way they can't simply find the script and read the password, all they get is the hash).

Over time you may also need to worry about someone opening a command prompt or something that might let them cancel the script by killing CE, if you can open something on top of where the mouse is clicking then it'd keep the focus because the mouse is constantly clicking on it. Using the win api SetForegroundWindow may help with that, example usage

Code:
local hwnd = findWindow(nil, '... - VLC media player') -- I was watching a movie lol
if hwnd ~= 0 and getForegroundWindow() ~= hwnd then -- found window and not foreground
  local success = executeCodeLocal('SetForegroundWindow',hwnd) ~= 0
end


Ultimately it depends on just how far you want to go, it's possible that other programs already exist that might help, though I haven't done any google searches to find out Smile

My idea is when I activated the F1 key. The pointer will remain in a fixed position on the screen, although I pointed at the mouse, it was still in that position.
Back to top
View user's profile Send private message
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

PostPosted: Sun Aug 20, 2017 4:59 pm    Post subject: Reply with quote

from your code

Code:
..
mytimer2.OnTimer = function(timer)
  mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP)
  setMousePos(1,1)
end
mytimer2.Interval = 500
..

_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
Back to top
View user's profile Send private message
Sting9x
Advanced Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 78

PostPosted: Sun Aug 20, 2017 7:49 pm    Post subject: Reply with quote

Corroder wrote:
from your code

Code:
..
mytimer2.OnTimer = function(timer)
  mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP)
  setMousePos(1,1)
end
mytimer2.Interval = 500
..

I've been tried, but the frame size is a lot, Is there a way to pointer in a certain position?
Back to top
View user's profile Send private message
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

PostPosted: Mon Aug 21, 2017 12:12 am    Post subject: Reply with quote

function setMousePos(x, y)

Sets the mouse cursor to the specified coordinates.

Parameter Type Description
x Integer The x coordinate to set the mouse cursor to
y Integer The y coordinate to set the mouse cursor to

Get it from another topic :

http://www.cheatengine.org/forum/viewtopic.php?t=602233&sid=38ce612f4e1002ff482acdc0dfc17d3a

_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
Back to top
View user's profile Send private message
Sting9x
Advanced Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 78

PostPosted: Mon Aug 21, 2017 7:26 am    Post subject: Reply with quote

Corroder wrote:
function setMousePos(x, y)

Sets the mouse cursor to the specified coordinates.

Parameter Type Description
x Integer The x coordinate to set the mouse cursor to
y Integer The y coordinate to set the mouse cursor to

Get it from another topic :

http://www.cheatengine.org/forum/viewtopic.php?t=602233&sid=38ce612f4e1002ff482acdc0dfc17d3a

Thank you for your enthusiastic support, I have a question.
Is there a way to exit CE means the game will turn off?
Back to top
View user's profile Send private message
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

PostPosted: Mon Aug 21, 2017 4:36 pm    Post subject: Reply with quote

maybe something like this to exit a process :

Code:

shellExecute('cmd.exe', '/c taskkill /PID ' .. getOpenedProcessID(), nil, false);

or

Code:
   
shellExecute('cmd.exe', '/c taskkill /PID ' .. getOpenedProcessID(), 'C:\\Windows\\System32\\', false);   


put the command under checkbox or button click function

_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
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