Last active
February 14, 2023 15:28
-
-
Save yuki-tkd/7a8b96db8201395d8c1af2b8fb2554bb to your computer and use it in GitHub Desktop.
Capture a screenshot on Windows using AutoHotKey with shortcut keys similar to macOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.Drawing, System.Windows.Forms | |
$jpegCodec = [Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object { $_.FormatDescription -eq "JPEG" } | |
Start-Sleep -Milliseconds 200 | |
[Windows.Forms.Sendkeys]::SendWait("{PrtSc}") | |
Start-Sleep -Milliseconds 200 | |
$bitmap = [Windows.Forms.Clipboard]::GetImage() | |
$ep = New-Object Drawing.Imaging.EncoderParameters | |
$ep.Param[0] = New-Object Drawing.Imaging.EncoderParameter ([System.Drawing.Imaging.Encoder]::Quality, [long]100) | |
$now = Get-Date -format "yyyy-MM-dd_HH-mm-ss" | |
$path = "$env:USERPROFILE\Desktop\ScreenShot_${now}.jpg" | |
$bitmap.Save($path, $jpegCodec, $ep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.Drawing, System.Windows.Forms | |
$jpegCodec = [Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object { $_.FormatDescription -eq "JPEG" } | |
Start-Sleep -Milliseconds 200 | |
[Windows.Forms.Sendkeys]::SendWait("%{PrtSc}") | |
Start-Sleep -Milliseconds 200 | |
$bitmap = [Windows.Forms.Clipboard]::GetImage() | |
$ep = New-Object Drawing.Imaging.EncoderParameters | |
$ep.Param[0] = New-Object Drawing.Imaging.EncoderParameter ([System.Drawing.Imaging.Encoder]::Quality, [long]100) | |
$now = Get-Date -format "yyyy-MM-dd_HH-mm-ss" | |
$path = "$env:USERPROFILE\Desktop\ScreenShot_${now}.jpg" | |
$bitmap.Save($path, $jpegCodec, $ep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ctrl + shift + 3 -> Capture screenshot of the screen | |
#if GetKeyState("LWin", "P") | |
Shift & 3::RunWait PowerShell.exe -ExecutionPolicy Unrestricted -File .\screenshot_all.ps1 ,, hide | |
; ctrl + shift + 4 -> Capture screenshot of an active window | |
#if GetKeyState("LWin", "P") | |
Shift & 4::RunWait PowerShell.exe -ExecutionPolicy Unrestricted -File .\screenshot_window.ps1 ,, hide |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment