12th program on Taskbar Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sir MR potatohead
Posts: 13
Joined: 16 Jan 2024, 22:31

12th program on Taskbar

24 Jan 2024, 00:50

I wrote this but seems wrong. It does open the 12th item on taskbar, but if I am in a text document, it types a " in there too

Code: Select all

 
^q::
Send "#{t}{Home}{Right 11}{Enter}"
return
How do I do it?
gregster
Posts: 9114
Joined: 30 Sep 2013, 06:48

Re: 12th program on Taskbar  Topic is solved

24 Jan 2024, 01:42

In AHK v1, you wouldn't quote the string (as long as you don't force an expression with %).
(In AHK v2, that would be different, of course.)
Sir MR potatohead
Posts: 13
Joined: 16 Jan 2024, 22:31

Re: 12th program on Taskbar

24 Jan 2024, 12:52

Thanks. Yes , now it works normal. But how would you write it if you were to make such a shortkey?? I mean I have no knowledge of scripting, just started 2 weeks ago playing with AHK, still, my script looks silly to me :think: I am sure there are better ways to run the 12th,13th,14th,.... app on taskbar.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

26 Jan 2024, 16:48

Sir MR potatohead wrote:
24 Jan 2024, 12:52
Thanks. Yes , now it works normal. But how would you write it if you were to make such a shortkey?? I mean I have no knowledge of scripting, just started 2 weeks ago playing with AHK, still, my script looks silly to me :think: I am sure there are better ways to run the 12th,13th,14th,.... app on taskbar.
In my opinion, you have already found the best way to do that. There is an alternate method but it requires getting X,Y coordinates of the application in question. For example, this script launches MS Word on my PC.

Code: Select all

CoordMode, Mouse, Screen
Click, 834, 1068
ExitApp
My taskbar is located on the bottom of the screen. If your taskbar is located in a different area of the screen, the X,Y coordinates would be vastly different.

For your 12th program located on your taskbar, you can get the exact X,Y coordinates using WindowSpy which is built into AutoHotKey program. Additionally, make sure you specify the appropriate coordinate mode in your script for clicking on the correct icon on the taskbar as I have done so in the very first line of my example above.
Sir MR potatohead
Posts: 13
Joined: 16 Jan 2024, 22:31

Re: 12th program on Taskbar

26 Jan 2024, 20:49

this Coordination thing is probable better. The bug with my script is that if the 13th app is not open, then the "12 t" is going to open something else. For example if I have 11 apps on the taskbar, this script presses T 12 times and it will open the 3rd item on taskbar. Still I believe there must be a specific script to play with the taskbar. thanks for the idea anyways
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

16 Feb 2024, 20:44

Sir MR potatohead wrote:
26 Jan 2024, 20:49
this Coordination thing is probable better.
I don't think you understand the example script I provided for you above. **CoordMode** is short for coordinate mode, not coordination. So in the example I provided for you, it tells AHK where to click relative to the screen. You should look through the AHK help files for more details on what this does.
Sir MR potatohead wrote:
26 Jan 2024, 20:49
For example if I have 11 apps on the taskbar, this script presses T 12 times and it will open the 3rd item on taskbar. Still I believe there must be a specific script to play with the taskbar. thanks for the idea anyways.
This absolutely no sense whatsoever. I don't even know what you're trying to say. It doesn't matter how many applications you have on your taskbar. All you have to do is just send the right arrow key the appropriate number of times to launch it.

For example, if you want to launch 11th application on the taskbar, then just send the right arrow key 11 times just like you have in your original script.

Code: Select all

^q::
Send "#{t}{Right 11}{Home}{Enter}"
return
By the way, sending the Home key is completely unnecessary.

Accordingly, if you you want to launch the 8th applications on the taskbar, you would send the right arrow key 8 times. If that 8th application happens to be already open, then you can send shift and Enter like so:

Code: Select all

^q::
Send "#{t}{Right 8}+{Enter}"
return
EDIT:

