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 


Attach if the window is active?

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

Joined: 15 May 2018
Posts: 10

PostPosted: Thu Dec 17, 2020 4:50 am    Post subject: Attach if the window is active? Reply with quote

I'm developing some code in C# and its going well.
As part of my project i utilise Cheat engine's 'Speed hack', using the hot keys.

Someone wrote me this small .lua function which auto-attaches to the most recently opened process.

Can this be adjusted to attach to the current 'active' window if process = title.exe (or if active window title = title.exe then attachProcess())

Code:
getAutoAttachList().add('title.exe')
local settings = getSettings() -- stored in windows registry (eg. regedit)
local originalAA = settings.Value['Always AutoAttach']

-- setup to restore value
MainForm.OnClose = function(...)
  settings.Value['Always AutoAttach'] = originalAA
  return caFree
end

settings.Value['Always AutoAttach'] = 1
reloadSettingsFromRegistry()
Back to top
View user's profile Send private message
noobes
Advanced Cheater
Reputation: 0

Joined: 17 Dec 2018
Posts: 89

PostPosted: Thu Dec 24, 2020 5:55 am    Post subject: Re: Attach if the window is active? Reply with quote

B4 making a thread please search it on google, you may find it!

https://wiki.cheatengine.org/index.php?title=Tutorials:Lua:Setup_Auto_Attach

Whatever, i think you're talking about that as you said you need the process to match so it gets auto attached

Code:
PROCESS_NAME = 'csgo.exe' ---change the process name to whatever you need, remember, keep the .exe at the end -noobes
--------
-------- Auto Attach
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
        ---- Destroy timer if max ticks is reached
   if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
      timer.destroy()
   end
        ---- Check if process is running
   if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
      timer.destroy() ---- Destroy timer
      openProcess(PROCESS_NAME) ---- Open the process
   end
   autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
Back to top
View user's profile Send private message
clerythecleric
Newbie cheater
Reputation: 0

Joined: 15 May 2018
Posts: 10

PostPosted: Mon Dec 28, 2020 1:09 am    Post subject: Reply with quote

"B4 making a thread please search it on google, you may find it!"

Try understanding the question before replying. What you answered didn't answer it in the slightest, Furthermore the answer your provided was already in the original thread. All you had to do was open your eyes to see your post helps nobody.

"Whatever, I think you're talking about that as you said you need the process to match so it gets auto attached"

At no point in my point did I say 'I need the process to match'. You're an idiot.

I've already resolved my issue anyway I just don't appreciate children incorrectly dictating rules to me while stimulatingly providing pointless information regarding something I clearly didn't even ask.
Take care.
Back to top
View user's profile Send private message
noobes
Advanced Cheater
Reputation: 0

Joined: 17 Dec 2018
Posts: 89

PostPosted: Tue Jan 05, 2021 4:37 am    Post subject: Reply with quote

clerythecleric wrote:
"B4 making a thread please search it on google, you may find it!"

Try understanding the question before replying. What you answered didn't answer it in the slightest, Furthermore the answer your provided was already in the original thread. All you had to do was open your eyes to see your post helps nobody.

"Whatever, I think you're talking about that as you said you need the process to match so it gets auto attached"

At no point in my point did I say 'I need the process to match'. You're an idiot.

I've already resolved my issue anyway I just don't appreciate children incorrectly dictating rules to me while stimulatingly providing pointless information regarding something I clearly didn't even ask.
Take care.


First things first, your code already said something about title.exe, "Can this be adjusted to attach to the current 'active' window if process = title.exe (or if active window title = title.exe then attachProcess())" you said if that matches to do what the fuck you need, also next time just try to do the things yourself if you don't like help from a forum.
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