How to Find Pixel Coordinates on Your Screen
You need the exact X/Y position of a pixel and you need it now -- maybe for an automation script, maybe to align a UI element, maybe to file a bug report with precise repro steps. Whatever brought you here, this page covers every practical method: built-in OS tools, terminal one-liners, browser DevTools, and a live picker you can try without installing anything.
Use the Full Screen Coordinates ToolQuick Demo: Live Coordinate Picker
The box above this section is interactive. Move your mouse over it and you will see four values update in real time: X and Y measure from the top-left corner of your entire screen, while Relative X and Y measure from the top-left corner of the demo box itself. Click anywhere inside the box to lock a coordinate pair.
This distinction -- screen coordinates versus element-relative coordinates -- is the single most common source of confusion when people first start working with pixel positions. Screen coordinates tell you where something is on the monitor. Relative coordinates tell you where it is inside a particular window or element. Most APIs give you one or the other; some give you both, and they are rarely the same number.
Practical takeaway: If you are writing an automation script that needs to click a button, you almost always want screen coordinates. If you are building a web app, you usually want relative coordinates (what the browser calls offsetX/offsetY).
Windows: PowerShell, Snipping Tool & More
Windows does not ship with a visible coordinate readout. There is no built-in app that follows your cursor and prints X/Y numbers. You have three real options, and the best one depends on whether you need a quick one-off reading or a scriptable solution.
Option 1: PowerShell + Win32 API (Copy-Paste Ready)
This is the method I reach for most often. It taps into the same GetCursorPos function that every Windows application uses internally, so the coordinates you get are physical screen pixels -- not affected by display scaling. Paste this into a PowerShell window:
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class User32 {
[StructLayout(LayoutKind.Sequential)]
public struct POINT { public int X; public int Y; }
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out POINT lpPoint);
}
"@
while ($true) {
$p = New-Object User32+POINT
[User32]::GetCursorPos([ref]$p)
Write-Host "`rX: $($p.X) Y: $($p.Y)" -NoNewline
Start-Sleep -Milliseconds 100
}
Move your mouse around and watch the numbers change. Press Ctrl+C to stop. The coordinates update ten times per second, which is fast enough for most tasks without hammering your CPU.
DPI scaling caveat: On Windows 10 and 11 with scaling set above 100%, GetCursorPos returns physical pixel coordinates. If your script is clicking inside a web browser, the browser may report CSS pixels instead. This mismatch is the number-one cause of automation clicks landing in the wrong spot. See the DPI section for the fix.
Option 2: Snipping Tool (For Quick Readings)
The Snipping Tool does not directly show coordinates, but it has a useful side effect: when you start a snip, the crosshair displays its current pixel position in a small tooltip near the cursor. It is not precise enough for automation, but if you just need to eyeball where something is, it works in a pinch.
To open it quickly: press Win + Shift + S. The screen dims and a crosshair appears. Move it around and look for the pixel readout near the crosshair. Press Esc to cancel without taking a screenshot.
Option 3: Python with PyAutoGUI
If you are already writing automation in Python, pyautogui is the standard library for this. Install it with pip install pyautogui, then:
import pyautogui, time
while True:
x, y = pyautogui.position()
print(f"\rX: {x} Y: {y}", end="", flush=True)
time.sleep(0.1)
For a deeper dive into PyAutoGUI -- including click(), moveTo(), and handling multi-monitor setups -- see our PyAutoGUI screen coordinates guide.
macOS: Digital Color Meter & Terminal
macOS is better equipped than Windows for this task. You get a built-in utility that shows live coordinates, and the terminal options are surprisingly capable.
Built-In: Digital Color Meter
Open Spotlight (Cmd + Space) and type "Digital Color Meter." This app lives in Applications / Utilities and was designed for reading pixel colors, but it also displays the cursor's screen coordinates in real time at the bottom of its window. It is the fastest way to get coordinates on a Mac without writing any code.
Tip: Resize the Digital Color Meter window to be small and move it to a corner of your screen. That way it does not block the area you are trying to measure. The coordinate readout updates as long as the app is in the foreground -- you can move your mouse anywhere on screen and the numbers will track.
Terminal: Python + Quartz (Precise and Scriptable)
For automation, the Quartz framework gives you the exact same coordinate data that the OS uses internally. The tricky part: macOS measures Y from the bottom of the screen, not the top. Most other systems use top-left origin. If you are porting a script from Windows, you need to flip the Y value.
import Quartz, time
while True:
loc = Quartz.CGEventGetLocation(
Quartz.CGEventCreate(None))
h = Quartz.CGDisplayPixelsHigh(
Quartz.CGMainDisplayID())
# macOS Y is from bottom; flip to top-left origin
print(f"\rX: {int(loc.x)} Y: {int(h - loc.y)}",
end="", flush=True)
time.sleep(0.1)
Install Quartz first with pip install pyobjc-framework-Quartz. The flipped Y coordinate will match what a web browser or a Windows-style coordinate system would report.
Linux: xdotool & xwininfo
Linux has the best command-line tools for coordinate work, partly because X11 was designed to be scriptable from day one. Wayland is catching up but some of these tools may not work on pure Wayland sessions -- see the note below.
xdotool: One-Shot Coordinate Read
Install with sudo apt install xdotool (Debian/Ubuntu) or your distro's package manager. Then:
# Print current mouse position once
xdotool getmouselocation --shell
# Output looks like:
# X=1920
# Y=540
# SCREEN=0
# WINDOW=16777216
The --shell flag formats the output as shell variables, which means you can source it directly in a bash script:
eval "$(xdotool getmouselocation --shell)"
echo "Mouse is at $X, $Y on screen $SCREEN"
Live Tracking Loop
while true; do
eval "$(xdotool getmouselocation --shell)"
printf "\rX: %-5s Y: %-5s" "$X" "$Y"
sleep 0.1
done
xwininfo: Window-Specific Coordinates
If you need coordinates relative to a specific window rather than the screen, xwininfo is your friend. Run xwininfo in a terminal, then click the window you want to inspect. It prints the window's absolute position, size, and corners -- useful for calculating where a button sits relative to its parent window.
Wayland users: xdotool and xwininfo are X11 tools. On a Wayland session they may return zeros or fail silently. For Wayland, wlr-randr and slurp can help with screen geometry, but there is no universal equivalent to getmouselocation yet. If you rely on coordinate automation on Linux, consider using an X11 session or XWayland compatibility mode.
In the Browser: DevTools & JavaScript
If you are trying to find coordinates within a web page -- for clicking, drag-and-drop testing, or layout debugging -- you do not need any OS-level tools. The browser gives you everything through JavaScript, and DevTools lets you inspect coordinates interactively.
DevTools Console Snippet
Open DevTools (F12 or Cmd+Option+I), go to the Console tab, and paste this:
document.addEventListener('mousemove', e => {
console.clear();
console.log('Screen: ' + e.screenX + ', ' + e.screenY);
console.log('Client: ' + e.clientX + ', ' + e.clientY);
console.log('Page: ' + e.pageX + ', ' + e.pageY);
console.log('Offset: ' + e.offsetX + ', ' + e.offsetY);
});
Now move your mouse over the page and watch the console update. Each pair measures from a different origin, and understanding the difference is essential for web development:
| Property | Origin Point | Scroll-Aware? | Use Case |
|---|---|---|---|
screenX / screenY | Top-left of physical monitor | No | Multi-monitor detection, OS-level automation |
clientX / clientY | Top-left of browser viewport | No | Most common; drawing on canvas, positioning overlays |
pageX / pageY | Top-left of full document | Yes | Use when page is scrollable and you need document-absolute position |
offsetX / offsetY | Top-left of the element under cursor | Yes | Element-relative interaction (drag within a container) |
The key thing that trips people up: clientX/Y does not change when you scroll the page, but pageX/Y does. If you are storing a click position and the user scrolls before you replay it, you need pageX/Y, not clientX/Y.
DPI Scaling: Why Your Coordinates Are Wrong
If you have ever written a script that works perfectly on one computer but clicks a few pixels off on another, DPI scaling is almost certainly the culprit. This section exists because it is the most common question we get, and the answer is not obvious.
Modern displays often run at a scaling factor greater than 100%. A 4K laptop screen at 150% scaling reports fewer logical pixels than it has physical pixels: a 3840x2160 panel at 150% reports 2560x1440 to most applications. The problem is that different layers of the software stack may report coordinates in different units:
- OS-level APIs (like Win32
GetCursorPos) often return physical pixels - Web browsers report CSS pixels (logical pixels) via JavaScript
- Automation frameworks like PyAutoGUI try to match the OS, but browser-based tools may convert
The result: a mouse position reported as (1000, 500) by your OS-level script might correspond to roughly (667, 333) in CSS pixels inside a browser at 150% scaling. If your script reads from the OS but clicks into a browser, or vice versa, coordinates will not line up.
How to fix it: Check window.devicePixelRatio in the browser console. If it returns 1.5, multiply browser CSS coordinates by 1.5 to get physical pixels, or divide OS coordinates by 1.5 to get CSS pixels. On Windows, also check Settings / Display / Scale. Our DPI scaling guide walks through this in detail.
Multi-Monitor Setups & Negative Coordinates
On a multi-monitor system, the primary monitor's top-left corner is always (0, 0). Secondary monitors extend the coordinate plane in whatever direction you have arranged them in your display settings. If your second monitor is to the left of the primary, its coordinates are negative: a point at the top-left of the left monitor might be (-1920, 0).
This catches people off guard because most coordinate documentation talks about positive numbers. But negative coordinates are perfectly valid and are how every operating system handles multi-monitor layouts. If your script uses pyautogui.click(-500, 300), it will click on a monitor to the left of the primary display.
| Monitor Position | Coordinate Range | Example |
|---|---|---|
| Primary (center) | 0 to +width, 0 to +height | 0,0 to 1920,1080 |
| Left of primary | -width to -1 | -1920,0 to -1,1080 |
| Right of primary | +primary to +(primary+secondary) | 1920,0 to 3840,1080 |
| Above primary | -height to -1 (Y axis) | 0,-1080 to 1920,-1 |
One more wrinkle: monitors with different resolutions or scaling factors create "dead zones" -- areas where the cursor cannot reach because the monitors do not align at that row or column. This is normal, not a bug; it is how all three major operating systems handle mixed-resolution multi-monitor setups.
For the full breakdown, see our multi-monitor coordinates guide.
Method Comparison Table
| Method | Platform | Precision | Scriptable? | Best For |
|---|---|---|---|---|
| PowerShell + GetCursorPos | Windows | Exact (physical px) | Yes | Automation scripts, batch jobs |
| Snipping Tool crosshair | Windows | Approximate | No | Quick visual estimate |
| PyAutoGUI | All | Exact | Yes | Cross-platform automation |
| Digital Color Meter | macOS | Exact | No | Quick readings, color picking |
| Python + Quartz | macOS | Exact | Yes | Mac automation scripts |
| xdotool | Linux (X11) | Exact | Yes | Shell scripts, X11 automation |
| DevTools Console | Browser | Exact (CSS px) | Yes | Web development, layout debugging |
| Online picker (this page) | Browser | Exact | No | One-off readings without tools |
Frequently Asked Questions
Why are my coordinates different on two computers with the same screen size?
Almost always DPI scaling. Two 1920x1080 screens can report different coordinate values if one is set to 125% scaling and the other to 100%. Check window.devicePixelRatio in the browser or Settings / Display / Scale on Windows.
How do I get pixel coordinates on a touchscreen device?
Touch events provide touches[0].clientX and touches[0].clientY in the browser, which work the same way as mouse coordinates. The coordinate values are identical to what a mouse would report at the same screen position -- the input method changes, but the coordinate system does not.
Can I find pixel coordinates of a specific element instead of the cursor?
Yes. In the browser, use element.getBoundingClientRect(). For desktop apps, accessibility APIs (UIAutomation on Windows, Accessibility API on macOS, AT-SPI on Linux) can enumerate UI elements and their screen rectangles without needing pixel coordinates at all -- generally the more robust approach for automation.
What is the difference between logical and physical pixels?
Physical pixels are the actual dots on your display hardware. Logical pixels (also called CSS pixels in browsers) are an abstraction layer for high-DPI displays. At 100% scaling they are identical. At 200% scaling, one logical pixel maps to a 2x2 block of physical pixels. See our physical vs logical pixels guide for the full breakdown.
Is there a keyboard shortcut to show coordinates on Windows?
No built-in shortcut exists. The closest thing is the Snipping Tool crosshair (Win + Shift + S). For reliable keyboard-triggered coordinate display, assign a hotkey to the PowerShell script in the Windows section above using AutoHotkey.