Pin to taskbar in Windows 10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RiRi Lopez

Pin to taskbar in Windows 10

26 Nov 2017, 09:43

Both methods here no longer work https://autohotkey.com/board/topic/73010-invokeverb/

What is the correct way to pin to taskbar in windows 10
User avatar
Micromegas
Posts: 260
Joined: 28 Apr 2015, 23:02
Location: Germany

Re: Pin to taskbar in Windows 10

27 Nov 2017, 13:49

Are you sure that page talks about pinning to the taskbar? I don't see that mentioned there.
RiRi Lopez

Re: Pin to taskbar in Windows 10

27 Nov 2017, 15:53

Micromegas wrote:Are you sure that page talks about pinning to the taskbar? I don't see that mentioned there.
you are correct here is the correct one https://autohotkey.com/board/topic/9389 ... utohotkey/

also i think its not possible in windows 10
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Pin to taskbar in Windows 10

27 Nov 2017, 16:00

This link suggests a method that may have worked on Windows 10, but that apparently no longer works.
Where is the list of pinned start menu and taskbar items stored in Windows 7 - Super User
https://superuser.com/questions/171096/ ... -windows-7

I have a slightly hacky workaround that uses Acc to pin WordPad to the taskbar, that works in Windows 7, it right-clicks the taskbar button and chooses 'Pin this program to taskbar' if available. So it's possible that that might work in Windows 10. It may be that the script needs to be modified slightly if the system language isn't English.

Code: Select all

;[Acc functions]
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

q:: ;explorer - pin WordPad to the taskbar (tested on Windows 7)
DetectHiddenWindows, Off
Run, wordpad.exe,,, vPID
WinWaitActive, % "ahk_pid " vPID
WinGet, vWinList, List, % "ahk_pid " vPID
oArray := {}
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	if !(vWinTitle = "")
		oArray["z" vWinTitle] := ""
}
ControlGet, hWnd, Hwnd,, MSTaskListWClass1, ahk_class Shell_TrayWnd
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
Loop, % oAcc.accChildCount
{
	vName := ""
	try vName := oAcc.accName(A_Index)
	if oArray.HasKey("z" vName)
	{
		oRect := Acc_Location(oAcc, A_Index)
		CoordMode, Mouse, Screen
		Click, % Format("R, {:i}, {:i}", oRect.x + oRect.w/2, oRect.y + oRect.h/2)
		;ToolTip, % Format("R, {:i}, {:i}", oRect.x + oRect.w/2, oRect.y + oRect.h/2)
		WinWaitActive, Jump List ahk_class DV2ControlHost
		ControlGet, hWnd, Hwnd,, SysListView321, Jump List ahk_class DV2ControlHost
		oAcc2 := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
		Loop, % oAcc2.accChildCount
		{
			vName := ""
			try vName .= oAcc2.accName(A_Index)
			;ToolTip, % A_Index " " vName
			;Sleep, 1000
			if (vName = "Pin this program to taskbar")
			{
				oAcc2.accDoDefaultAction(A_Index)
				break
			}
		}
		if (vName = "Pin this program to taskbar")
			break
	}
}
oAcc := oRect := oArray := ""
return
Some related code:
Move mouse to taskbar to use AeroPeek - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=27147
Explorer window interaction (folder windows/Desktop, file/folder enumeration/selection/navigation/creation) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35041
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
RiRi Lopez

Re: Pin to taskbar in Windows 10

27 Nov 2017, 16:42

jeeswg wrote:This link suggests a method that may have worked on Windows 10, but that apparently no longer works.
Where is the list of pinned start menu and taskbar items stored in Windows 7 - Super User
https://superuser.com/questions/171096/ ... -windows-7

I have a slightly hacky workaround that uses Acc to pin WordPad to the taskbar, that works in Windows 7, it right-clicks the taskbar button and chooses 'Pin this program to taskbar' if available. So it's possible that that might work in Windows 10. It may be that the script needs to be modified slightly if the system language isn't English.

Code: Select all

;[Acc functions]
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

