批量鼠标点击检测?

时间:2015-02-19 00:52:34

标签: batch-file

所以我想创建一个通过鼠标点击恢复输入的批处理文件。我最近发现了一个文件,它可以准确地说明我想要做什么,但它没有多大意义。

@Echo Off
::Tic Tac Toe Trainer v1.0
::Author: Carlos
:Global
SetLocal EnableExtensions EnableDelayedExpansion
Set "b.s.-1=O" & Set "b.s.0= " & Set "b.s.1=X"
Set/a "e.f.1=7,e.f.7=1,e.f.3=5,e.f.5=3"
Set/a "e.c.1.a=0,e.c.1.b=2,e.c.3.a=0,e.c.3.b=6"
Set/a "e.c.5.a=2,e.c.5.b=8,e.c.7.a=6,e.c.7.b=8"
Set/a "c.d.0=8,c.d.8=0,c.d.2=6,c.d.6=2"
Set/a "c.s.0.a=1,c.s.0.b=3,c.s.2.a=1,c.s.2.b=5"
Set/a "c.s.6.a=3,c.s.6.b=7,c.s.8.a=5,c.s.8.b=7"
Set "all=0 1 2 3 4 5 6 7 8" & Set "center=4"
Set "corners=0 2 6 8" & Set "edges=1 3 5 7"
Set "wp="0 1 2" "3 4 5" "6 7 8" "0 3 6""
Set "wp=!wp! "1 4 7" "2 5 8" "0 4 8" "2 4 6""
If Not Exist Mouse.exe Call :BMouse
Set/a "computer=ties=player=0"
:Main
Title Tic Tac Toe Trainer v1.0
Echo.Tic Tac Toe Trainer v1.0
Echo.........................
Echo.Play with Mouse.
Echo.For Quit Press Ctrl+C
Echo.Clic for Continue ...
Mouse > Nul 2>&1
Call :BMenu
Goto :Eof
:BMenu
Cls
Set/a "b=1"
:Play
If !b! Equ 1 (Call :BComputr) Else Call :BPlayer
Echo.
Echo. Clic for Continue ...
Mouse.exe > nul
Set/a "b*=-1"
Goto :Play
:IsCorner
For %%+ in (%corners%) Do If %~1 Equ %%+ Exit/b 1
Exit/b 0
:IsEdge
For %%+ in (%edges%) Do If %~1 Equ %%+ Exit/b 1
Exit/b 0
:IsCenter
For %%+ in (%center%) Do If %~1 Equ %%+ Exit/b 1
Exit/b 0
:BGame
For /L %%i in (0,1,8) Do Set/a "b[%%i]=0"
Set/a "Over=0"
Call :ShowBoard
Goto :Eof
:Winner
For %%+ in (%wp%) Do ( Call :_WinnerL %%~+
If !ErrorLevel! Neq 0 Exit/b !ErrorLevel!)
Exit/b 0
:_WinnerL
If !b[%~1]! Neq 0 (
If !b[%~1]! Equ !b[%~2]! If !b[%~3]! Equ !b[%~1]! Exit/b !b[%~1]!)
Exit/b 0
:Player
If !Over! Equ 1 Exit/b -1
Set/a "sel=-1,k=-1,c=0"
Set "cas="
For /f "tokens=1,2,3" %%a in ('Mouse.exe 2^>Nul') Do (
Set "cas=%%b%%c"
Set/a "c=%%a")
If !c! Neq 1 Goto :Player
For %%a in (00 20 40 02 22 42 04 24 44) Do (
Set/a "sel+=1"
If "%%a"=="!cas!" Set/a "k=!sel!")
If !k! Equ -1 Goto :Player
If !b[%k%]! Equ 0 (Call :UpdatePos %k% %~1
Exit/b %k%)
Goto :Player
:ShowBoard
Cls
Echo.!b.s.%b[0]%!^|!b.s.%b[1]%!^|!b.s.%b[2]%!
Echo.-----
Echo.!b.s.%b[3]%!^|!b.s.%b[4]%!^|!b.s.%b[5]%!
Echo.-----
Echo.!b.s.%b[6]%!^|!b.s.%b[7]%!^|!b.s.%b[8]%!
Echo.
Echo.  Computer     Ties       Player
Echo.     !computer!          !ties!          !player!
Goto :Eof
:WinBlock
If !Over! Equ 1 Exit/b -1
If %~1 Equ 1 (Set/a "_win_value=2,_lost_value=-2"
) Else Set/a "_win_value=-2,_lost_value=2"
Call :_WinBloc %~1 %_win_value%
If !wb_return! Neq -1 (Set/a "Over=1"
) Else Call :_WinBloc %~1 %_lost_value%
Exit/b !wb_return!
:_WinBloc
Set/a "wb_return=-1"
For %%+ in (%wp%) Do (Call :_SumLine %%~+ %~2
If ErrorLevel 1 (For %%- in (%%~+) Do (If !b[%%-]! Equ 0 (
Call :UpdatePos %%- %~1
Set/a "wb_return=%%-"
Goto :_WinBloE))))
:_WinBloE
Goto :Eof
:_SumLine
Set/a "_sum_line=!b[%~1]!+!b[%~2]!+!b[%~3]!"
If !_sum_line! Equ %~4 Exit/b 1
Exit/b 0
:FullBoard
For /L %%i in (0,1,8) Do If !b[%%i]! Equ 0 Exit/b 0
Exit/b 1
:RUpdatePos
Set "av="
Set/a "cav=0"
For %%+ in (!%~1!) Do If !b[%%+]! Equ 0 (
Set "av=!av! %%+"
Set/a "cav+=1")
If !cav! Equ 0 Exit/b -1
Set/a "rp=%random% %% !cav!+1"
For /f "tokens=%rp%" %%+ in ("!av!") Do Set/a "rp=%%+"
Call :UpdatePos !rp! %~2
Exit/b !ErrorLevel!
:UpdatePos
Set/a "b[%~1]=%~2"
Call :Winner
Set "w=!ErrorLevel!"
If !w! Equ 1 (If !b! Equ 1 (Set/a "computer+=1"
) Else Set/a "player+=1") Else If !w! Equ -1 (
If !b! Equ 1 (Set/a "player+=1") Else Set/a "computer+=1"
) Else (Call :FullBoard
If ErrorLevel 1 Set/a "ties+=1")
Call :ShowBoard
Exit/b %~1
:BPlayer
Call :BGame
Call :Player 1
Set/a "maxf=!ErrorLevel!"
Call :IsCenter %maxf%
If ErrorLevel 1 (Call :RUpdatePos corners -1
For /l %%. in (1,1,4) Do (Call :Player 1
Call :WinBlock -1
If Not ErrorLevel 0 If !Over! Equ 0 (
Call :RUpdatePos corners -1
If Not ErrorLevel 0 Call :RUpdatePos all -1))
) Else (Call :UpdatePos 4 -1
Call :Player 1
Set/a "maxc=0,maxe=0,maxcd=0,c1e1oc2nd=0"
For /L %%+ in (0,1,8) Do If !b[%%+]! Equ 1 (Call :IsEdge %%+
If ErrorLevel 1 (Set/a "maxe+=1"
) Else (Call :IsCorner %%+
If ErrorLevel 1 (Set/a "maxc+=1"
For /f %%- in ("b[!c.d.%%+!]") Do (
If !%%-! Equ 1 Set/a "maxcd=1"))))
If !maxc! Equ 1 (Set/a "c1e1oc2nd=1"
) Else If !maxc! Equ 2 If !maxcd! Equ 0 Set/a "c1e1oc2nd=1"
If !c1e1oc2nd! Equ 1 (Call :WinBlock -1
If ErrorLevel 0 (Call :Player 1
Call :WinBlock -1
Set/a _res=!ErrorLevel!
If !Over! Equ 0 (If !_res! Neq -1 (Call :Player 1
Call :WinBlock -1
If !Over! Equ 0 (Call :RUpdatePos all -1
Call :Player 1)) Else (Call :RUpdatePos edges -1
Call :Player 1
Call :WinBlock -1
If !Over! Equ 0 Call :Player 1))) Else (
For %%+ in (%corners%) Do If !b[%%+]! Equ 1 (
Call :UpdatePos !c.d.%%+! -1)
Call :Player 1
Call :WinBlock -1
If ErrorLevel 0 (Call :Player 1
Call :WinBlock -1
If Not ErrorLevel 0 (Call :RUpdatePos all -1
Call :Player 1) Else If !Over! Equ 0 (Call :Player 1
Call :RUpdatePos all -1)) Else (Call :RUpdatePos corners -1
Call :Player 1
Call :WinBlock -1
If !Over! Equ 0 Call :Player 1
))) Else If !maxc! Equ 2 (Call :RUpdatePos edges -1
Call :Player 1
For /l %%+ in (1,1,2) Do (Call :WinBlock -1
If !Over! Equ 0 Call :Player 1)) Else (Set/a "eif=0"
For %%+ in (%edges%) Do (
If !b[%%+]! Equ 1 For /f %%- in ("b[!e.f.%%+!]") Do (
If !%%-! Equ 1 Set/a "eif=1"))
If !eif! Equ 1 (Call :RUpdatePos edges -1
Call :Player 1
Call :WinBlock -1
If Not ErrorLevel 0 (Set/a "p=0"
For %%+ in (%corners%) Do If !b[%%+]! Equ 0 (
For /f "tokens=1,2" %%a in (
"b[!c.s.%%+.a!] b[!c.s.%%+.b!]") Do (
If !p! Equ 0 If !%%a! Equ -1 (Call :UpdatePos %%+ -1
Set/a "p=1") Else If !p! Equ 0 If !%%b! Equ -1 (
Call :UpdatePos %%+ -1
Set/a "p=1")))
Call :Player 1
Call :WinBlock -1)) Else (
For %%+ in (%corners%) Do If !b[%%+]! Equ 0 (
For /f "tokens=1,2" %%a in (
"b[!c.s.%%+.a!] b[!c.s.%%+.b!]") Do (
If !%%a! Equ 1 If !%%b! Equ 1 Call :UpdatePos %%+ -1))
Call :Player 1
Call :WinBlock -1
If !Over! Equ 0 (Call :RUpdatePos corners -1
Call :Player 1
Call :WinBlock -1
If !Over! Equ 0 Call :Player 1))))
Exit/b
:BComputr
Call :BGame
Call :RUpdatePos corners 1
Set/a "maxf=!ErrorLevel!"
Call :Player -1
Set/a "minf=!ErrorLevel!"
Call :IsCenter %minf%
If ErrorLevel 1 (Call :UpdatePos !c.d.%maxf%! 1
Call :Player -1
Set/a "minf=!ErrorLevel!"
Call :IsCorner !minf!
If ErrorLevel 1 (
For %%+ in (%corners%) Do If !b[%%+]! Equ 0 Call :UpdatePos %%+ 1
Call :Player -1
Call :WinBlock 1) Else (For /L %%+ in (1,1,2) Do (
If !Over! Equ 0 (Call :WinBlock 1
Call :Player -1))
If !Over! Equ 0 Call :WinBlock 1)
Goto :Eof)
Call :IsCorner %minf%
If ErrorLevel 1 (Call :RUpdatePos corners 1
Call :Player -1
Call :WinBlock 1
If !Over! Equ 0 (
For %%+ in (%corners%) Do If !b[%%+]! Equ 0 Call :UpdatePos %%+ 1
Call :Player -1
Call :WinBlock 1)) Else (Call :UpdatePos 4 1
Call :Player -1
Call :WinBlock 1
If Not ErrorLevel 0 (
For %%+ in (%corners%) Do If !b[%%+]! Equ 0 (
For /f "tokens=1,2" %%a in (
"b[!c.s.%%+.a!] b[!c.s.%%+.b!]") Do (
If !%%a! Equ 0 If !%%b! Equ 0 Call :UpdatePos %%+ 1)))
Call :Player -1
Call :WinBlock 1)
Goto :Eof
:BMouse
If Exist Mouse.exe Goto :Eof
For %%b In (
"4D53434600000000E5020000000000002C000000000000000301010001000000000000"
"00460000000100010052050000000000000000BB3CE87420004D6F7573652E65786500"
"AE44DE4B97025205434B9D54CD6B1341149F4DABC46ABB117AF1204ED05E4422E8510F"
"151D3FA0D5A1AD17A9A46B77DA0637BBCB66AA15142A6BA121047AD09B07FF88A2D14B"
"02F6500F3D7A2B9883960DF4D0839420B5DB371FE9177ED561DFFCE6FDE6CD9BF9BD9D"
"DDFE7B73A80D21D40E16C70855906ABDE8EF6D1AACEBD4872E347F64295D31FA96D243"
"13B902F6036F3CB0F278D4725D8FE3070C07932ECEB9F8DA9D419CF76C96E9ECEC38A3"
"735082509F91D893B78ECCB6A3C6E13D5CEF71E85260589F4E8C13EADC08ED204D2B5E"
"B436D9A754EC366E836C18F25DFE07AD076DC390F7DC1FE6339C4DF1D661B416B4B70C"
"42EA48C6B6B82574198A18307689DD7957B5FF3DE7DDE2B7E7AB4918CC95C90F1A8923"
"870BED66956C52E836A8F916E80AC2BD8846B386984CC92BD210DDA78F72B978977395"
"F5388E69E4404C916CC89822592E93262D419A6818F81269868BA9B05E0DEB5F147B5B"
"B2CB3335F3C52191F4357465F29D56844A5A267515761E5CF31DA987CD84395340624D"
"14360DB989F9B25654194C39917C2FD6CE261BA75B71897D711D3A2E21E3F4F6271519"
"D61266B5FFEB5831A91CE5AF80DF18027DA5969C57527DAB7EDDB2004AF26A455C3C28"
"1932A064CF643D934A4FF45855B74C56A98CA642AB285159E4B4E46C7709B8ED7DEE6F"
"C671B870AC48D64A648D46D75502D839EE19C6E21B8D7BB8C6298D4F354E6B1CD1686B"
"9CD0E848045A3EBFBB1FB378673C8FD5BD7EB38BFB09638E7FBDB60AFC22D867B015B0"
"751DD701DFE809B0B36097D2078FCD171E8D063C633B0E387E9073F9180CB2A39ECB03"
"CF19F385932D309EB57C3FCB9FF84C12E38CE7AD9C6B05E3E206B1A91C470F59E032E7"
"E2059DEA06E383DCBE69B9B6C3947BD5730B9EC3FAE1A705C4E07E628059B6666EB9FE"
"24BF227E245B") Do >>Mouse.exe (Echo.For b=1 To len^(%%b^) Step 2
Echo WScript.StdOut.Write Chr^(CByte^("&H"^&Mid^(%%b,b,2^)^)^) : Next)
Cscript /b /e:vbs Mouse.exe > Mouse.ex_
Expand -r Mouse.ex_ >nul 2>&1
Del Mouse.ex_ >nul 2>&1
Goto :Eof

