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

Post your working scripts, libraries and tools
delseyyy
Posts: 5
Joined: 01 Jan 2018, 17:00

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

24 May 2018, 10:50

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
}
swagfag
Posts: 3063
Joined: 11 Jan 2017, 17:59

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

24 May 2018, 12:28

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
}

Return to “Scripts and Functions”

Who is online

Users browsing this forum: wineguy and 100 guests