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 


keyUp / keyDown not working on administrator process

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Selene
How do I cheat?
Reputation: 0

Joined: 26 Aug 2017
Posts: 5

PostPosted: Thu Apr 04, 2019 10:34 am    Post subject: keyUp / keyDown not working on administrator process Reply with quote

I have a case where the script checks for an address to have some value and then press right click (simulate) but the process has so much of a higher administrator level that cheat engine can't input. Do I have to manipulate game memory now or is there a GrantAdministrator type of lua line?

Also I know the script is really beginner, it's cuz I am new to LUA.

It works but doesn't ingame.

And the game needs admin rights for save files.

Code:

test1 = nil
if test1 then
   print("timer exists")
   test1.Enabled = true
else
  test1 = createTimer(test1,true)
  test1.setInterval(50)
  test1.Enabled = true
end


test1.OnTimer = function(test1)
  local ESS = readInteger("[addrres]+8")
  if ESS then
     if ESS > 1 then
        --print("PRESS RBUTTON")
        keyDown(VK_RBUTTON)
        sleep(100)
        keyUp(VK_RBUTTON)
        sleep(100)
     end
  end
  if isKeyPressed(VK_K) == true then
    test1.destroy()
    test1 = nil
    print("Broke out")
  end
end

_________________
I'm just an "odd" one..
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Apr 04, 2019 11:59 am    Post subject: Reply with quote

If you're running CE as admin then it shouldn't matter, sounds like it may read the mouse differently.

And if the game only needs admin rights to save, you should change the privileges of the folder it saves to so it doesn't need admin rights; and you should do this with any program, needless admin rights tend to be a security rick.

_________________
Back to top
View user's profile Send private message Visit poster's website
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Apr 04, 2019 12:20 pm    Post subject: Reply with quote

Use
Code:
mouse_event
function to send mouse clicks.

Code:
mouse_event(0x8007, 2560,6826) -- XY = 100x150 calculated absolute position

Left button
0x8007 = {MOUSEEVENTF_ABSOLUTE,MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP,MOUSEEVENTF_MOVE}

Right button
0x8019 = {MOUSEEVENTF_ABSOLUTE,MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP,MOUSEEVENTF_MOVE}

Single Click in relative to current mouse position
Left button
0x7
Right button
0x19

MOUSEEVENTF_ABSOLUTE means we provide cords

function to calculate absolute position (from X,Y)
Code:
local function CalculateAbsoluteCoordinateX(input,width)
   if (not (type(input)=='number' and type(width)=='number')) then
      return false
   end
   return math.floor((input * 65536) / width);
end
local function CalculateAbsoluteCoordinateY(input,height)
   if (not (type(input)=='number' and type(height)=='number')) then
      return false
   end
   return math.floor((input * 65536) / height);
end

source: https://forum.cheatengine.org/viewtopic.php?p=5688755#5688755

to press relative to current position call it this way:
Code:
--Left Click
mouse_event(0x7)
--Right click
mouse_event(0x19)

More information at MSDN: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-mouse_event

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Selene
How do I cheat?
Reputation: 0

Joined: 26 Aug 2017
Posts: 5

PostPosted: Thu Apr 04, 2019 1:01 pm    Post subject: Reply with quote

DaSpamer wrote:

Code:

mouse_event(0x19)


So 0x19 is "move", "right click down" and "right click up"
But why "move" in particular? I just need it to rclick so why not 0x18
Or was it a mistake?

_________________
I'm just an "odd" one..
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Apr 04, 2019 1:52 pm    Post subject: Reply with quote

Selene wrote:
DaSpamer wrote:

Code:

mouse_event(0x19)


So 0x19 is "move", "right click down" and "right click up"
But why "move" in particular? I just need it to rclick so why not 0x18
Or was it a mistake?

Yes mistake, as I use this to also move the mouse.

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
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