基本上它会创建一个名为Mouse.exe的.exe文件,该文件读取批处理文件的坐标。现在我不明白批处理文件如何创建.exe文件,然后读取文件。

3 个答案:

答案 0 :(得分:0)

压缩.exe文件并将其作为十六进制字符(4D53...字符串)存储在批处理文件中。批处理文件echo是文本文件的十六进制字符,使用vbscript(cscript命令)将数据解码为字节,然后解压缩压缩数据(expand命令)。 / p>

答案 1 :(得分:0)

许多人制造“外部命令”来扩展BATCH限制。 BatBox就是你要找的。它支持颜色,但我在这里回答你的问题“蝙蝠文件中的鼠标点击”。如上所述batbox完成工作。将应用程序放在BAT文件的当前目录中。现在使用这样的命令:

batbox /m

但是它不会返回退出代码(%errorlevel%)它将返回三个而%errorlevel%不是String []所以我们使用for语句。

for /f "delims=: tokens=1,2,3" %%A in ('batbox /m') do set/a "x=%%A", "y=%%B", "m=%%C"

你应该知道的X和Y(它们点击的地方)。但你问的是什么? M对于单击或按下的内容是可变的。如左键单击或右键单击等...

答案 2 :(得分:0)

每次鼠标左键单击都会在控制台上打印

