• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Returning the Cursor Position within the Screen Area

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 11583
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Returning the Cursor Position within the Screen Area

kdolan
kdolan over 3 years ago

Hi,

I want to be able to return the x:y coordinates of the cursor with reference to the screen area. Is there a way to do this?

I found similar threads using the hiGetPoint() and hiGetCommandPoint() commands, but these only return the coordinates with reference to a window.

Instead, I would like the coordinates to be with reference to the screen size [   hiGetScreenSize( )   ].

I also came across the following command and maybe it has something to do with this?   hiGetScreenPoint()

I couldn't however get this command to work.

Thanks for the help,

Regards,

Keelan

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    Keelan,

    hiGetScreenPoint gets the screen (pixel) coordinates but only within the drawing area of the specified window.

    There's no function to get the absolute pixel coordinate on the screen. There have been a few requests for this in the past (mostly related to trying to position a form relative to the cursor, I think), but these enhancements have not been implemented (they haven't been planned).

    Why do you need this?

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kdolan
    kdolan over 3 years ago in reply to Andrew Beckett

    Hi Andrew,

    Ah I see. And the reason being is exactly as you say, trying to position a form relative to the cursor. 

    I understand you can change the default location of forms, but yes I was specifically looking to position forms relative to the cursor. 

    Do you know of any other strategy or workaround for such a issue? Or do I have to go back to the drawing board?

    Thanks,

    Keelan

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to kdolan

    Hi Keelan,

    How about this:

    hiGetCIWindow()->formRelativeTo="currentWindow"
    hiGetCIWindow()->formPlacement="center"

    The documentation covers the other values - but the formPlacement could be left/right/top/bottom too.

    Maybe that gives you the kind of flexibility you want? There's also a similar setting for optionFormRelativeTo and optionFormPlacement. They are set as attributes on the CIW window.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • kdolan
    kdolan over 3 years ago in reply to Andrew Beckett

    Hi Andrew,

    Thanks for the information. I've come across this before alright but it is not exactly what I was looking for. 

    I went and did a bit of further digging and found out I could get the mouse coordinates using Python and then utilising this information via Cadence.

    I've done up to following code that achieved this:

    The Cadence Script:

    procedure( getMouseCoordinates()
    prog(
    (
    pythonScript pythonScriptProcess pythonOutput tmp mouseXpos mouseYpos
    )
    pythonScript = "python ~kdolan/Python/getMouseCoordinates.py"
    pythonScriptProcess = ipcBeginProcess(pythonScript) ;execute my python script
    ipcWait(pythonScriptProcess) ;wait for scipt to complete
    pythonOutput = ipcReadProcess(pythonScriptProcess) ;store script output
    if(ipcIsAliveProcess(pythonScriptProcess) == t ;if child still exists
    then
    ipcCloseProcess(pythonScriptProcess) ;close child
    )
    if(rexMatchp("Errno" pythonOutput) || rexMatchp("SyntaxError" pythonOutput)
    then
    printf("\nERROR --> [getMouseCoordinates.il] A problem occured when executing the command: %L \n", pythonScript)
    return(nil)
    )
    rexCompile(" *")
    pythonOutput = rexReplace(pythonOutput " " 0)
    pythonOutput = parseString(pythonOutput "\n") ;format script output
    foreach(line pythonOutput ;step through each line of script output
    rexCompile(" *")
    line = rexReplace(line "" 0)

    if(rexMatchp("c_int" line) == t
    then
    tmp = parseString(line ")")
    mouseXpos = atoi(nth(1 parseString(nth(0 tmp) "("))) ;store mouse X position
    mouseYpos = atoi(nth(1 parseString(nth(1 tmp) "("))) ;store mouse Y position
    )
    )

    return(list(mouseXpos mouseYpos))
    ))

    The Python Script:

    import sys
    from ctypes import *
    Xlib = CDLL("libX11.so.6")
    display = Xlib.XOpenDisplay(None)
    if display == 0: sys.exit(2)
    w = Xlib.XRootWindow(display, c_int(0))
    (root_id, child_id) = (c_uint32(), c_uint32())
    (root_x, root_y, win_x, win_y) = (c_int(), c_int(), c_int(), c_int())
    mask = c_uint()
    ret = Xlib.XQueryPointer(display, c_uint32(w), byref(root_id), byref(child_id),
    byref(root_x), byref(root_y),
    byref(win_x), byref(win_y), byref(mask))
    if ret == 0: sys.exit(1)
    print child_id.value
    print root_x, root_y

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information