June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,2 +1 @@
Simulate the click of a mouse button by the user. Specify if the target GUI may be externally created.
{{Omit From|Modula-3}}

View file

@ -0,0 +1,38 @@
/*Abhishek Ghosh, 10th October 2017*/
#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;
}

View file

@ -1,19 +1,23 @@
import pyautogui
import autopy
import math
import time
import random
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
TWO_PI = math.pi * 2.0
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
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.
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
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))
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"
sine_mouse_wave()

View 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"

View file

@ -0,0 +1,45 @@
# Project : Simulate input/Mouse
# Date : 2018/02/02
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
load "guilib.ring"
load "stdlib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("")
setgeometry(100,100,800,600)
setwindowtitle("Mouse events")
line1 = new qlineedit(win1) {
setgeometry(150,450,300,30)
settext("")}
line2 = new qlineedit(win1) {
setgeometry(150,400,300,30)
settext("")}
new qpushbutton(win1) {
setgeometry(150,500,300,30)
settext("draw")
myfilter = new qallevents(win1)
myfilter.setMouseButtonPressevent("drawpress()")
myfilter.setMouseButtonReleaseevent("drawrelease()")
installeventfilter(myfilter)
}
show()
}
exec()
}
func drawpress()
line2.settext("")
line1.settext("Mouse was pressed")
func drawrelease()
line1.settext("")
line2.settext("Mouse was released")

View file

@ -0,0 +1,25 @@
extern crate autopilot;
extern crate rand;
use rand::Rng;
// Moves the mouse in a sine wave across the screen.
const TWO_PI: f64 = std::f64::consts::PI * 2.0;
fn sine_mouse_wave() -> Result<(), autopilot::mouse::MouseError> {
let screen_size = autopilot::screen::size();
let scoped_height = screen_size.height / 2.0 - 10.0; // Stay in screen bounds.
for x in 0..screen_size.width as u64 {
let y = (scoped_height * ((TWO_PI * x as f64) / screen_size.width).sin() + scoped_height)
.round();
let duration: u64 = rand::thread_rng().gen_range(1, 3);
try!(autopilot::mouse::move_to(autopilot::geometry::Point::new(
x as f64,
y as f64
)));
std::thread::sleep(std::time::Duration::from_millis(duration));
}
Ok(())
}
fn main() {
sine_mouse_wave().expect("Unable to move mouse");
}