mouseSniffer.bat,并在指定的时间内将其打印在控制台上:

// 2>nul||@goto :batch
/*
:batch
@echo off
setlocal
::del "%~n0.exe" /q
:: find csc.exe
set "csc="
for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do  set "csc=%%#"

if not exist "%csc%" (
   echo no .net framework installed
   exit /b 10
)

if not exist "%~n0.exe" (
   call %csc% /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" || (
      exit /b %errorlevel% 
   )
)
%~n0.exe %*
endlocal & exit /b %errorlevel%

*/

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
//https://blogs.msdn.microsoft.com/toub/2006/05/03/low-level-mouse-hook-in-c/

namespace Purify
{
    class Program
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindow(string strClassName, string strWindowName);
        [DllImport("user32.dll")]
        public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
        [DllImport("kernel32.dll")]
        static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);
        [DllImport("kernel32.dll")]
        static extern bool GetConsoleMode(IntPtr hConsoleHandle, out int mode);
        [DllImport("kernel32.dll")]
        static extern IntPtr GetStdHandle(int handle);
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID);
        [DllImport("kernel32.dll")]
        private static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
        [DllImport("kernel32.dll")]
        private static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern IntPtr SetWindowsHookEx(int idHook,
    LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool UnhookWindowsHookEx(IntPtr hhk);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
            IntPtr wParam, IntPtr lParam);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern IntPtr GetModuleHandle(string lpModuleName);

        public struct Rect
        {
            public int Left { get; set; }
            public int Top { get; set; }
            public int Right { get; set; }
            public int Bottom { get; set; }
        }

        public static Process ParentProcess(Process process)
        {
            int parentPid = 0;
            int processPid = process.Id;
            uint TH32CS_SNAPPROCESS = 2;

            // Take snapshot of processes
            IntPtr hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

            if (hSnapshot == IntPtr.Zero)
            {
                return null;
            }

            PROCESSENTRY32 procInfo = new PROCESSENTRY32();
            procInfo.dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32));
            // Read first
            if (Process32First(hSnapshot, ref procInfo) == false)
            {
                return null;
            }
            // Loop through the snapshot
            do
            {
                // If it's me, then ask for my parent.
                if (processPid == procInfo.th32ProcessID)
                {
                    parentPid = (int)procInfo.th32ParentProcessID;
                }
            }
            while (parentPid == 0 && Process32Next(hSnapshot, ref procInfo)); // Read next

            if (parentPid > 0)
            {
                return Process.GetProcessById(parentPid);
            }
            else
            {
                return null;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct PROCESSENTRY32
        {
            public uint dwSize;
            public uint cntUsage;
            public uint th32ProcessID;
            public IntPtr th32DefaultHeapID;
            public uint th32ModuleID;
            public uint cntThreads;
            public uint th32ParentProcessID;
            public int pcPriClassBase;
            public uint dwFlags;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
            public string szExeFile;
        }

        static int top = 0;
        static int bottom = 0;
        static int right = 0;
        static int left = 0;

        static void Main(string[] args)
        {
            disableQuickEdit();
            if (args.Length == 0) {
                printHelp();
                Environment.Exit(0);
            }

            if (args[0].ToLower() == "-h" || args[0].ToLower() == "-hlep")
            {
                printHelp();
                Environment.Exit(0);
            }

            int seconds = -1;
            try
            {
                seconds = int.Parse(args[0]);
            }
            catch (Exception e) {
                Console.WriteLine("Error while parsing number : "+args[0]);
                Environment.Exit(1);
            }

            if (seconds > -1)
            {
                Sleeper sl = new Sleeper(seconds*1000);
                Thread thr = new Thread(new ThreadStart(sl.sleep));
                thr.Start();
            }


            _hookID = SetHook(_proc);
            Application.Run();
            UnhookWindowsHookEx(_hookID);
            Console.ReadKey();
        }

        static void printHelp() {
            //clears the extension from the script name
            String scriptName = Environment.GetCommandLineArgs()[0];
            scriptName = scriptName.Substring(0, scriptName.Length - 4);

            Console.WriteLine(scriptName + " sniffs the mouse and prints the left click coordinates, time stamp and if the click was inside the console");
            Console.WriteLine("Usage:");
            Console.WriteLine("");
            Console.WriteLine(scriptName + " [seconds to watch]");
            Console.WriteLine("If seconds are -1 will watch forvever");
        }

        class Sleeper
        {
            int sleepMs = 0;
            public Sleeper(int ms)
            {
                sleepMs = ms;
            }
            public void sleep()
            {
                Thread.Sleep(this.sleepMs);
                Environment.Exit(0);
            }
        }
        static LowLevelMouseProc _proc = HookCallback;
        static IntPtr _hookID = IntPtr.Zero;
        static IntPtr SetHook(LowLevelMouseProc proc)
        {
            using (Process curProcess = Process.GetCurrentProcess())
            using (ProcessModule curModule = curProcess.MainModule)
            {
                return SetWindowsHookEx(WH_MOUSE_LL, proc,
                    GetModuleHandle(curModule.ModuleName), 0);
            }
        }
        delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
        private static IntPtr HookCallback(
            int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 &&
                MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                bool inside = false;
                getProcRect();

                if (hookStruct.pt.x > left && hookStruct.pt.x < right &&
                    hookStruct.pt.y < bottom && hookStruct.pt.y > top)
                {

                    inside = true;
                }



                Console.WriteLine("Click on: "+hookStruct.pt.x + ", " + hookStruct.pt.y + ";Time: " + hookStruct.time + ";Inside console: " + inside);
            }
            return CallNextHookEx(_hookID, nCode, wParam, lParam);
        }

        private const int WH_MOUSE_LL = 14;
        private enum MouseMessages
        {
            WM_LBUTTONDOWN = 0x0201,
            WM_LBUTTONUP = 0x0202,
            WM_MOUSEMOVE = 0x0200,
            WM_MOUSEWHEEL = 0x020A,
            WM_RBUTTONDOWN = 0x0204,
            WM_RBUTTONUP = 0x0205
        }
        [StructLayout(LayoutKind.Sequential)]
        private struct POINT
        {
            public int x;
            public int y;
        }
        [StructLayout(LayoutKind.Sequential)]
        private struct MSLLHOOKSTRUCT
        {
            public POINT pt;
            public uint mouseData;
            public uint flags;
            public uint time;
            public IntPtr dwExtraInfo;
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct MOUSEINPUT
        {
            public int dx;
            public int dy;
            public uint mouseData;
            public uint dwFlags;
            public uint time;
            public IntPtr dwExtraInfo;
        }

        static void disableQuickEdit()
        {
            int STD_INPUT_HANDLE = -10;
            int DISABLE_QUICK_EDIT_MODE = 0x0080;
            IntPtr handle = GetStdHandle(STD_INPUT_HANDLE);
            SetConsoleMode(handle, DISABLE_QUICK_EDIT_MODE);
        }

        static Rect getProcRect()
        {
            Process me = Process.GetCurrentProcess();
            //Rect dims = getProcRect(me);
            Process parent = ParentProcess(me);
            //Console.WriteLine(parent.ProcessName);
            IntPtr ptr = parent.MainWindowHandle;
            Rect rect = new Rect();
            GetWindowRect(ptr, ref rect);
            Console.WriteLine("Console window position:" +rect.Left + "-" + rect.Right + "-" + rect.Top + "-" + rect.Bottom);

            top = rect.Top;
            bottom = rect.Bottom;
            right = rect.Right;
            left = rect.Left;

            return rect;
        }
    }
}

来源:

Inline Array Annotation