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 for last file

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

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu Nov 02, 2023 7:04 am    Post subject: Hotkey for last file Reply with quote

How to add hotkeys for the last two CE recent files?
So that the last recent file can be opened using the F9 hotkey, and the penultimate recent file can be opened using the 'ctrl + 2' hotkeys.
As a result, to open the last CT file we need to press F9. This will make things a little easier and faster for everyone who uses CE frequently.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu Nov 02, 2023 7:43 am    Post subject: Reply with quote

add to your autorun folder

Code:

local oldclick=MainForm.File1.OnClick
MainForm.File1.OnClick=function(s)
  oldclick(s)
  for i=0,math.min(MainForm.miLoadRecent.Count-3,9) do  -- -3 because the last 2 aren't table entries
    local shortcut='Ctrl+'..(i+1) % 10
    --print(MainForm.miLoadRecent.Item[i].Caption..' gets shortcut '..shortcut)
    MainForm.miLoadRecent.Item[i].ShortCut=textToShortCut(shortcut)
  end
end

MainForm.File1.doClick() --init once else it only fills it when you click on the File menu


replace the 9 with 1 if you only want the first 2

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu Nov 02, 2023 1:42 pm    Post subject: Reply with quote

Dark Byte wrote:
add to your autorun folder

CE 7.4 shows an error: Access violation, some condition is needed until CE window loads. Hotkeys in CE 7.4/7.5 only work after clicking on the "File" menu. It seems that the code: MainForm.File1.doClick() is being executed before the CE window appears.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu Nov 02, 2023 2:41 pm    Post subject: Reply with quote

ah ok. i didn't test it in autorun
then try
Code:

createTimer(1,function()
local oldclick=MainForm.File1.OnClick
MainForm.File1.OnClick=function(s)
  oldclick(s)
  for i=0,math.min(MainForm.miLoadRecent.Count-3,9) do  -- -3 because the last 2 aren't table entries
    local shortcut='Ctrl+'..(i+1) % 10
    --print(MainForm.miLoadRecent.Item[i].Caption..' gets shortcut '..shortcut)
    MainForm.miLoadRecent.Item[i].ShortCut=textToShortCut(shortcut)
  end
end

MainForm.File1.doClick() --init once else it only fills it when you click on the File menu
end)


(still not tested, and the issue may be somewhere else as autorun should execute after the mainform is present)

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu Nov 02, 2023 4:05 pm    Post subject: Reply with quote

Dark Byte wrote:
then try

it works now, thanks
P.S.: Since I had ctrl+1 hotkey and rarely used it, here is another code with the F9 hotkey for the last file.
Code:
createTimer(100,function()
local oldclick=MainForm.File1.OnClick
MainForm.File1.OnClick=function(s)
  oldclick(s)
  MainForm.miLoadRecent.Item[0].ShortCut=textToShortCut('F9')
  for i=1,math.min(MainForm.miLoadRecent.Count-3,9) do  -- -3 because the last 2 aren't table entries
    local shortcut='Ctrl+'..(i+1) % 10
    --print(MainForm.miLoadRecent.Item[i].Caption..' gets shortcut '..shortcut)
    MainForm.miLoadRecent.Item[i].ShortCut=textToShortCut(shortcut)
  end
end

MainForm.File1.doClick() --init once else it only fills it when you click on the File menu
end)
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