2 small corrections you need to make in your original script. 1) You need a comma , after Send.
2) You do not need quotation marks after your Send parameter.

Code: Select all

^q::
Send, #{t}{Right 8}+{Enter}
return
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

17 Feb 2024, 22:21

M4verick wrote: You need a comma , after Send.
The comma is optional except for a few exceptions, of which this is not one. See Commands.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

17 Feb 2024, 23:04

boiler wrote:
17 Feb 2024, 22:21
M4verick wrote: You need a comma , after Send.
The comma is optional except for a few exceptions, of which this is not one. See Commands.
That's odd because I tested the script both with and without the comma and got different results.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

17 Feb 2024, 23:10

Post what different results you got with only that change when run as a v1 script both times.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

17 Feb 2024, 23:34

boiler wrote:
17 Feb 2024, 23:10
Post what different results you got with only that change when run as a v1 script both times.
Using the script provided by the OP, I added the comma and deleted the Home key.

Code: Select all

^q::
Send, #{t}{Right 8}+{Enter}
return
The 8th icon on my Windows taskbar is Windows Notepad. When I run the script with the comma, it works perfectly.

When I run it without the comma, it launches the 6th icon which is a completely different program altogether.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

18 Feb 2024, 00:02

Make sure you have the same number of windows represented in the taskbar each time, including the number of Notepad windows.
loopernow
Posts: 27
Joined: 17 Mar 2019, 14:18

Re: 12th program on Taskbar

18 Feb 2024, 00:37

M4verick wrote:
17 Feb 2024, 23:34

Code: Select all

^q::
Send, #{t}{Right 8}+{Enter}
return
The 8th icon on my Windows taskbar is Windows Notepad. When I run the script with the comma, it works perfectly.
For the first 10 apps in your taskbar, you don't need to press Windows-T, arrow over a certain number of times, and press Enter. Instead, you can just press the Windows key and any single digit from 0 to 9 to focus any one of the first ten apps in your taskbar.

I'm using AutoHotkey similarly to you, I think, but the hotkeys emulate pressing the Windows key plus a number, instead of mimicking Windows-T plus arrowing over:

Code: Select all

; pin Windows apps to taskbar then open/focus them with
; mnemonic shortcuts instead of built-in Win-number
; Win-E N T F H | Explorer Notepad Typora Firefox Thunderbird
; With ad'l modifiers (Ctrl/Shift/Alt), ad'l/alt. functionality
#E::Send {Blind}#1
#N::Send {Blind}#2
#T::Send {Blind}#3
#F::Send {Blind}#4
#H::Send {Blind}#5
+#E::Send {Blind}+#1
+#N::Send {Blind}+#2
+#T::Send {Blind}+#3
+#F::Send {Blind}+#4
+#H::Send {Blind}+#5
^#E::Send {Blind}^#1
^#N::Send {Blind}^#2
^#T::Send {Blind}^#3
^#F::Send {Blind}^#4
^#H::Send {Blind}^#5
!#E::Send {Blind}!#1
!#N::Send {Blind}!#2
!#T::Send {Blind}!#3
!#F::Send {Blind}!#4
!#H::Send {Blind}!#5
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

18 Feb 2024, 13:24

boiler wrote:
18 Feb 2024, 00:02
Make sure you have the same number of windows represented in the taskbar each time, including the number of Notepad windows.
I have no idea what you mean by this. We're talking about using the right arrow key to highlight the desired application on the taskbar. The number of Notepad windows that are open when I run this script has no relevance. Can you please clarify your comment?
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

18 Feb 2024, 13:44

M4verick wrote: I have no idea what you mean by this. We're talking about using the right arrow key to highlight the desired application on the taskbar. The number of Notepad windows that are open when I run this script has no relevance. Can you please clarify your comment?
I’m saying that I can’t reproduce your problem. It works exactly the same whether there is a comma or not. And you say you are using it to select the Notepad icon. When I do that, it opens another instance, thus changing the number of icons on the taskbar, causing it to act differently the next time (at least with my taskbar settings where it groups icons of the same application). So I was just saying to make sure the number of icons is the same when you try it one way vs. another. In that sense, it is directly relevant.

