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 


get mouse posistion x and y in a panel [ help ]

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

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Thu Feb 22, 2018 12:26 am    Post subject: get mouse posistion x and y in a panel [ help ] Reply with quote

how to get mouse position or set position x and y
but in panel not in whole screen

thx for reply
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Feb 22, 2018 12:45 am    Post subject: Reply with quote

use control.screenToClient/clientToScreen to concert x,y coordinates between the two
_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Feb 22, 2018 2:22 am    Post subject: Re: get mouse posistion x and y in a panel [ help ] This post has 1 review(s) Reply with quote

Lynxz Gaming wrote:
how to get mouse position or set position x and y
but in panel not in whole screen


Example : <copy and paste script below to CE Table and execute>

Code:
f = createForm()
f.width, f.height = 300,250
pnl = createPanel(f)
pnl.left,pnl.top = 10,10
pnl.width,pnl.height = 280,180
pnl.Caption = 'Panel for mouse pos action'

lblX = createLabel(f)
lblX.left, lblX.top = 10, pnl.top+pnl.height + 20
lblX.font.size = 14

lblY = createLabel(f)
lblY.left, lblY.top = lblX.left + lblX.width + 150, pnl.top+pnl.height + 20
lblY.font.size = 14

function pnlOnEnter()
 z=createTimer(nil)
 z.Interval=100
 z.OnTimer=function(z)
 local x,y = getMousePos()
 x,y = pnl.ScreenToClient(x,y)
 lblX.caption = 'X.pos : '..tostring(x)
 lblY.caption = 'Y.pos : '..tostring(y)
 return x > 0 and x < pnl.width and y > 0 and y < pnl.height
 end
  z.Enabled=true
 end

function pnlOnLeave()
 z.destroy()
 x,y = 0,0
 lblX.caption = 'X.pos : '..tostring(x)
 lblY.caption = 'Y.pos : '..tostring(y)
end

pnl.onMouseEnter = pnlOnEnter
pnl.onMouseLeave = pnlOnLeave

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Thu Feb 22, 2018 4:45 am    Post subject: This post has 1 review(s) Reply with quote

thank you again corroder and db!
it works
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
MateeJr GT
Advanced Cheater
Reputation: 0

Joined: 24 Dec 2017
Posts: 66

PostPosted: Thu Feb 22, 2018 5:35 am    Post subject: Reply with quote

Lol lynxz ini aku
_________________
Hi Lynxz Gaming
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Thu Sep 03, 2020 1:02 pm    Post subject: Re: get mouse posistion x and y in a panel [ help ] Reply with quote

2years Cool!!
anyways
Corroder wrote:

return x > 0 and x < pnl.width and y > 0 and y < pnl.height

what is this line performing??

_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Sep 03, 2020 2:33 pm    Post subject: Re: get mouse posistion x and y in a panel [ help ] Reply with quote

FIRELESS_BOUNTY wrote:
2years Cool!!
anyways
Corroder wrote:

return x > 0 and x < pnl.width and y > 0 and y < pnl.height

what is this line performing??


Thats mean "set the x value must be greater than 0 and less than panel width and set the y value must be grater than 0 and less than panel height"

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Fri Sep 04, 2020 2:28 am    Post subject: Reply with quote

oh ok, but I don't think it helps in this code, since it returns to pnlonenter, and you can hold left mouse down when your on panel and drag it.
anyways, thx for help!! Cool

_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Sep 04, 2020 9:31 am    Post subject: Reply with quote

If you fully understand the 'return'' statement, then you will know, how that return command on that function is needed.

"A return statement returns occasional results from a function or simply finishes a function. There is an implicit return at the end of any function.

So you do not need to use one if your function ends naturally, without returning any value.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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