Mouse position: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 267:
return 0;
}</lang>
 
=={{header|c_sharp|C#}}==
Writes the absolute Mouse Position of the Screen into the Console
<lang csharp>
using System;
using System.Windows.Forms;
static class Program
{
[STAThread]
static void Main()
{
Console.WriteLine(Control.MousePosition.X);
Console.WriteLine(Control.MousePosition.Y);
}
}
</lang>
 
=={{header|Clojure}}==
<lang lisp>(let [point (.. java.awt.MouseInfo getPointerInfo getLocation)] [(.getX point) (.getY point)])</lang>
 
=={{header|Common Lisp}}==
Line 297 ⟶ 316:
 
The <code>#S</code> indicates we get a structure, so we can access the x position with <code>(event-x event)</code>.
 
=={{header|c_sharp|C#}}==
Writes the absolute Mouse Position of the Screen into the Console
<lang csharp>
using System;
using System.Windows.Forms;
static class Program
{
[STAThread]
static void Main()
{
Console.WriteLine(Control.MousePosition.X);
Console.WriteLine(Control.MousePosition.Y);
}
}
</lang>
=={{header|Clojure}}==
<lang lisp>(let [point (.. java.awt.MouseInfo getPointerInfo getLocation)] [(.getX point) (.getY point)])</lang>
 
=={{header|Delphi}}==
Line 477 ⟶ 478:
CLS
END PROGRAM
</lang>
 
=={{header|Factor}}==
Works only in the graphical listener.
Replaces the text in the button with the relative and absolute coordinates of the mouse
<lang factor>: replace-text ( button text -- )
[ drop children>> pop drop ] [ >label add-gadget drop ] 2bi ;
: present-locations ( loc1 loc2 -- string )
[
first2 [ number>string ] bi@ "," glue
] bi@ ";" glue ;
: example ( -- ) "click me"
[
dup hand-rel ! location relative to the button
hand-loc get ! location relative to the window
present-locations replace-text
]
<border-button> gadget. ;
</lang>
 
Line 523 ⟶ 506:
ScreenToClient(hwnd, &ptFs) |> ignore
ptFs
</lang>
 
=={{header|Factor}}==
Works only in the graphical listener.
Replaces the text in the button with the relative and absolute coordinates of the mouse
<lang factor>: replace-text ( button text -- )
[ drop children>> pop drop ] [ >label add-gadget drop ] 2bi ;
: present-locations ( loc1 loc2 -- string )
[
first2 [ number>string ] bi@ "," glue
] bi@ ";" glue ;
: example ( -- ) "click me"
[
dup hand-rel ! location relative to the button
hand-loc get ! location relative to the window
present-locations replace-text
]
<border-button> gadget. ;
</lang>
 
Line 651 ⟶ 652:
In the above example, the window may not be external.
It must in fact be a web browser window, which runs the script.
 
 
=={{header|Julia}}==
Line 778:
CheckIt
</lang>
 
 
=={{header|Mathematica}}==
<lang Mathematica>MousePosition["WindowAbsolute"]</lang>
 
=={{header|MATLAB}}==
<lang MATLAB>get(0,'PointerLocation')</lang>
 
=={{header|MAXScript}}==
Creates a window on the screen and shows mouse position as it moves.
Line 807 ⟶ 810:
createdialog mousepos
</lang>
 
=={{header|MATLAB}}==
<lang MATLAB>get(0,'PointerLocation')</lang>
 
=={{header|MiniScript}}==
Line 855:
xCloseDisplay d;
;;</lang>
 
 
=={{header|Octave}}==
Line 930 ⟶ 929:
{{out}}
<pre>x=15 y=304</pre>
 
=={{header|Perl 6}}==
{{works with|rakudo/jvm|2013-12-03}}
<lang perl6>use java::awt::MouseInfo:from<java>;
 
given MouseInfo.getPointerInfo.getLocation {
say .getX, 'x', .getY;
}</lang>
 
An implementation that will work on any X11 windowing system. Reports mouse position, window ID# and window name for whichever window the mouse pointer is over. Automatically moves mouse for hands-off testing purposes.
 
{{works with|Rakudo|2018.11}}
<lang perl6>use X11::libxdo;
my $xdo = Xdo.new;
 
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );
 
sleep .25;
 
for ^$dw -> $mx {
my $my = (($mx / $dh * τ).sin * 500).abs.Int + 200;
$xdo.move-mouse( $mx, $my, 0 );
my ($x, $y, $window-id, $screen) = $xdo.get-mouse-info;
my $name = (try $xdo.get-window-name($window-id) if $window-id)
// 'No name set';
 
my $line = "Mouse location: x=$x : y=$y\nWindow under mouse:\nWindow ID: " ~
$window-id ~ "\nWindow name: " ~ $name ~ "\nScreen #: $screen";
 
print "\e[H\e[J", $line;
sleep .001;
}
 
say '';</lang>
 
=={{header|Phix}}==
Line 1,135 ⟶ 1,100:
mainloop()
</lang>
 
=={{header|Scala}}==
 
{{libheader|Scala}}<lang scala>import java.awt.MouseInfo
object MousePosition extends App {
val mouseLocation = MouseInfo.getPointerInfo.getLocation
println (mouseLocation)
}</lang>
 
=={{header|Racket}}==
Line 1,154 ⟶ 1,111:
(send point get-y)
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|rakudo/jvm|2013-12-03}}
<lang perl6>use java::awt::MouseInfo:from<java>;
 
given MouseInfo.getPointerInfo.getLocation {
say .getX, 'x', .getY;
}</lang>
 
An implementation that will work on any X11 windowing system. Reports mouse position, window ID# and window name for whichever window the mouse pointer is over. Automatically moves mouse for hands-off testing purposes.
 
{{works with|Rakudo|2018.11}}
<lang perl6>use X11::libxdo;
my $xdo = Xdo.new;
 
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );
 
sleep .25;
 
for ^$dw -> $mx {
my $my = (($mx / $dh * τ).sin * 500).abs.Int + 200;
$xdo.move-mouse( $mx, $my, 0 );
my ($x, $y, $window-id, $screen) = $xdo.get-mouse-info;
my $name = (try $xdo.get-window-name($window-id) if $window-id)
// 'No name set';
 
my $line = "Mouse location: x=$x : y=$y\nWindow under mouse:\nWindow ID: " ~
$window-id ~ "\nWindow name: " ~ $name ~ "\nScreen #: $screen";
 
print "\e[H\e[J", $line;
sleep .001;
}
 
say '';</lang>
 
=={{header|Ring}}==
Line 1,224 ⟶ 1,216:
ok
</lang>
 
=={{header|Ruby}}==
 
Line 1,284 ⟶ 1,277:
x: 0, y: 0
^C</pre>
 
=={{header|Scala}}==
 
{{libheader|Scala}}<lang scala>import java.awt.MouseInfo
object MousePosition extends App {
val mouseLocation = MouseInfo.getPointerInfo.getLocation
println (mouseLocation)
}</lang>
 
=={{header|Seed7}}==
10,333

edits