Panel vs Cursor Coordinate​s

I'm having a problem understanding the relationship between cursor
position and front panel object positioning. I'm using the "get cursor
position" vi to give me the coordinates on a 1024x768 monitor. But,
when I plug those numbers into the "position attribute" for an
indicator, it isn't even close to being in the right location. Why?
What's the secret code? Is there a known grid for all front panels
(1024x1024) ? And somehow I need to translate from my graphics card
resolution?
Thanks,
Bill

Bill,
The cursor position you got is in screen coordinates
(top-left cornor of your screen is 0,0, bottom-right
corner is 1024,768). You have to convert it to client
coordinate (top-left corner of the client area of your
front panel is 0,0). And then convert to LabVIEW
coordinate, a vertical shift of the toolbar height.
And then you can use it for position attribute.
If you're using LabVIEW5.1, you can download the
screen to client convert following this link:
http://gtoolbox.yeah.net
George
George Zou
http://webspace.webring.com/people/og/gtoolbox

Similar Messages

  • Trapping cursor coordinates in Javascript

    Hello Everyone:
       I am attempting to trap cursor coordinates but I do not know how to make that happen.  Here is the short algorithm I hope to implement:
    click object to select.
    click new location for object to move to
    move object to new location.
    I think I know how to do the first, but I have no idea how to make Javascript report the coordinates of the mouse cursor when I click on the new location.
    Please share with me any thoughts/documentation/snippets that might help.  I will greatly appreciate it.
    TIA.
    John

    @John – if you are using InDesign CS5 (or above) I have something for you.
    At least a proof of concept that will work. Tested with InDesign CS5.5.
    The script will not read out any cursor coordinates.
    Unfortunately we cannot do this…
    Instead I am using:
    one event listener,
    an JPEG image already placed,
    the placeGun
    and the "afterSelectionChanged" event.
    To test the script below, you need:
    1.A The ESTK open, run the script from that
    OR:
    1.B Run the script with a keyboard shortcut from InDesign's Scripts Panel
    2. An open document
    3. An already placed JPEG image in the document (with a link status OK)
    4. One single page item selected (no text selected, not more than one object selected)
    This is just a proof of concept!
    I did not consider moving a selection greater than one object, I needed at least ONE image placed in the document, I did not consider double sided spreads with a coordiante system set by page.
    And: I really had fun writing this!
    Here the script (ExtendScript/JavaScript):
    //MoveSelectionTo_POSITION-OF-CURSOR_ProofOfConcept.jsx
    //Uwe Laubender
    //DESCRIPTION:Just a proof of concept. Some pieces missing!
    #targetengine "MovePositionToCursor[Proof Of Concept ONLY]"
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    //SOME CHECKS:
    if(parseFloat(app.version)<7){alert("Does not run in InDesign v. "+app.version);exit()};
    if(app.documents.length == 0){alert("No document open!");exit()};
    if(app.selection.length !== 1 && !app.selection[0].hasOwnProperty("baselineShift")){
        alert("This is a proof of concept! Does ONLY work with ONE page item selected. NOT TEXT!");
        exit();
    if(app.documents[0].allGraphics.length == 0){
        alert("This is a proof of concept! Does ONLY work with AT LEAST ONE JPEG ALREADY placed!");
        exit();
    moveSelection();
    function moveSelection(){
    var myDoc = app.documents[0];
    var myOriginalSel = app.selection[0];
    var myOriginalSelID = myOriginalSel.id;
    for(var n=0;n<myDoc.links.length;n++){
        if(myDoc.links[n].status == LinkStatus.NORMAL && myDoc.links[n].linkType == "JPEG"){
            var myImage = File(myDoc.links[n].filePath);
            break;
    if(myImage){myDoc.placeGuns.loadPlaceGun(myImage)}
    else{
        alert("This is a proof of concept! Does ONLY work with AT LEAST ONE JPEG ALREADY placed!");
        exit();
    app.addEventListener("afterSelectionChanged", doSomething);
    app.select(app.documents[0].pageItems.itemByID(myOriginalSelID));
    function doSomething(myEvent){
        try{
        app.removeEventListener("afterSelectionChanged", doSomething);
        var myNewID = app.selection[0].id;
        var myGeoBounds = app.selection[0].getElements()[0].geometricBounds;
        app.documents[0].pageItems.itemByID(myNewID).remove();
        app.documents[0].pageItems.itemByID(myOriginalSelID).move([myGeoBounds[1],myGeoBounds[0]]);
        app.select(app.documents[0].pageItems.itemByID(myOriginalSelID));
        }catch(e){};
    Uwe

  • Mouse cursor coordinates

    Is it possible to get mouse cursor coordinates when it is not on a Component?

    Whit SwingUtilities.convertPointToScreen(point, component), but you will still need to add a mouse listeners.

  • How can I create a box in the toolbar to dispaly cursor coordinates

    I would like to create a box in the acrobat toolbar to display cursor position coordinates relative to a user specified origin. How can this box be created and added to the toolbar? I'm just getting started with writing acrobat plugins.

    OK...
    You can create a floating palette using the ADM APIs that are documented in the SDK, and for which there are samples.
    Or use your OS platform APIs for doing windows...
    Leonard

  • How can I change the numeric format of the cursor coordinates display in LV 8.2

    Since LV 8.0 or so the cursor display window of a graph indicator seems to be a tree control. I couldn't find where to change the numeric format of the numbers displayed in that control. What did I miss?

    lecroy wrote:
    Maybe I'm not clear on what your looking for but I just use a property node and route the raw cursor data out to what ever function I want to run on it, then display it in a seperate field.  The nice thing with the property node is you can have multiple graphs linked together by one set of cursors all with different readouts. 
    Yes, of course that's an option and I guess I'll have to do it that way.
    The point is that I converted a pre-LV-8.x program to LV 8.5. In the program I had used the coordinates display field in the cursor legend to display the position, just the was the cursor legend is supposed to be used, IMO. And in pre-LV-8.x days it was possible to customize the numeric format property of the cursor legend (either directly or by property nodes). It seems that with LV 8.x NI chose to use a treeview control for the cursor legend. With that 'improvement' the numeric formatting flexibility was lost since now the conversion to the string content in the cursor legend's treeview is happening somewhere 'under the hood'.
    <rant> Why do they (NI) always try to 'improve' things (where nothing needs be improved) and sacrifice functionality on the way....? </rant>

  • How can I extract cursor coordinate in Adobe Photoshop for use in Action script?

    What I want to do in Photoshop (version CC, but I think this applies to any version) is label a point using count tool under my mouse's current position, and label it multiple times (for different labels). I have an action that essentially does this:
    (1) Add to count (under one label) (2) Switch to second label (3) Add to count (under second label) (4) Switch to third label (5) Add to count (under third label)
    And the problem is that I need to be able to have a variable in the action script that uses the cursor's current position (X and Y numbers) on the canvas to set these three points when the macro is activated. Currently I am only able to record the script using constant X, Y values (the same point is labeled over and over when I play the recorded action). I am able to extract the code for the action for editing (via xbytor2's suggestion in this forum:https://forums.adobe.com/thread/696989) and I see where the variable can go, I just don't know what exactly to put in place of the constant X, Y values that will let Photoshop input the mouse's current coordinates...
    Any ideas? Much appreciated!!

    You could use the pen tool set to path and create a single dot, then run the script to get the cursor positions and use that in your script.
    var strtRulerUnits = app.preferences.rulerUnits;
    var strtTypeUnits = app.preferences.typeUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    app.preferences.typeUnits = TypeUnits.PIXELS;
    var doc = activeDocument;
    var workPath = doc.pathItems.getByName("Work Path");
    var pos = workPath.subPathItems[0].pathPoints[0].leftDirection;
    $.writeln("x = " + pos[0] + " y = " + pos[1]);
    doc.pathItems.getByName("Work Path").remove();
    app.preferences.rulerUnits = strtRulerUnits;
    app.preferences.typeUnits = strtTypeUnits;

  • Cursor Coordinate​s & Rectangle Coordinate​s not matching

    hello!
    I am actually drawing a drawing a rectangle over xy graph using mouse clicking events and I need coordinates exactly the way it is extracted by cursor.The indicator ''coord2'' & ''cursor 0'' should give me same results.I need output of coord 2 to be like cursor 0.Hope i managed to convey my point.May be i have to manipulate with scale.Check the attachment.
    Solved!
    Go to Solution.
    Attachments:
    Untitled.png ‏139 KB
    Draw Rect on graph.vi ‏39 KB

    Sets,
    I attached a VI that will turn your mouse up and down coordinates that are by default in pixels to x-y coordinates.  I also noticed that you were only able to make a rectangle when you started in the upper left and ended in the bottom right so I added some logic so you can start and end anywhere and have the rectangle be drawn.
    I also noticed that when drawing the rectangle the corners were drawn slightly below and to the left of the cursor, is this the issue you were actually trying to fix?  I just looked into that a little bit but couldn't figure out why that was happening.
    Matt J
    Professional Googler and Kudo Addict
    National Instruments
    Attachments:
    Draw Rect on graph.vi ‏27 KB

  • Screen Resolution & Mouse Cursor Coordinate

    Hi,
    I would like to ask how to do the following with a java program:
    1. get the screen's resolution
    2. get the coordinate of the mouse cursor on the screen
    Thanks you very much.

    If you can use Java 1.5, the classjava.awt.MouseInfo might be what you need
    Thanks, it really works!
    Glad I could help.
    However, now i find that the method
    getScreenResolution() in class Toolkit is an abstract
    method. I would like to know how to implement this?
    You don't need to. There is a concrete implementation tailor-made for your particular platform ready waiting for you. You get it by calling the static method getDefaultToolkit:
    Toolkit tk = Toolkit.getDefaultToolkit();
    int dotsPerInch = tk.getScreenResolution();

  • Panel Object xy coordinates and Multiple window list in task bar

    Two questions...
    I recently had to rearange panel objects to programatically display them. They were not at the origin, and had to futz them into
    position.
    Is the first object placed, placed at the origin?
    Could the guys at NI provide an xy indicator?
    And second,
    I built my application, but in the task bar there is a listing for the app, then another listing for the window name. How can I
    clean this up?
    XP
    LV 6.1
    Cheers

    Martin,
    As far as question 1:
    There are 2 different �origins� when speaking about the front panel. There is the 0,0 position that is global to all controls and indicators on it. This origin is a location that does not change. In LabVIEW 7.0 if you have the grids turned on you can see this location as a slightly darker line on the grid and a gray dot. You can reference a controls relative position to this origin by using the "Position" Properties.
    There is then the �Origin� property of a front panel. This origin refers to what part of the front panel is viewable. The �Origin� in this sense is what location, referenced to the first position, is at the top left corner of the front panel screen.
    Take a look at the attached screen shot.
    So if you a
    re programmatically moving objects around you need to be aware of both. If you move the scrollbars of the front panel, the �origin� changes. However the positions of all the objects do not.
    If you have any questions about this description let me know. The difference between the 2 origins is subtle.
    Evan
    National Instruments
    Attachments:
    temp.jpg ‏56 KB

  • How do I convert the single x and y coordinates returned by a CWGraph Click event to the Cursor X and Y Positions?

    I am trying a work around for another problem.
    cwCSnapNearestPoint does not give me a CursorDown event (TrackMode = cwGTrackDragCursor). I need to know when the user has clicked on a Cursor. I need to figure out when the user has clicked on a cursor.
    The click event gives you coordinates as "Single" which are an OLE_XPOS_PIXELS. How do I convert to the Cursor coordinates (or vis a vis)?
    Or better yet is there another way to figure that a cursor has been clicked on (while using cwCSnapNearestPoint and TrackMode = cwGTrackDragCursor )

    Here are a couple potential fixes for the problem. If you are dealing with cursors on the graph, I would look into CursorChangeEvent, CursorMouseDown, CursorMouseUp, and CursorMouseMove. The ChangeEvent is triggered upon repositioning of the cursor. MouseDown triggers on the depression of a mouse button on a cursor, while MouseUp triggers on the button's release. MouseMove is triggered when the mouse is moved over a cursor. These each give X and Y positions in the arguments. If you used these and then made a Sanp to nearest point, you should have the coordinates before you sanpped to the point.

  • How to strore mouse coordinates in array

    Hi,
    I am using LaptopTouchpad to get cursor coordinates. I need to track all the coordinates while the cursor moving. But i am getting only present coordinates. i thought that to track coordinates, i need to store in an array. while doing that i am getting only present coordinates in all the index position of array.

    Post your VI so we can see how you are doing it now.

  • How to modify the cursor palette size in a waveform graph programmaticaly in LabVIEW8

    In previous version of LabVIEW it vas possible to create reference to cursor panel (array) so it was possible to resize, change number of rows, in it. It will be useful for me to have reference to TreeControl contained in cursor legend. How to create this reference? The method described in the manual works for scale legend but not work for cursors panel.

    Thank you JLS once again.
    In my opinion the cursor palette at list should have the following functionality:
    Automatic resizing of the panel while adding and removing cursors programmatically (like plot legend)
    Positioning the panel programmatically (like plot legend)
    Hiding any columns and rows. For example when I hide one of the cursors (let say the second one, not necessary the last one) also this one should disappear from cursors panel, removing cursor from cursor list might be inconvenient. If I have one cursor and not enough room to show cursor panel I can not hide the cursor name column that is unusable but occupies place on the panel
    Altering number of column and rows programmatically. If my cursors serve for selecting part of the signal to be processed (for example trimming signal) it is sense less to show cursors Y position
    Hiding cursor navigator, it works very badly (try to move cursor only to the next measurement point to select exactly for example 10000 points), so I move it under other controls.
    Formatting data displayed
    Having additional elements (coming from underlying tree control) is not necessary in several cases. Life will be much more pleasant if it will be possible to get reference to this tree control.
    By the way it is possible to customize this palette. In design mode configure WaveformGraf to show cursor legend. Select it and then select from menu “Customize control…” Now you can do whatever you (I) want, for example change the column name from X to Time. Save your work, if prompted replace original with just designed and… nothing changes – funny isn’t it?
    Best regards,
    Zygmunt

  • XY graph cursor position bug

    I have reproduced the bug mentioned here:
    http://forums.lavag.org/Graph-Cursor-XY-Position-Bug-t1366.html&gopid=40859#entry40859
    I've reproduced this bug (?) in Labview 8.5, with an XY graph doing
    much the same as Jack. The attached zip file contains a stripped down
    version of my program (originally written by my coworker, Andrew
    MacDonald). Run "RENA3 Data Viewer.vi" and follow the instructions.
    As Jack said, changing Cursor.PosX to Cursor.Index solves the problem.
    I did not find this bug mentioned anywhere other than the above link.
    Fraser
    Attachments:
    XY Graph Cursor Bug.zip ‏142 KB

    Hi Karla,
    Sorry if that wasn't as obvious as I thought! :-)  Hopefully the attached image makes it clear.  On the front panel, 'Cursor Channel' is inputted.  This is directly wired to Histogram.Cursor.PosX.  Immediately following, Histogram.Cursor.PosX is read and wired to the front panel indicator 'Cursor.Cursor Position:Cursor X'.  There is always a difference of 15 or 16 between the two values.  If there was no bug, these two values should be identical!  I can only conclude that Labview is doing something funny...
    As I mentioned before, changing Cursor.PosX to Cursor.Index fixes the problem.
    A bit of background:  my FWHM function outputs the peak channel, and the cursor is supposed to go through the peak so you can have a visual check that it is analyzing the right peak.  I noticed that the line would never go through the peak; the line would always have an offset.  After wasting a couple of hours, it became clear that I was wiring the correct value into 'Cursor.PosX', but something was going wrong beyond that.
    Cheers,
    Fraser
    Message Edited by fjharris on 01-25-2008 11:34 AM
    Message Edited by fjharris on 01-25-2008 11:36 AM
    Attachments:
    Labview Bug.png ‏27 KB

  • How do I obtain the coordinates from an active X IMAQ container from use in another part of a vi?

    Is their a simple way to read the screen coordinates from the IMAQ Active X container produced by the example NI code IMAQ_vi.llb so I can use them in another part of a program?
    Many thanks
    Nick

    What is confusing me is the ActiveX reference. Are you using a non-standard display, or are you assuming it is ActiveX? The standard display (WindDraw) is not ActiveX as far as I know.
    To get a cursor coordinate within the WindDraw window, use IMAQ WindLastEvent. You can input that you are looking for mouse clicks. The output will tell you where the last mouse click was.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Sketch erased in AWT panel

    hai
    I have a very strange problem:
    I am presently working on drawiing a sketches on a panel using a PC tablet...
    the scenario is like this:- I have created a Frame and in that I have created a Panel , the screen coordinates of which are scynchronized to those of the PC tablet. At the bottom of the panel there is an OK button.
    Now as soon as I draw something on the tablet, I display it on the Panel.
    Now when I have completed drawing and when I press ok, I get a dialog box to display a message.
    what is the problem now is I see the dialog box, the sketch in the background i.e. on the Panel is erased.
    Can any one tell me what can be the problem with my interface......It will be extremely useful for me......thank you
    best wishes

    You're probably doing the painting in your MouseEventListeren?
    If so you have two ways to go, the easier one, and the one I would use, cause it's more "clean".
    The easier one is to use double-buffering (read about it on the http://java.sun.com) and do the painting in your EventListeren but do it on the offscreen-buffer, and just call repaint().
    The more difficult one is to build a model that holds all the data about the picture, that allows to reproduce it. In your case it would be probably just line coordinates plus colors. And in the EventListeren instead of doing all the painting, just add the new line to the model, and call repaint(). The actuall painting would be done in the paintComponent(Graphics g) method, where you should write a code that would paint your picture based on the data model.
    Hope it helps,
    Marcin

Maybe you are looking for