Snipping Tool (default to new snip) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
seriously5OH

Snipping Tool (default to new snip)

Post by seriously5OH » 13 Jun 2018, 10:47

I found the following AHK code online at TenForums. It does not work. Any suggestions on making this code work to automatically open Snipping Tool and execute the New Snip function with one keyboard shortcut?

Code: Select all

#s::
IfWinExist Snipping Tool
	WinActivate
else
	Run "c:\windows\system32\SnippingTool.exe"
    WinWait,  Snipping Tool,,1
	ControlClick, x40 y40, Snipping Tool
return
User avatar
TLM
Posts: 1323
Joined: 01 Oct 2013, 07:52

Re: Snipping Tool (default to new snip)

Post by TLM » 13 Jun 2018, 15:46

this works for me

Code: Select all

#s::
if WinExist( "Snipping Tool" )
{
	ControlClick, x40 y40, Snipping Tool
}
else 
{
	Run SnippingTool.exe /clip
}
return
JoeWinograd
Posts: 1056
Joined: 10 Feb 2014, 20:00

Re: Snipping Tool (default to new snip)

Post by JoeWinograd » 13 Jun 2018, 16:03

This thread at another forum where I participate may help you:
Restore Windows 7 Snipping Tool function to Windows 10
Regards, Joe
iseahound
Posts: 307
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Snipping Tool (default to new snip)

Post by iseahound » 13 Jun 2018, 16:13

Windows 7/10 compatible

Code: Select all

#s::
   if WinExist("Snipping Tool"){
      WinActivate
      Send, ^n
   } else {
      try
         Run C:\Windows\SysNative\SnippingTool.exe
      catch {
         Run %A_WinDir%\System32\SnippingTool.exe
         WinWaitActive, Snipping Tool
         Send, ^n
      }
   }
   return
If you're on windows 10, the built in hotkey is #+s.
FanaticGuru
Posts: 1192
Joined: 30 Sep 2013, 22:25

Re: Snipping Tool (default to new snip)

Post by FanaticGuru » 13 Jun 2018, 16:19

seriously5OH wrote:I found the following AHK code online at TenForums. It does not work. Any suggestions on making this code work to automatically open Snipping Tool and execute the New Snip function with one keyboard shortcut?

Code: Select all

#s::
IfWinExist Snipping Tool
	WinActivate
else
	Run "c:\windows\system32\SnippingTool.exe"
    WinWait,  Snipping Tool,,1
	ControlClick, x40 y40, Snipping Tool
return
Here is my script for accessing the Snipping Tool and Calculator easier.

Code: Select all

; Quick Tools
; Fanatic Guru
; 2017 09 18
;
; Shortcuts to bring up Windows Tools
;
;{-----------------------------------------------
; Window+X          Open/Activate/Minimize Windows Snipping Tool
; Window+Numpad 0   Open/Activate/Minimize Windows Calculator
;}

; INITIALIZATION - ENVIROMENT
;{-----------------------------------------------
;
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force  ; Ensures that only the last executed instance of script is running
;}

; HOTKEYS
;{-----------------------------------------------
;
#x::	; <-- Open/Activate/Minimize Windows Snipping Tool
{
	SetTitleMatchMode, % (Setting_A_TitleMatchMode := A_TitleMatchMode) ? "RegEx" :
	if WinExist("ahk_class Microsoft-Windows-.*SnipperToolbar")
	{
		WinGet, State, MinMax
		if (State = -1)
		{	
			WinRestore
			Send, ^n
		}
		else if WinActive()
			WinMinimize
		else
		{
			WinActivate
			Send, ^n
		}
	}
	else if WinExist("ahk_class Microsoft-Windows-.*SnipperEditor")
	{
		WinGet, State, MinMax
		if (State = -1)
			WinRestore
		else if WinActive()
			WinMinimize
		else
			WinActivate
	}
	else
	{
		Run, snippingtool.exe
		if (SubStr(A_OSVersion,1,2)=10)
		{
			WinWait, ahk_class Microsoft-Windows-.*SnipperToolbar,,3
			Send, ^n
		}
	}
	SetTitleMatchMode, %Setting_A_TitleMatchMode%
	return
}

#numpad0::	; <-- Open/Activate/Minimize Windows Calculator
{
	if WinExist("Calculator ahk_class CalcFrame") or WinExist("Calculator ahk_class ApplicationFrameWindow")
		if WinActive()
			WinMinimize
		else
			WinActivate
	else
		Run calc.exe
	return
}
;}
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
seriously5OH

