Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Simulate-input-Mouse/00-META.yaml
Normal file
5
Task/Simulate-input-Mouse/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Testing
|
||||
from: http://rosettacode.org/wiki/Simulate_input/Mouse
|
||||
note: GUI
|
||||
2
Task/Simulate-input-Mouse/00-TASK.txt
Normal file
2
Task/Simulate-input-Mouse/00-TASK.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Simulate the click of a mouse button by the user. Specify if the target GUI may be externally created.
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
WinActivate, ahk_class MozillaUIWindowClass
|
||||
Click 200, 200 right ; relative to external window (firefox)
|
||||
sleep, 2000
|
||||
WinMinimize
|
||||
CoordMode, Mouse, Screen
|
||||
Click 400, 400 right ; relative to top left corner of the screen.
|
||||
36
Task/Simulate-input-Mouse/C/simulate-input-mouse.c
Normal file
36
Task/Simulate-input-Mouse/C/simulate-input-mouse.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#define WINVER 0x500
|
||||
#include<windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int maxX = GetSystemMetrics(SM_CXSCREEN), maxY = GetSystemMetrics(SM_CYSCREEN);
|
||||
int x = maxX/2, y = maxY/2;
|
||||
double factorX = 65536.0 / maxX,factorY = 65536.0 / maxY;
|
||||
|
||||
INPUT ip;
|
||||
|
||||
ZeroMemory(&ip,sizeof(ip));
|
||||
|
||||
ip.type = INPUT_MOUSE;
|
||||
|
||||
while(x > 5 || y < maxY-5){
|
||||
|
||||
ip.mi.mouseData = 0;
|
||||
ip.mi.dx = x * factorX;
|
||||
ip.mi.dy = y * factorY;
|
||||
ip.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
||||
|
||||
SendInput(1,&ip,sizeof(ip));
|
||||
Sleep(1);
|
||||
if(x>3)
|
||||
x-=1;
|
||||
if(y<maxY-3)
|
||||
y+=1;
|
||||
}
|
||||
|
||||
ip.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
|
||||
|
||||
SendInput(1,&ip,sizeof(ip));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(defun sh (cmd)
|
||||
#+clisp (shell cmd)
|
||||
#+ecl (si:system cmd)
|
||||
#+sbcl (sb-ext:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*)
|
||||
#+clozure (ccl:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*))
|
||||
(sh "xdotool mousemove 0 0 click 1")
|
||||
(sleep 2)
|
||||
(sh "xdotool mousemove 300 300 click 1")
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using fwt
|
||||
using gfx
|
||||
|
||||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
button1 := Button
|
||||
{
|
||||
text = "don't click!"
|
||||
onAction.add |Event e|
|
||||
{
|
||||
echo ("clicked by code")
|
||||
}
|
||||
}
|
||||
button2 := Button
|
||||
{
|
||||
text = "click"
|
||||
onAction.add |Event e|
|
||||
{
|
||||
// fire all the event listeners on button1
|
||||
button1.onAction.fire(e)
|
||||
}
|
||||
}
|
||||
Window
|
||||
{
|
||||
title = "simulate mouse event"
|
||||
size = Size (300, 200)
|
||||
button1,
|
||||
button2,
|
||||
}.open
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using [java] java.awt::Robot
|
||||
using [java] java.awt.event::InputEvent
|
||||
using fwt
|
||||
using gfx
|
||||
|
||||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
button := Button
|
||||
{
|
||||
text = "click for robot"
|
||||
onAction.add |Event e|
|
||||
{
|
||||
robot := Robot ()
|
||||
robot.mouseMove (50, 50) // move to screen point 50, 50
|
||||
robot.mousePress (InputEvent.BUTTON1_MASK) // and click mouse
|
||||
robot.mouseRelease (InputEvent.BUTTON1_MASK)
|
||||
}
|
||||
}
|
||||
Window
|
||||
{
|
||||
title = "simulate mouse event"
|
||||
size = Size (300, 200)
|
||||
button,
|
||||
}.open
|
||||
}
|
||||
}
|
||||
150
Task/Simulate-input-Mouse/FreeBASIC/simulate-input-mouse.basic
Normal file
150
Task/Simulate-input-Mouse/FreeBASIC/simulate-input-mouse.basic
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
#include "fbgfx.bi"
|
||||
#define rect 4
|
||||
|
||||
Windowtitle "Mouse events"
|
||||
Screen 19,32
|
||||
Dim Shared As Integer xres, yres
|
||||
Screeninfo xres, yres
|
||||
|
||||
Type box
|
||||
As Single x, y, z
|
||||
As String caption
|
||||
As Uinteger textcol, boxcol
|
||||
End Type
|
||||
|
||||
Dim Shared As box label(rect,1)
|
||||
Dim Shared As box button(rect,1)
|
||||
Dim Shared As Boolean flag
|
||||
Dim Shared As fb.event e
|
||||
Dim As Uinteger background = Rgb(100,100,100)
|
||||
|
||||
Sub thickline(x1 As Double, y1 As Double, x2 As Double, y2 As Double,_
|
||||
thickness As Double, colour As Uinteger, im As Any Pointer = 0)
|
||||
Dim p As Uinteger = Rgb(255, 255, 254)
|
||||
If thickness < 2 Then
|
||||
Line(x1,y1)-(x2,y2), colour
|
||||
Else
|
||||
Dim As Double h = Sqr((x2-x1)^2+(y2-y1)^2), s = (y1-y2)/h, c = (x2-x1)/h
|
||||
For x As Integer = 1 To 2
|
||||
Line im,(x1+s*thickness/2,y1+c*thickness/2)-(x2+s*thickness/2,y2+c*thickness/2),p
|
||||
Line im,(x1-s*thickness/2,y1-c*thickness/2)-(x2-s*thickness/2,y2-c*thickness/2),p
|
||||
Line im,(x1+s*thickness/2,y1+c*thickness/2)-(x1-s*thickness/2,y1-c*thickness/2),p
|
||||
Line im,(x2+s*thickness/2,y2+c*thickness/2)-(x2-s*thickness/2,y2-c*thickness/2),p
|
||||
Paint im,((x1+x2)/2, (y1+y2)/2), p, p
|
||||
p = colour
|
||||
Next x
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Function inbox(p1() As box, p2 As box) As Integer
|
||||
Type pt2d : As Single x, y : End Type
|
||||
Type ln2d : As pt2d v1, v2 : End Type
|
||||
#macro isleft(L,p)
|
||||
-Sgn((L.v1.x-L.v2.x)*(p.y-L.v2.y) - (p.x-L.v2.x)*(L.v1.y-L.v2.y))
|
||||
#endmacro
|
||||
Dim As Single n1 = p1(rect,0).z
|
||||
Dim As Integer index, nextindex
|
||||
Dim send As ln2d
|
||||
Dim As Integer n, wn = 0
|
||||
For n = 1 To 4
|
||||
index = n Mod 5 : nextindex = (n+1) Mod 5
|
||||
If nextindex = 0 Then nextindex = 1
|
||||
send.v1.x = p1(index,n1).x : send.v2.x = p1(nextindex,n1).x
|
||||
send.v1.y = p1(index,n1).y : send.v2.y = p1(nextindex,n1).y
|
||||
If p1(index,n1).y <= p2.y Then
|
||||
If p1(nextindex,n1).y > p2.y Then
|
||||
If isleft(send,p2) > 0 Then wn += 1
|
||||
End If
|
||||
Else
|
||||
If p1(nextindex,n1).y <= p2.y Then
|
||||
If isleft(send,p2) < 0 Then wn -= 1
|
||||
End If
|
||||
End If
|
||||
Next n
|
||||
Return wn
|
||||
End Function
|
||||
|
||||
Sub draw_box(p() As box, col As Uinteger, pnt As String = "paint", im As Any Pointer = 0)
|
||||
Dim As Integer index, nextindex
|
||||
Dim As Single n1 = p(rect,0).z
|
||||
Dim As Double xc, yc
|
||||
For n As Integer = 1 To 4
|
||||
xc += p(n,n1).x : yc += p(n,n1).y
|
||||
index = n Mod 5 : nextindex = (n+1) Mod 5
|
||||
If nextindex = 0 Then nextindex = 1
|
||||
thickline(p(index,n1).x,p(index,n1).y, p(nextindex,n1).x,p(nextindex,n1).y,4,col,im)
|
||||
Next n
|
||||
xc /= Ubound(p) : yc /= Ubound(p)
|
||||
If pnt = "paint" Then Paint(xc,yc), col, col
|
||||
End Sub
|
||||
|
||||
Sub highlightbox(box() As box, mp As box, col As Uinteger)
|
||||
box(rect,0).z = 1
|
||||
If inbox(box(),mp) Then draw_box(box(),col,"dont_paint")
|
||||
End Sub
|
||||
|
||||
Sub checkbox(box() As box,mp As box)
|
||||
flag = True
|
||||
label(rect,1).caption = box(rect,1).caption
|
||||
label(rect,1).textcol = box(rect,1).textcol
|
||||
label(rect,1).boxcol = box(rect,1).boxcol
|
||||
End Sub
|
||||
|
||||
Sub drawbox(x As Integer, y As Integer, box()As box, boxlength As Integer, _
|
||||
boxheight As Integer, col As Uinteger, highlight As Uinteger, caption As String)
|
||||
Dim As box startpoint
|
||||
startpoint.x = x : startpoint.y = y
|
||||
Dim As Integer mmx, mmy
|
||||
Getmouse mmx, mmy
|
||||
Dim As box mouse
|
||||
mouse.x = mmx : mouse.y = mmy
|
||||
box(rect,1).boxcol = col
|
||||
box(rect,1).caption = caption
|
||||
Dim As Uinteger outline, count = 1
|
||||
outline = Rgb(255,255,255)
|
||||
For x As Integer = 1 To 4
|
||||
Select Case x
|
||||
Case 1
|
||||
box(1,count).x = startpoint.x
|
||||
box(1,count).y = startpoint.y
|
||||
Case 2
|
||||
box(2,count).x = box(1,count).x + boxlength
|
||||
box(2,count).y = box(1,count).y
|
||||
Case 3
|
||||
box(3,count).x = box(2,count).x
|
||||
box(3,count).y = box(2,count).y + boxheight
|
||||
Case 4
|
||||
box(4,count).x = box(3,count).x - boxlength
|
||||
box(4,count).y = box(3,count).y
|
||||
End Select
|
||||
Next x
|
||||
box(rect,0).z = 1
|
||||
draw_box(box(),col)
|
||||
draw_box(box(),outline,"nopaint")
|
||||
If inbox(box(),mouse) Then
|
||||
highlightbox(box(),mouse,highlight)
|
||||
If (Screenevent(@e)) Then
|
||||
If e.type = fb.EVENT_MOUSE_BUTTON_PRESS Then checkbox(box(),mouse)
|
||||
End If
|
||||
End If
|
||||
Draw String(box(1,1).x+5,box(1,1).y+5), box(rect,1).caption,box(rect,1).textcol
|
||||
End Sub
|
||||
|
||||
' ---------- Main Program ----------
|
||||
Do
|
||||
Screenlock
|
||||
Cls
|
||||
Paint(0,0), background
|
||||
Draw String(300,50), "BUTTON CLICK TEST", Rgb(0,0,200)
|
||||
|
||||
drawbox(100,100,button(),100,50,Rgb(200,200,0),Rgb(00,0,200),"Box 1")
|
||||
drawbox(100,200,button(),100,50,Rgb(200,0,190),Rgb(00,0,200),"Box 2")
|
||||
drawbox(100,300,button(),100,50,Rgb(0,200,190),Rgb(00,0,200),"Box 3")
|
||||
|
||||
If flag Then drawbox(400,100,label(),250,250,label(rect,1).boxcol,Rgb(255,255,255),label(rect,1).caption)
|
||||
If (Screenevent(@e)) Then
|
||||
If e.type=13 Then End
|
||||
End If
|
||||
Screenunlock
|
||||
Sleep 1, 1
|
||||
Loop Until Inkey = Chr(27)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Start,Programs,Accessories,Notepad,Textbox,Type:Hello World[pling],Menu:File,Save,
|
||||
Inputbox:filename>greetings.txt,Button:Save
|
||||
8
Task/Simulate-input-Mouse/Go/simulate-input-mouse.go
Normal file
8
Task/Simulate-input-Mouse/Go/simulate-input-mouse.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "github.com/go-vgo/robotgo"
|
||||
|
||||
func main() {
|
||||
robotgo.MouseClick("left", false) // single clicks left mouse button
|
||||
robotgo.MouseClick("right", true) // double clicks right mouse button
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
Point p = component.getLocation();
|
||||
Robot robot = new Robot();
|
||||
robot.mouseMove(p.getX(), p.getY()); //you may want to move a few pixels closer to the center by adding to these values
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK); //BUTTON1_MASK is the left button,
|
||||
//BUTTON2_MASK is the middle button, BUTTON3_MASK is the right button
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
|
@ -0,0 +1 @@
|
|||
button.doClick(); //optionally, give an integer argument for the number of milliseconds to hold the button down
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Wrap win32 API function mouse_event() from the User32 dll.
|
||||
function mouse_event_wrapper(dwFlags,dx,dy,dwData,dwExtraInfo)
|
||||
ccall((:mouse_event, "User32"),stdcall,Nothing,(UInt32,UInt32,UInt32,UInt32,UInt),dwFlags,dx,dy,dwData,dwExtraInfo)
|
||||
end
|
||||
|
||||
function click()
|
||||
mouse_event_wrapper(0x2,0,0,0,0)
|
||||
mouse_event_wrapper(0x4,0,0,0,0)
|
||||
end
|
||||
14
Task/Simulate-input-Mouse/Kotlin/simulate-input-mouse.kotlin
Normal file
14
Task/Simulate-input-Mouse/Kotlin/simulate-input-mouse.kotlin
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// version 1.1.2
|
||||
|
||||
import java.awt.Robot
|
||||
import java.awt.event.InputEvent
|
||||
|
||||
fun sendClick(buttons: Int) {
|
||||
val r = Robot()
|
||||
r.mousePress(buttons)
|
||||
r.mouseRelease(buttons)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
sendClick(InputEvent.BUTTON3_DOWN_MASK) // simulate a click of the mouse's right button
|
||||
}
|
||||
10
Task/Simulate-input-Mouse/Oz/simulate-input-mouse.oz
Normal file
10
Task/Simulate-input-Mouse/Oz/simulate-input-mouse.oz
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
declare
|
||||
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
|
||||
Button
|
||||
Window = {QTk.build td(button(text:"Click me" handle:Button))}
|
||||
in
|
||||
{Window show}
|
||||
{Delay 500}
|
||||
{Tk.send event(generate Button "<ButtonPress-1>")}
|
||||
{Delay 500}
|
||||
{Tk.send event(generate Button "<ButtonRelease-1>")}
|
||||
64
Task/Simulate-input-Mouse/Phix/simulate-input-mouse.phix
Normal file
64
Task/Simulate-input-Mouse/Phix/simulate-input-mouse.phix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
(notonline)-->
|
||||
<span style="color: #000080;font-style:italic;">--
|
||||
-- demo\rosetta\Simulate_mouse_input.exw
|
||||
--
|
||||
-- Note that CURSORPOS, SCREENPOSITION, and MOUSEBUTTON are known to be a little flaky and/or system-dependent, ymmv.
|
||||
--</span>
|
||||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- you'd better hope this sort of thing ain't possible in a browser!</span>
|
||||
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.1"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (IupGetGlobalIntInt)</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">delay</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">16</span> <span style="color: #000080;font-style:italic;">-- (4s @ 250ms)</span>
|
||||
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">btn</span>
|
||||
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">action_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*btn*/</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">t</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">date</span><span style="color: #0000FF;">(),</span><span style="color: #008000;">"hh:mm:sspm"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">IupSetStrAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"TITLE"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Clicked at %s"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">t</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_DEFAULT</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">cx</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">cy</span>
|
||||
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">timer_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000000;">timer</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">delay</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #7060A8;">IupSetStrAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"TITLE"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%3.2f"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">delay</span><span style="color: #0000FF;">/</span><span style="color: #000000;">4</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #000000;">delay</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span>
|
||||
<span style="color: #0000FF;">{</span><span style="color: #000000;">cx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cy</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupGetGlobalIntInt</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"CURSORPOS"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">else</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">xb</span><span style="color: #0000FF;">,</span><span style="color: #000000;">yb</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupGetIntInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"SCREENPOSITION"</span><span style="color: #0000FF;">),</span>
|
||||
<span style="color: #0000FF;">{</span><span style="color: #000000;">wb</span><span style="color: #0000FF;">,</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupGetIntInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"RASTERSIZE"</span><span style="color: #0000FF;">),</span>
|
||||
<span style="color: #0000FF;">{</span><span style="color: #000000;">dx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">dy</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">xb</span><span style="color: #0000FF;">+</span><span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">wb</span><span style="color: #0000FF;">/</span><span style="color: #000000;">2</span><span style="color: #0000FF;">),</span><span style="color: #000000;">yb</span><span style="color: #0000FF;">+</span><span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">/</span><span style="color: #000000;">2</span><span style="color: #0000FF;">)}</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">dx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">dy</span><span style="color: #0000FF;">}!={</span><span style="color: #000000;">cx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cy</span><span style="color: #0000FF;">}</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">IupGetInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">timer</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"TIME"</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">250</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #7060A8;">IupSetInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">timer</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"TIME"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">40</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">IupSetInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">timer</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"RUN"</span><span style="color: #0000FF;">,</span><span style="color: #004600;">false</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">IupSetInt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">timer</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"RUN"</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">15</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">cx</span><span style="color: #0000FF;"><</span><span style="color: #000000;">dx</span> <span style="color: #008080;">then</span> <span style="color: #000000;">cx</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">cx</span><span style="color: #0000FF;">></span><span style="color: #000000;">dx</span> <span style="color: #008080;">then</span> <span style="color: #000000;">cx</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">cy</span><span style="color: #0000FF;"><</span><span style="color: #000000;">dy</span> <span style="color: #008080;">then</span> <span style="color: #000000;">cy</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">cy</span><span style="color: #0000FF;">></span><span style="color: #000000;">dy</span> <span style="color: #008080;">then</span> <span style="color: #000000;">cy</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">cxcy</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%dx%d "</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">cx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cy</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #7060A8;">IupSetGlobal</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"CURSORPOS"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cxcy</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">else</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%dx%d 1 2"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">dx</span><span style="color: #0000FF;">,</span><span style="color: #000000;">dy</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #7060A8;">IupSetStrGlobal</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"MOUSEBUTTON"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">IupSetAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">timer</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"RUN"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"NO"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_CONTINUE</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
|
||||
<span style="color: #7060A8;">IupOpen</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #000000;">btn</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupButton</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"button"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"action_cb"</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"SIZE=100x12"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">dlg</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupDialog</span><span style="color: #0000FF;">(</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`TITLE="Simulate mouse input", CHILDOFFSET=10x40, SIZE=200x80`</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">IupShow</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">timer</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupTimer</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"timer_cb"</span><span style="color: #0000FF;">),</span> <span style="color: #000000;">250</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()!=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span> <span style="color: #000080;font-style:italic;">-- (just for consistency)</span>
|
||||
<span style="color: #7060A8;">IupMainLoop</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<!--
|
||||
15
Task/Simulate-input-Mouse/PicoLisp/simulate-input-mouse.l
Normal file
15
Task/Simulate-input-Mouse/PicoLisp/simulate-input-mouse.l
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(load "@lib/http.l" "@lib/scrape.l")
|
||||
|
||||
# Connect to the demo app at https://7fach.de/app/
|
||||
(scrape "7fach.de" 80 "app")
|
||||
|
||||
# Log in
|
||||
(expect "'admin' logged in"
|
||||
(enter 3 "admin") # Enter user name into 3rd field
|
||||
(enter 4 "admin") # Enter password into 4th field
|
||||
(press "login") ) # Press the "login" button
|
||||
|
||||
(click "Items") # Open "Items" dialog
|
||||
(click "Spare Part") # Click on "Spare Part" article
|
||||
(prinl (value 8)) # Print the price (12.50)
|
||||
(click "logout") # Log out
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
Macro Click()
|
||||
mouse_event_(#MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
|
||||
mouse_event_(#MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
|
||||
EndMacro
|
||||
|
||||
; Click at the current location
|
||||
Click()
|
||||
|
||||
Delay(1000) ; Wait a second
|
||||
|
||||
; Move to a new location and click it
|
||||
SetCursorPos_(50, 50)
|
||||
Click()
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
; The same function as above, but using AutoWin UserLibray
|
||||
AW_MouseClick()
|
||||
Delay(1000)
|
||||
AW_MouseClick(#PB_MouseButton_Left, 50, 50)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import ctypes
|
||||
|
||||
def click():
|
||||
ctypes.windll.user32.mouse_event(0x2, 0,0,0,0) # Mouse LClick Down, relative coords, dx=0, dy=0
|
||||
ctypes.windll.user32.mouse_event(0x4, 0,0,0,0) # Mouse LClick Up, relative coords, dx=0, dy=0
|
||||
|
||||
click()
|
||||
23
Task/Simulate-input-Mouse/Python/simulate-input-mouse-2.py
Normal file
23
Task/Simulate-input-Mouse/Python/simulate-input-mouse-2.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import autopy
|
||||
import math
|
||||
import time
|
||||
import random
|
||||
|
||||
TWO_PI = math.pi * 2.0
|
||||
|
||||
|
||||
def sine_mouse_wave():
|
||||
"""
|
||||
Moves the mouse in a sine wave from the left edge of the screen to
|
||||
the right.
|
||||
"""
|
||||
width, height = autopy.screen.get_size()
|
||||
height /= 2
|
||||
height -= 10 # Stay in the screen bounds.
|
||||
|
||||
for x in xrange(width):
|
||||
y = int(height * math.sin((TWO_PI * x) / width) + height)
|
||||
autopy.mouse.move(x, y)
|
||||
time.sleep(random.uniform(0.001, 0.003))
|
||||
|
||||
sine_mouse_wave()
|
||||
19
Task/Simulate-input-Mouse/Python/simulate-input-mouse-3.py
Normal file
19
Task/Simulate-input-Mouse/Python/simulate-input-mouse-3.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import pyautogui
|
||||
|
||||
pyautogui.moveTo(100, 200) # moves mouse to X of 100, Y of 200.
|
||||
pyautogui.moveTo(None, 500) # moves mouse to X of 100, Y of 500.
|
||||
pyautogui.moveTo(600, None) # moves mouse to X of 600, Y of 500.
|
||||
pyautogui.moveTo(100, 200, 2) # moves mouse to X of 100, Y of 200 over 2 seconds
|
||||
|
||||
pyautogui.moveRel(0, 50) # move the mouse down 50 pixels.
|
||||
pyautogui.moveRel(-30, 0) # move the mouse left 30 pixels.
|
||||
|
||||
pyautogui.click() # Left button click on current position
|
||||
pyautogui.click(clicks=2)
|
||||
pyautogui.click(clicks=2, interval=0.25) # with a quarter second pause in between clicks
|
||||
|
||||
pyautogui.click(10, 5) # Mouse left button click, x=10, y=5
|
||||
pyautogui.click(200, 250, button='right') # Mouse right button click, x=200, y=250
|
||||
|
||||
pyautogui.scroll(10) # scroll up 10 "clicks"
|
||||
pyautogui.scroll(10, x=100, y=100) # move mouse cursor to 100, 200, then scroll up 10 "clicks"
|
||||
10
Task/Simulate-input-Mouse/Racket/simulate-input-mouse.rkt
Normal file
10
Task/Simulate-input-Mouse/Racket/simulate-input-mouse.rkt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#lang at-exp racket
|
||||
|
||||
(require ffi/unsafe)
|
||||
|
||||
(define mouse-event
|
||||
(get-ffi-obj "mouse_event" (ffi-lib "user32")
|
||||
(_fun _int32 _int32 _int32 _int32 _pointer -> _void)))
|
||||
|
||||
(mouse-event #x2 0 0 0 #f)
|
||||
(mouse-event #x4 0 0 0 #f)
|
||||
47
Task/Simulate-input-Mouse/Raku/simulate-input-mouse.raku
Normal file
47
Task/Simulate-input-Mouse/Raku/simulate-input-mouse.raku
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
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 '';
|
||||
|
||||
#`[ There are several available routines controlling mouse position and button events. | ||||