Skip to content

Commit

Permalink
add DisableQuickEdit parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nephest committed Mar 7, 2024
1 parent 5d2b5bb commit 2e94bca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ start powershell ^

### Misc parameters
* `Race` The race you will be playing, lower case. Overrides auto detected race from SC2 Pulse. Useful if you want to change an account/region/race but don't want to wait for SC2 Pulse to catch up.
* `DisableQuickEdit` Disable console `QuickEdit` mode. Prevents users from accidently pausing the script by clicking on the console window.
* `Test` Test mode for devs. Replaces your name with a barcode and allows you to test the script in a custom/vs ai game.
11 changes: 7 additions & 4 deletions Reveal-Sc2Opponent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ param(
[string[]]$ActiveRegion = @("us", "eu", "kr"),
[string]$FilePath,
[switch]$Notification,
[switch]$DisableQuickEdit,
[switch]$Test
)

Expand All @@ -59,15 +60,17 @@ param(
disable console quick edit mode to prevent the user from accidentally
pausing the script by clicking on it
#>
Add-Type -MemberDefinition @"
if($DisableQuickEdit) {
Add-Type -MemberDefinition @"
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr GetStdHandle(int handle);
"@ -Namespace Win32 -Name NativeMethods
$Handle = [Win32.NativeMethods]::GetStdHandle(-10)
[Win32.NativeMethods]::SetConsoleMode($Handle, 0x0080)
Write-Verbose "Disabled console quick edit"
$Handle = [Win32.NativeMethods]::GetStdHandle(-10)
[Win32.NativeMethods]::SetConsoleMode($Handle, 0x0080)
Write-Verbose "Disabled console quick edit"
}

Test-ScriptFileInfo $PSCommandPath

Expand Down

0 comments on commit 2e94bca

Please sign in to comment.