2017-06-05 80 views
-1

我很新的批量编程,我想知道是否有一种方法来检测额外的鼠标按钮已批量点击。检测额外的鼠标按钮批量点击

+1

你尝试过什么做你自己?请告诉我们你的努力,所以我们可以尝试帮助你。你可以从一个叫google的好工具开始。 – elzooilogico

+0

@elzooilogico no。我几乎没有关于批量编程的知识。我只是学会了如果简单的情况。我更像一个C#的人,但没有人在互联网上有任何好的鼠标钩子教程。所以我卡住了。 –

回答

0

如果您习惯于c#,您可能会构建一个程序来检测鼠标输入和管道输入到批处理本身,即getinput.exe | mybatch.cmd。这不是一件小事,但你可能会看到如何实现(这里与PowerShell)Tetris game in a pure Batch fileAacini

您可以下载完整工作mouse batch menu测试hereinputoutputc中处理(并写入),但主要处理是纯粹的batch

以下代码是批处理hibryd,如果它不存在,则会创建一个c# executable。您可以根据需要构建复杂的c# code,问题是两次抓取cmd's window input并在批处理文件上处理它。

//>nul 2>nul||@goto :batch_code 
/* 
:batch_code 
@echo off 
setlocal 

if not exist "%~n0.exe" call :build_the_exe || exit/B 

%~n0.exe 
endlocal 
exit /b 0 


:build_the_exe 
:: find csc.exe 
set "frm=%SystemRoot%\Microsoft.NET\Framework\" 
for /f "tokens=* delims=" %%v in ('dir /b /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
    set netver=%%v 
    goto :break_loop 
) 
:break_loop 
set "csc=%frm%%netver%\csc.exe" 
:: csc not found 
if "%csc%" == "\csc.exe" echo/&echo/Warning: Net Framework Not Found&exit/B 1 
::csc found 
call %csc% /nologo /out:"%~n0.exe" "%~dpsfnx0" 
exit/B 0 
*/ 


//begin c# code 
public class HelloWorld 
{ 
    public static void Main() 
    { 
     System.Console.WriteLine("Hello, C# World!"); 
    } 
} 

又如

//>nul 2>nul||@goto :batch_code 
/* 
:batch_code 
@echo off 
setlocal 

if not exist "keyTime.exe" call :build_the_exe || exit/B 

:: use the newly created exe 
<NUL set/p="Press a key (wait 5 seconds) " 

keyTime.exe /W 5000 
endlocal 

exit /b 0 


:build_the_exe 
:: find csc.exe 
set "frm=%SystemRoot%\Microsoft.NET\Framework\" 
for /f "tokens=* delims=" %%v in ('dir /b /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
    set netver=%%v 
    goto :break_loop 
) 
:break_loop 
set "csc=%frm%%netver%\csc.exe" 
:: csc not found 
if "%csc%" == "\csc.exe" echo/&echo/Warning: Net Framework Not Found&exit/B 1 
::csc found 
call %csc% /nologo /out:"keyTime.exe" "%~dpsfnx0" 
exit/B 0 
*/ 


//begin c# code 
using System; 

namespace ElZooilogico 
{ 
    public static class choice 
    { 
// readkey with timeout  
    private static void ReadKeyTimeout(int msecs, char theChar) 
    { 
     theChar = '\0'; 
     ConsoleKeyInfo cfi; 
     ReadKeyDelegate d = Console.ReadKey; 
     IAsyncResult result = d.BeginInvoke(null, null); 
     result.AsyncWaitHandle.WaitOne(msecs); 
     if (result.IsCompleted) 
     { 
     cfi = d.EndInvoke(result); 
     theChar = cfi.KeyChar; 
     } 
    } 
    delegate ConsoleKeyInfo ReadKeyDelegate();  
// readkey with timeout 

    [STAThread] 
    public static int Main(string[] args) 
    { 
     char myChar='\0'; int wait = 10000; 

     for (int i = 0; i < args.Length; i++) 
     { 
     if (args[i].Equals("/W", StringComparison.OrdinalIgnoreCase)) { wait = Int32.Parse(args[i + 1]); } 
     } 

     ReadKeyTimeout(wait, myChar); 
     Console.Write(myChar); 

     return 0; 
    } 
    } // class miClass 
} // namespace ElZooilogico