Again, I don’t see any reason why the presence of the optional comma should make a difference, and it indeed doesn’t for me, so I’m trying to identify what else might be causing it to behave differently.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

18 Feb 2024, 13:55

boiler wrote:
18 Feb 2024, 13:44
M4verick wrote: I have no idea what you mean by this. We're talking about using the right arrow key to highlight the desired application on the taskbar. The number of Notepad windows that are open when I run this script has no relevance. Can you please clarify your comment?
I’m saying that I can’t reproduce your problem. It works exactly the same whether there is a comma or not. And you say you are using it to select the Notepad icon. When I do that, it opens another instance, thus changing the number of icons on the taskbar, causing it to act differently the next time (at least with my taskbar settings where it groups icons of the same application). So I was just saying to make sure the number of icons is the same when you try it one way vs. another. In that sense, it is directly relevant.

Again, I don’t see any reason why the presence of the optional comma should make a difference, and it indeed doesn’t for me, so I’m trying to identify what else might be causing it to behave differently.
When I tested the OP's script without the comma, it had the undesired effect of launching the 6th icon on the taskbar instead of the 8th. Just to be clear about this, the number of Notepad windows that were open at the time the script was executed had no bearing on this. 1 Notepad window versus 10 of them - it still launched the WRONG application.

However, when I run it with the comma, it has the correct desired effect on my computer. Again, like the previous situation, the number of Notepad windows that were open at the time had no bearing.

Using Win7 64-bit.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

18 Feb 2024, 14:41

M4verick wrote: When I tested the OP's script without the comma, it had the undesired effect of launching the 6th icon on the taskbar instead of the 8th.
OP’s original script didn’t only have a comma wrong with it. It also had quotation marks that don’t belong. As I asked before, are you running two scripts where the only difference is the comma? And there is only one script running, as opposed to both possibly running at the same time?

Also as I said before, the number of Notepad windows would have a bearing if it changed the total count/relative position of your icons, and I’m only suggesting that because I’m trying to search for reasons why the script would be behaving differently because it doesn’t make sense that the comma alone would cause the difference. I can’t see your screen so I’m only speculating.

I'm just trying to figure out why this is occurring, not trying to be confrontational. Either there is something else going on, or it suggests that there is an AHK bug. Before concluding the latter, it needs to confirmed by more than one user. So far, we only have one user (you) that has reported this. I haven't been able to reproduce the issue. Perhaps someone else can try to do so.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

19 Feb 2024, 22:03

boiler wrote:
18 Feb 2024, 14:41
OP’s original script didn’t only have a comma wrong with it. It also had quotation marks that don’t belong.
I know that the quotation marks that don't belong. I told him that already.

boiler wrote:
18 Feb 2024, 14:41
As I asked before, are you running two scripts where the only difference is the comma? And there is only one script running, as opposed to both possibly running at the same time?
I don't recall you asking that question. I have reviewed your comments in this thread and I don't see where you asked that - it's possible I missed it. Just to be clear about this - I am not running 2 different version of the OP's script at the same time. I am an AHK novice but I am not stupid enough to do that sort of thing. I tested 1 version without the comma and I tested another version with the comma. 1 AT A TIME. To be even more clear about this - I completely exited one script when I was done testing and then I loaded the 2nd version afterwards to test.

boiler wrote:
18 Feb 2024, 14:41
Also as I said before, the number of Notepad windows would have a bearing if it changed the total count/relative position of your icons,
It has no bearing. I don't know why you insist that it does. Using Notepad as an example, Notepad will ALWAYS be the 8th icon on my taskbar unless of course I change the order of the icons on the taskbar. See screenshot.

