Page 1 of 1

Extremely simple script to make Windows SnippingTool a bit more satisfying to use

Posted: 24 May 2018, 10:50
by delseyyy

Code: Select all

PrintScreen::
Run, "SnippingTool.exe" ,, min
WinWait, Snipping Tool
ControlSend, , !{n}, ahk_class Microsoft-Windows-SnipperToolbar
This works on Win10. If your Win can't find the .exe look up THIS thread.

Edit: I updated it so that by hitting escape, it closes the snipping-screen.
Edit2: Updated again to use CTRL+N instead of Alt+N because in some cases, it triggered the Alt-Accel.

Code: Select all

PrintScreen::openSnippingTool()
Esc::closeSnippingToolByEscape()

openSnippingTool(){
Run, "SnippingTool.exe" ,, min
WinWait, Snipping Tool
ControlSend,, ^{n}, ahk_class Microsoft-Windows-SnipperToolbar
}

closeSnippingToolByEscape(){
#IfWinActive ahk_class Microsoft-Windows-SnipperToolbar
WinClose ahk_class Microsoft-Windows-SnipperToolbar
}

Re: Extremely simple script to make Windows SnippingTool a bit more satisfying to use

Posted: 24 May 2018, 12:28
by swagfag
purely as an addendum to this, on win10 you can press Win+Shift+S to trigger clipping mode, which will save the snip to your Clipboard.

If you wanna save it to a file instead, using some GDI+ u could do the following:

Code: Select all

#NoEnv
#SingleInstance Force
SetBatchLines -1
SetWorkingDir %A_ScriptDir%

; https://github.com/mmikeww/AHKv2-Gdip/blob/master/Gdip_All.ahk
#Include Gdip_All.ahk

pToken := Gdip_Startup()
fileName := A_Now ".PNG"
OnExit("CleanUp")
Esc::ExitApp

q::
{
	Clipboard := ""
	Run % A_WinDir "\system32\SnippingTool.exe /clip"
	ClipWait, , 1
	pBitmap := Gdip_CreateBitmapFromClipboard()
	Gdip_SaveBitmapToFile(pBitmap, fileName)
	Gdip_DisposeImage(pBitmap)
return
}

CleanUp(pToken) {
	if (pBitmap)
		Gdip_DisposeImage(pBitmap)
	Gdip_Shutdown(pToken)
	ExitApp
}