2017-06-05 7 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テストhereをダウンロードできます。 inputoutputcに扱われますが、メイン処理は純粋なbatchです。

次のコードは、存在しない場合はc# executableを作成するバッチヒブリッドです。 c# codeを必要に応じて複雑に構築できますが、問題は2つのグラブ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 
関連する問題