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 


Equivalent for OnClickRelease?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri Feb 04, 2022 11:03 am    Post subject: Equivalent for OnClickRelease? Reply with quote

Is there some equivalent for OnClickRelease=?

For example, I need to be able to do this:

Code:
OnClick=DoSomething
OnClickRelease=Close


If I add OnClick=Close, then the OnClick=DoSomething does not happen because the window closes.

Looking through celua.txt, I cannot find any solution for this. I have also searched the web and have tried many different things without success.

Thanks.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1065
Location: 0x90

PostPosted: Fri Feb 04, 2022 11:29 am    Post subject: Reply with quote

It's a little janky but you can achieve that with a custom function:
Code:

function OnClickRelease()
  // 0x01 = Left Mouse Button
 if not isKeyPressed(0x01) then
    print('released')
 end
end


In the onClick event just call this function at the end.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 465

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

PostPosted: Fri Feb 04, 2022 11:49 am    Post subject: This post has 1 review(s) Reply with quote

OnMouseDown=dosomething
OnMouseUp=Close

_________________
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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1065
Location: 0x90

PostPosted: Fri Feb 04, 2022 11:56 am    Post subject: Reply with quote

Dark Byte wrote:
OnMouseDown=dosomething
OnMouseUp=Close


That will only work if there are controls involved, correct?
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri Feb 04, 2022 12:07 pm    Post subject: Reply with quote

Thank you, guys. I really appreciate the help.

Sorry, DB, I did not want to keep bothering you with this. I am just trying to alter the script that you gave me earlier. While I have a few things sorted, I could not figure this one out.

Code:
--handy helper function
function forEachAndFutureForm(classname, func)
  local i
  for i=0,getFormCount()-1 do
    local f
    f=getForm(i)
    if f.ClassName==classname then
      func(f)
    end
  end

  registerFormAddNotification(function(f)
    if classname==f.ClassName then
      f.registerFirstShowCallback(function()
        func(f)
      end)
    end
  end)
end


forEachAndFutureForm('TfrmAutoInject',function(f)
  b=createButton(f)
  b.Caption='Add to Table'
  b.OnClick=f.Assigntocurrentcheattable1.OnClick
  b.parent=f.Panel3
  b.SetHeight(30)
  b.SetWidth(130)
  b.AutoSize=false
  b.AnchorSideLeft.Control=f.btnExecute
  b.AnchorSideLeft.Side=asrRight

  b.AnchorSideTop.Control=f.btnExecute
  b.AnchorSideTop.Side=asrTop

  end)


I tried both suggestions, but could not get them to work. I am too stupid to implement LeFiXER's code, and the MouseUp solution probably does not work in this case without changing more.

Thanks.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1065
Location: 0x90

PostPosted: Fri Feb 04, 2022 12:22 pm    Post subject: This post has 1 review(s) Reply with quote

++METHOS wrote:

...

I tried both suggestions, but could not get them to work. I am too stupid to implement LeFiXER's code, and the MouseUp solution probably does not work in this case without changing more.

Thanks.


No need to apologise. Just trying to help where I can. Providing the code gives a little more context for me so thank you, with this you can actually do it like DB mentioned:
Code:

--handy helper function
function forEachAndFutureForm(classname, func)
  local i
  for i=0,getFormCount()-1 do
    local f
    f=getForm(i)
    if f.ClassName==classname then
      func(f)
    end
  end

  registerFormAddNotification(function(f)
    if classname==f.ClassName then
      f.registerFirstShowCallback(function()
        func(f)
      end)
    end
  end)
end


forEachAndFutureForm('TfrmAutoInject',function(f)
  b=createButton(f)
  b.Caption='Add to Table'
--b.OnClick=f.Assigntocurrentcheattable1.OnClick
--
  b.OnMouseDown=f.Assigntocurrentcheattable1.OnClick
  b.OnMouseUp=myfunction() -- whatever function you want to execute on mouseup
--
  b.parent=f.Panel3
  b.SetHeight(30)
  b.SetWidth(130)
  b.AutoSize=false
  b.AnchorSideLeft.Control=f.btnExecute
  b.AnchorSideLeft.Side=asrRight

  b.AnchorSideTop.Control=f.btnExecute
  b.AnchorSideTop.Side=asrTop

  end)


As for which events you can use for the button control, you have:
    OnChange
    OnClick
    OnEnter
    OnExit
    OnMouseDown
    OnMouseUp
    OnMouseLeave
    OnMouseMove
    OnMouseUp
    OnMouseWheel
    OnMouseWheelDown
    OnMouseWheelUp
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri Feb 04, 2022 12:41 pm    Post subject: This post has 1 review(s) Reply with quote

Thank you very much.

Sorry that it took so long to reply, but I could not get the OnMouseDown to work as intended, no matter what I tried.

This works, though:

