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 


replace key combos with another using Lua?

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

Joined: 22 Jun 2015
Posts: 34

PostPosted: Thu Jan 20, 2022 7:39 am    Post subject: replace key combos with another using Lua? Reply with quote

Hello, my game doesn't support CTRL + A to select all text. however you can HOME, then SHIFT + END to essentially do the same thing.

is this something that can be done via Lua? where pressing CTRL+A = HOME, SHIFT+END?

I only want this key replacement to work on my game, and not globally across the rest of my PC when I tab away from the game.

any guidance or direction would be greatly appreciated!
thanks so much!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Jan 20, 2022 7:51 am    Post subject: Reply with quote

Code:

if hk then hk.destroy() hk=nil end
hk=createHotkey(function()
  if getForegroundProcess()==getOpenedProcessID() then
    --first unpress the control key in case it acts like an normal list where index and selection can be different
    keyUp(VK_LCONTROL)
    keyUp(VK_RCONTROL)
    keyUp(VK_CONTROL)
    sleep(10)

    --now do the home, shift+end
    doKeyPress(VK_HOME)
    keyDown(VK_SHIFT)
    doKeyPress(VK_END)
    keyUp(VK_SHIFT)
  end
end, VK_CONTROL, VK_A)


(tested on ce's foundlist, which also doesn't do ctrl+a, for a good reason)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
catfood
Cheater
Reputation: 0

Joined: 22 Jun 2015
Posts: 34

PostPosted: Thu Jan 20, 2022 10:11 am    Post subject: Reply with quote

i am trying to do a similar thing where up / down keyboard arrows enter a single mouse wheel scroll up / down respectfully. however I cannot find any documentation on the wiki of mouse wheel scrolling.
https://wiki.cheatengine.org/index.php?title=Lua:keyDown
is mouse wheel scrolling supported?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Jan 20, 2022 11:22 am    Post subject: Reply with quote

mouse_event might work with 0x800 (MOUSEEVENTF_WHEEL)

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event
(this winapi is also exposed in lua)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
catfood
Cheater
Reputation: 0

Joined: 22 Jun 2015
Posts: 34

PostPosted: Thu Jan 20, 2022 4:36 pm    Post subject: Reply with quote

thank you again, last question hopefully, then I have everything working. is there a function similar to autohotkey's [url=https://www.autohotkey.com/docs/commands/KeyWait.htm]KeyWait[/url]?

I would like to be able to triggger scroll wheel up using up arrow, without losing the ability to hold up arrow to move upward in my game.
some sudocode like:

[code]if hk then hk.destroy() hk=nil end
hk=createHotkey(function()
if getForegroundProcess()==getOpenedProcessID() then
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 40, 0)
keyWait(VK_UP) --THIS IS A GUESS OF HOW IT MIGHT BE CALLED
end
end, VK_UP)[/code]

if this function doesn't exist, I was wondering if some while loop could do it using the isKeyPressed function, or something.

is this even possible with Lua? I've spent the better part of the day googling and trying reference code to piece something together.

any guidance is much appreciated, thanks!
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