This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,3 @@
(mouse-pixel-position)
=>
(FRAME . (X . Y))

View file

@ -3,3 +3,4 @@ until *Pending() > 0 & Event() == "q" do { # loop until there is something to do
py := WAttrib("pointery")
# do whatever is needed
WDelay(5) # wait and share processor
}

View file

@ -0,0 +1,38 @@
// rust 0.9-pre
use std::libc::types::os::arch::extra::{BOOL, HANDLE};
use std::ptr::mut_null;
type LONG = i32;
type HWND = HANDLE;
#[deriving(Eq)]
struct POINT {
x: LONG,
y: LONG
}
#[link_args = "-luser32"]
extern "stdcall" {
pub fn GetCursorPos(lpPoint:&mut POINT) -> BOOL;
pub fn GetForegroundWindow() -> HWND;
pub fn ScreenToClient(hWnd:HWND, lpPoint:&mut POINT);
}
#[fixed_stack_segment]
fn main() {
let mut pt = POINT{x:0, y:0};
loop {
std::rt::io::timer::sleep(100); // sleep duration in milliseconds
let pt_prev = pt;
unsafe { GetCursorPos(&mut pt) };
if pt != pt_prev {
let h = unsafe { GetForegroundWindow() };
if h == mut_null() { continue }
let mut ptc = pt;
unsafe { ScreenToClient(h, &mut ptc) };
println!("x: {}, y: {}", ptc.x, ptc.y);
}
}
}

View file

@ -0,0 +1,6 @@
import java.awt.MouseInfo
object MousePosition extends App {
val mouseLocation = MouseInfo.getPointerInfo().getLocation()
println (mouseLocation)
}