Screen coordinates

61 views
Skip to first unread message

mikkelstuff

unread,
Jan 13, 2023, 9:26:12 PMJan 13
to
I need to capture the screen coordinates when touching a left mouse button. Seems like "canvas" should do this but I just do not see it. Any other ideas?

Rich

unread,
Jan 13, 2023, 10:26:39 PMJan 13
to
Do the %X and %Y substitutions for bindings not provide what you are
looking for?

Or 'winfo pointerxy'?

Luc

unread,
Jan 14, 2023, 12:31:25 PMJan 14
to
bind $canvaswidget <ButtonRelease-1> {$textwidget delete 1.0 end; $textwidget insert end [%W canvasx %x]/[%W canvasy %y]}

or

bind $canvaswidget <ButtonRelease-1> {puts [%W canvasx %x]/[%W canvasy %y]}


--
Luc
>>


mikkelstuff

unread,
Jan 14, 2023, 3:22:30 PMJan 14
to
Got it! Sorry but I have not programmed in Tcl/Tk since retirement and am rusty. Ok, rusty geezer.
Thanks all

Luc

unread,
Jan 14, 2023, 3:56:39 PMJan 14
to
Please note those are not the coordinates of the screen. They are
the coordinates of the canvas, and the canvas has its own idea of what
x and y mean. I believe a canvas puts 0,0 on the bottom right corner
by default, such that everything you can see sits on negative (less
than zero) coordinates. I'm not really sure though. Anyway, you will
probably have to adjust the position of the canvas yourself before
you use it.

For example:

set ::canvaswidget $::w.outer.canvasframe.canvaswidget
canvas $::canvaswidget
$::canvaswidget configure -bg white
$::canvaswidget configure -height 900 -width 1900
$::canvaswidget configure -xscrollincrement 1
$::canvaswidget configure -yscrollincrement 1
$::canvaswidget configure -scrollregion [list 0 -900 19200 0]
$::canvaswidget xview moveto 0.0
$::canvaswidget yview moveto 0.45

Those values are pretty random here since I don't know what you
want or need. Your case will certainly require different values.


--
Luc
>>

Francois Vogel

unread,
Jan 15, 2023, 9:02:23 AMJan 15
to
Le 14/01/2023 à 03:26, mikkelstuff a écrit :
> I need to capture the screen coordinates when touching a left mouse button.

Depending on the coordinates system in which you want to obtain the
values, I suggest reading the manual for [winfo pointerxy] and/or [winfo
rootx/rooty].

Regards,
Francois

Harald Oehlmann

unread,
Jan 16, 2023, 7:11:53 AMJan 16
to
Background:
In medical applications (medical device/pharmaceutics), often a user
verification is required, even if the same user is already logged in.
This is to check, if the user is really in front of the screen and
approves the current process.

Request:
In consequence, I would like on a WIndows system to:
- present a Tk screen: Username/Password
- then verify the entered username/password against the system the
computer is in. This may be a local user or a user in the active directory.

TWAPI looks to be helpful here.
get_users -level 1
returns the -password field, what is always empty for me.

Are there any other ideas to find a solution ?

Thank you all,
Harald

Ralf Fassel

unread,
Jan 16, 2023, 8:50:20 AMJan 16
to
* Harald Oehlmann <wort...@yahoo.com>
| Request:
| In consequence, I would like on a WIndows system to:
| - present a Tk screen: Username/Password
| - then verify the entered username/password against the system the
| computer is in. This may be a local user or a user in the active
| directory.
>
| TWAPI looks to be helpful here.

Check [open_user_token] in TWAPI:

https://twapi.magicsplat.com/v4.7/security.html#open_user_token

It seems to be the wrapper around LogonUser(), which from what I read is
*the* method to verify user/passwd.

HTH
R'

Harald Oehlmann

unread,
Jan 16, 2023, 10:38:56 AMJan 16
to
Wow, great, works great !

Thanks,
Harald

Reply all
Reply to author
Forward
0 new messages