Re: Snipping Tool (default to new snip)

Post by seriously5OH » 14 Jun 2018, 08:01

None of them work for me because WIN+S keeps bringing up Cortana search bar.
seriously5OH

Re: Snipping Tool (default to new snip)

Post by seriously5OH » 14 Jun 2018, 12:12

iseahound wrote:Windows 7/10 compatible

Code: Select all

#s::
   if WinExist("Snipping Tool"){
      WinActivate
      Send, ^n
   } else {
      try
         Run C:\Windows\SysNative\SnippingTool.exe
      catch {
         Run %A_WinDir%\System32\SnippingTool.exe
         WinWaitActive, Snipping Tool
         Send, ^n
      }
   }
   return
If you're on windows 10, the built in hotkey is #+s.
yes i am on windows 10 and even this code is not working because the win + S brings up Cortana search box.
seriously5OH

Re: Snipping Tool (default to new snip)  Topic is solved

Post by seriously5OH » 14 Jun 2018, 15:25

JoeWinograd wrote:This thread at another forum where I participate may help you:
Restore Windows 7 Snipping Tool function to Windows 10
Regards, Joe
Same problem ... win+S brings up Cortana search box, not Snipping Tool.
JoeWinograd
Posts: 1056
Joined: 10 Feb 2014, 20:00

Re: Snipping Tool (default to new snip)

Post by JoeWinograd » 14 Jun 2018, 16:41

Either stop Win+S from being a Cortana keyboard shortcut (a web search will show you how) or use another hotkey for the Snipping Tool. Note this comment at the link I gave you:

"Use whatever hotkey you want (the code above makes Win-S the Snipping Tool hotkey)."

Regards, Joe
FanaticGuru
Posts: 1192
Joined: 30 Sep 2013, 22:25

Re: Snipping Tool (default to new snip)

Post by FanaticGuru » 14 Jun 2018, 17:11

seriously5OH wrote:
JoeWinograd wrote:Same problem ... win+S brings up Cortana search box, not Snipping Tool.
You need to make sure you have the ability to create any hotkey with win+s.

You can test with this.

Code: Select all

#s::
	MsgBox Yes
return
For the record I have no problem making a win+s hotkey in Windows 10.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
seriously5OH

Re: Snipping Tool (default to new snip)

Post by seriously5OH » 15 Jun 2018, 13:01

It's my work computer at a large corporation. They won't let me do anything that requires admin login. Disabling the windows key requires admin. I will just choose another key combination. Thanks guys.

Control + Shift + S::
will this work?
JoeWinograd
Posts: 1056
Joined: 10 Feb 2014, 20:00

Re: Snipping Tool (default to new snip)

Post by JoeWinograd » 15 Jun 2018, 13:28

Control + Shift + S::
will this work?
Yes.
seriously5OH

Re: Snipping Tool (default to new snip)

Post by seriously5OH » 15 Jun 2018, 14:11

Error at line 6.

Line Text: Control+Shift+s::
Error: Invalid hotkey

The program will exit.

Code: Select all

Control+Shift+s::
   if WinExist("Snipping Tool"){
      WinActivate
      Send, ^n
   } else {
      try
         Run C:\Windows\SysNative\SnippingTool.exe
      catch {
         Run %A_WinDir%\System32\SnippingTool.exe
         WinWaitActive, Snipping Tool
         Send, ^n
      }
   }
   return
JoeWinograd
Posts: 1056
Joined: 10 Feb 2014, 20:00

Re: Snipping Tool (default to new snip)

Post by JoeWinograd » 15 Jun 2018, 14:28

You need to learn the correct syntax for keys and modifiers, which are documented here:
https://autohotkey.com/docs/KeyList.htm
https://autohotkey.com/docs/Hotkeys.htm#Symbols

After studying that, you'll know that the first line in your script should be this:

Code: Select all

^+s::
Regards, Joe
seriously5OH

Re: Snipping Tool (default to new snip)

Post by seriously5OH » 15 Jun 2018, 15:06

Ok i actually had looked at the first document. But now that i've done some reading on the second document i am on board. :) thanks for the help as i learn this program.

Thanks to all.
Post Reply

Return to “Ask For Help”