-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevokeMouseInput.ps1
More file actions
35 lines (27 loc) · 996 Bytes
/
RevokeMouseInput.ps1
File metadata and controls
35 lines (27 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Issue 1886: Change text cursor position with LeftClick was not working
# when PSReadLine was loaded in your $profile.
# Following will remove ENABLE_MOUSE_INPUT from console input mode flags
# Just call this script at the end of your $profile.
# (C) 2015 ConEmu.Maximus5@gmail.com
Add-Type -PassThru '
using System;
using System.Runtime.InteropServices;
public class ConsoleWinApi {
[DllImport("kernel32.dll")]
static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")]
static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint dwMode);
[DllImport("kernel32.dll")]
static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
public static void RevokeMouseInput()
{
uint dwMode = 0;
IntPtr h = GetStdHandle(-10);
if (GetConsoleMode(h, out dwMode) && ((dwMode & 0x10) != 0))
{
SetConsoleMode(h, dwMode ^ 0x10);
}
}
}
' | Out-Null
[ConsoleWinApi]::RevokeMouseInput()