taskbar.png
taskbar.png (36.02 KiB) Viewed 472 times
Therefore, the script that I posted above works perfectly regardless of there is just 1 or 10 Notepad windows open at the time the script is executed.

Code: Select all

^q::
Send, #{t}{Right 8}+{Enter}
return
EDIT:

To clarify - I have the taskbar icons grouped together so that whether I have 1 Notepad window open or 10 of them, they're all grouped together under the main Notepad icon on the taskbar.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: 12th program on Taskbar

19 Feb 2024, 23:42

M4verick wrote:
boiler wrote:
18 Feb 2024, 14:41
As I asked before, are you running two scripts where the only difference is the comma? And there is only one script running, as opposed to both possibly running at the same time?
I don't recall you asking that question. I have reviewed your comments in this thread and I don't see where you asked that - it's possible I missed it.
Not that it’s important, but to clarify: The part in red is what I meant by having asked that before — not the next sentence.

M4verick wrote: I am an AHK novice but I am not stupid enough to do that sort of thing. I tested 1 version without the comma and I tested another version with the comma. 1 AT A TIME. To be even more clear about this - I completely exited one script when I was done testing and then I loaded the 2nd version afterwards to test.
I’ve helped a lot of people find the source of issues they couldn’t explain, and these kinds of things happen all the time, and it sometimes is the sole issue. When it does happen, I don’t consider them to be stupid. It just happens, so I checked. Apparently, you are taking my attempts to eliminate potential causes of the issue other than the presence of the “optional” comma personally, so I won’t pursue it anymore. If anyone else can reproduce the issue, then I suggest posting it in the Bug Reports section, even though it is now primarily meant for v2 bugs, since it would be behavior inconsistent with the documentation.
User avatar
V0RT3X
Posts: 249
Joined: 20 May 2023, 21:59
Contact:

Re: 12th program on Taskbar

20 Feb 2024, 10:24

Just my 2 cents...
When I run the below code (with the number changed to the 6th taskbar icon for my instance of notepad), it works exactly the same regardless if I use the comma or not.
It also is irrelevant to my system if I have one or twelve of the notepad icons open, it stays consistent and just keeps doing as expected opening another notepad instance.
For my system, the icons are grouped. My only issue appears to be that the Brave icon isn't even recognized by this small code piece, so although the notepad icon is actually the 7th, I have to call it the 6th.
To me that is odd considering if I use the built in shortcut key Win+1 it sees Brave just fine. Other than that, this appears to work as it should.

image.png
image.png (23.63 KiB) Viewed 442 times

Code: Select all

^q::
Send, #{t}{Right 6}+{Enter}
return

Windows 10 Home
22H2
19045.4046
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: 12th program on Taskbar

21 Feb 2024, 21:32

boiler wrote:
19 Feb 2024, 23:42
I’ve helped a lot of people find the source of issues they couldn’t explain, and these kinds of things happen all the time, and it sometimes is the sole issue. When it does happen, I don’t consider them to be stupid. It just happens, so I checked. Apparently, you are taking my attempts to eliminate potential causes of the issue other than the presence of the “optional” comma personally, so I won’t pursue it anymore. If anyone else can reproduce the issue, then I suggest posting it in the Bug Reports section, even though it is now primarily meant for v2 bugs, since it would be behavior inconsistent with the documentation.
I don't doubt you have helped a lot of people, including myself in the past. My only frustration with you is that keep insisting the number of Notepad windows running has a direct bearing on the scripting working correctly or not. Doesn't even seem like you've tested the script yourself on your end! The other possibility is that you don't have your icons grouped together on the taskbar in which case if you have 3 Notepad windows open, you're gonna see 3 Notepad icons (separately) on the taskbar which could possibly affect how the script runs. I also thought that I had explained clearly enough how I tested the two versions (1 with the comma, the other without comma). Apparently I did not explain it clearly enough. Either way, I'm done with the thread - I was just trying to help out the OP with his taskbar issue.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], bobstoner289, Chunjee, macromint, peter_ahk and 332 guests