zoukankan      html  css  js  c++  java
  • Powershell mouse_event

    No worries for your PC being idle during the office time. This Powershell down below will help you:

    * Tips: First time when running the PowerShell

    Run command  : Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

    Then put :   Y

    Step1: Create a file named:   Click-MouseButton.ps1

    function Click-MouseButton
    {
    param(
    [string]$Button, 
    [switch]$help)
    $HelpInfo = @'
    
    Function : Click-MouseButton
    By       : John Bartels
    Date     : 12/16/2012 
    Purpose  : Clicks the Specified Mouse Button
    Usage    : Click-MouseButton [-Help][-Button x]
               where      
                      -Help         displays this help
                      -Button       specify the Button You Wish to Click {left, middle, right}
    
    '@ 
    
    if ($help -or (!$Button))
    {
        write-host $HelpInfo
        return
    }
    else
    {
        $signature=@' 
          [DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
          public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
    '@ 
    
        $SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru 
        if($Button -eq "left")
        {
            $SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
            $SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
        }
        if($Button -eq "right")
        {
            $SendMouseClick::mouse_event(0x00000008, 0, 0, 0, 0);
            $SendMouseClick::mouse_event(0x00000010, 0, 0, 0, 0);
        }
        if($Button -eq "middle")
        {
            $SendMouseClick::mouse_event(0x00000020, 0, 0, 0, 0);
            $SendMouseClick::mouse_event(0x00000040, 0, 0, 0, 0);
        }
    
    }
    }
    while ($true){
        Sleep 3     <#Delay for 3 seconds#> 
        Click-MouseButton  "left"     <# left click #> 
    }

    Step2:

    Result :

  • 相关阅读:
    RCNN,Fast RCNN,Faster RCNN 的前生今世:(4) SSD
    RCNN,Fast RCNN,Faster RCNN 的前生今世:(0) DMP
    nachos3.4 threads管理 (c++)
    逻辑回归与多分类逻辑回归
    [LeetCode]String to Integer (atoi)
    [LeetCode]Reverse Integer
    [LeetCode]ZigZag Conversion
    [LeetCode]Longest Palindromic Substring
    [LeetCode]Median of Two Sorted Arrays
    平面点的旋转公式
  • 原文地址:https://www.cnblogs.com/tangh4/p/15100875.html
Copyright © 2011-2022 走看看