q:: ;explorer - pin WordPad to the taskbar (tested on Windows 7)
DetectHiddenWindows, Off
Run, wordpad.exe,,, vPID
WinWaitActive, % "ahk_pid " vPID
WinGet, vWinList, List, % "ahk_pid " vPID
oArray := {}
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	if !(vWinTitle = "")
		oArray["z" vWinTitle] := ""
}
ControlGet, hWnd, Hwnd,, MSTaskListWClass1, ahk_class Shell_TrayWnd
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
Loop, % oAcc.accChildCount
{
	vName := ""
	try vName := oAcc.accName(A_Index)
	if oArray.HasKey("z" vName)
	{
		oRect := Acc_Location(oAcc, A_Index)
		CoordMode, Mouse, Screen
		Click, % Format("R, {:i}, {:i}", oRect.x + oRect.w/2, oRect.y + oRect.h/2)
		;ToolTip, % Format("R, {:i}, {:i}", oRect.x + oRect.w/2, oRect.y + oRect.h/2)
		WinWaitActive, Jump List ahk_class DV2ControlHost
		ControlGet, hWnd, Hwnd,, SysListView321, Jump List ahk_class DV2ControlHost
		oAcc2 := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
		Loop, % oAcc2.accChildCount
		{
			vName := ""
			try vName .= oAcc2.accName(A_Index)
			;ToolTip, % A_Index " " vName
			;Sleep, 1000
			if (vName = "Pin this program to taskbar")
			{
				oAcc2.accDoDefaultAction(A_Index)
				break
			}
		}
		if (vName = "Pin this program to taskbar")
			break
	}
}
oAcc := oRect := oArray := ""
return
Some related code:
Move mouse to taskbar to use AeroPeek - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=27147
Explorer window interaction (folder windows/Desktop, file/folder enumeration/selection/navigation/creation) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35041
does not work on windows 10, I even updated this to match how it reads on windows 10 (vName = "Pin to taskbar") (I have acc etc)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Pin to taskbar in Windows 10

27 Nov 2017, 16:57

- Plus, it's always worth running a script as admin just in case.
- I rarely if ever say, is this really worth automating, and indeed I thought it was sufficiently worthwhile that I made an attempt. However, typically, you only need to pin more than one item to the taskbar when you first get a PC, unless you're installing lots of PCs. So I'm curious if this is very important to you. So I'm asking out of interest, in case this is a major problem for you, but it doesn't have to be. I like to try and fix certain things just for the sake of it, even for tiny convenience gains, to understand things, or for the challenge, i.e. every little Explorer thing should ideally be automatable.
- In the worst case scenario, you could have a script that opens each window, you manually pin it and close it, it detects that the window has closed, and opens up the next window. E.g. use RunWait, or Run and WinWaitClose.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
RiRi Lopez

Re: Pin to taskbar in Windows 10

27 Nov 2017, 17:02

jeeswg wrote:- Plus, it's always worth running a script as admin just in case.
- I rarely if ever say, is this really worth automating, and indeed I thought it was sufficiently worthwhile that I made an attempt. However, typically, you only need to pin more than item to the taskbar when you first get a PC, unless you're installing lots of PCs. So I'm curious if this is very important to you.
- In the worst case scenario, you could have a script that opens each window, you manually pin it and close it, it detects that the window has closed, and opens up the next window.
it started off as a cool idea that after someone in my company installs the small program im making it auto pins it. It is not as important as the other parts of the program I am still working on :-)

thank you for your code, the acc part is very new to me
pop

Re: Pin to taskbar in Windows 10

12 Sep 2018, 06:56

The Solution I used was to make a copy of AutoHotkey.exe in the installed dir and rename it to something that Windows 10 allows to be pinned. I used AHKscripts.exe if you want to run the AutoHotkey.ahk script automatically when the taskbar pin is clicked, make a copy of AutoHotkey.ahk and rename it to the same filename as the AutoHotkey.exe copy (i.e. AHKscripts.ahk) you can also pin ahk scripts to this taskbar icon and right click to select.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 384 guests