Code:
--handy helper function
function forEachAndFutureForm(classname, func)
  local i
  for i=0,getFormCount()-1 do
    local f
    f=getForm(i)
    if f.ClassName==classname then
      func(f)
    end
  end

  registerFormAddNotification(function(f)
    if classname==f.ClassName then
      f.registerFirstShowCallback(function()
        func(f)
      end)
    end
  end)
end


forEachAndFutureForm('TfrmAutoInject',function(f)
  b=createButton(f)
  b.Caption='Add to Table'
  b.OnClick=f.Assigntocurrentcheattable1.OnClick
  b.OnMouseUp=f.Close
  b.parent=f.Panel3
  b.SetHeight(30)
  b.SetWidth(130)
  b.AutoSize=false
  b.AnchorSideLeft.Control=f.btnExecute
  b.AnchorSideLeft.Side=asrRight

  b.AnchorSideTop.Control=f.btnExecute
  b.AnchorSideTop.Side=asrTop

  end)


Thanks, again.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1432

PostPosted: Fri Feb 04, 2022 1:05 pm    Post subject: This post has 1 review(s) Reply with quote

++METHOS wrote:

but I could not get the OnMouseDown to work as intended, no matter what I tried.


I guess "OnMouseDown" runs before "OnClick" and prevents "OnClick" from reaching function pressure.
My recommendation; Use "OnMouseWheel".

Like:

Code:
  b.OnMouseWheelUp=function() print("hello") end
  b.OnMouseWheelDown=function() print("CE") end



EDIT:

If the mouse wheel moves more than once, the function it triggers will be continuous.
I added "Permission" to avoid this.

Code:
  b.OnMouseLeave=function() permission=1 end
  b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
  b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end


and
Code:
local permission=1
forEachAndFutureForm('TfrmAutoInject',function(f)
  b=createButton(f)
  b.Caption='Add to Table'
  b.OnClick=f.Assigntocurrentcheattable1.OnClick
  b.OnMouseUp=f.Close
  b.parent=f.Panel3
  b.SetHeight(30)
  b.SetWidth(130)
  b.AutoSize=false
  b.OnMouseLeave=function() permission=1 end
  b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
  b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end
  b.AnchorSideLeft.Control=f.btnExecute
  b.AnchorSideLeft.Side=asrRight

  b.AnchorSideTop.Control=f.btnExecute
  b.AnchorSideTop.Side=asrTop

  end)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1065
Location: 0x90

PostPosted: Fri Feb 04, 2022 1:39 pm    Post subject: Reply with quote

AylinCE wrote:

I guess "OnMouseDown" runs before "OnClick" and prevents "OnClick" from reaching function pressure.
My recommendation; Use "OnMouseWheel".

Like:

Code:
  b.OnMouseWheelUp=function() print("hello") end
  b.OnMouseWheelDown=function() print("CE") end



EDIT:

If the mouse wheel moves more than once, the function it triggers will be continuous.
I added "Permission" to avoid this.

Code:
  b.OnMouseLeave=function() permission=1 end
  b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
  b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end


and
Code:
local permission=1
forEachAndFutureForm('TfrmAutoInject',function(f)
  b=createButton(f)
  b.Caption='Add to Table'
  b.OnClick=f.Assigntocurrentcheattable1.OnClick
  b.OnMouseUp=f.Close
  b.parent=f.Panel3
  b.SetHeight(30)
  b.SetWidth(130)
  b.AutoSize=false
  b.OnMouseLeave=function() permission=1 end
  b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
  b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end
  b.AnchorSideLeft.Control=f.btnExecute
  b.AnchorSideLeft.Side=asrRight

  b.AnchorSideTop.Control=f.btnExecute
  b.AnchorSideTop.Side=asrTop

  end)



With all due respect, not only does ++METHOS have a working solution, you are misconstruing MouseDown i.e. the event triggered when state of the mouse button is in the down position, for the MouseWheel.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1432

PostPosted: Fri Feb 04, 2022 2:01 pm    Post subject: Reply with quote

It is not my intention to undermine the solution.

++METHOS wrote:

but I could not get the OnMouseDown to work as intended, no matter what I tried.


It was just to offer different idea to the comment above.

Solutions are a separate case, ideas are rich in use and archival value.

respects.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1065
Location: 0x90

PostPosted: Fri Feb 04, 2022 2:10 pm    Post subject: Reply with quote

AylinCE wrote:
It is not my intention to undermine the solution.

++METHOS wrote:

but I could not get the OnMouseDown to work as intended, no matter what I tried.


It was just to offer different idea to the comment above.

Solutions are a separate case, ideas are rich in use and archival value.

respects.


Of course, I agree it's best to have multiple solutions to the same problem. No hard feelings from the comments Smile.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri Feb 04, 2022 2:18 pm    Post subject: This post has 1 review(s) Reply with quote

AylinCE wrote:
My recommendation; Use "OnMouseWheel".
-Thank you for your help and for your suggestion. It is always good to share ideas. Even if I do not use this method now, it could prove useful to someone that reads this later.
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