Changing window app position on taskbar

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pickone
Posts: 16
Joined: 30 Sep 2017, 10:02

Changing window app position on taskbar

19 Sep 2022, 06:08

Hi everyone!

I am trying to make a script which can help me to reorder position of 5 apps, if the apps are opened.
I want to have this order always, on the taskbar:

1. total commander
2. firefox
3. outlook
4. whatsapp
5. teamviewer

All good if all the apps are opened, but what if some of the apps are not opened, how the script will know which is opened and which is not, then... how to give the proper position of some of the apps, if the other are not opened, withtout making an 10.000 lines script of IFs

Here is where I got stuck

Code: Select all

CoordMode Pixel, Screen
CoordMode Mouse, Screen

Gui +LastFound 
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,Hwnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

first := 100
second := 270
third := 430
forth := 600
fifth := 750

ShellMessage( wParam,lParam )
{
If(wParam = 4 OR wParam = 32772) 
{

pos1 := 0
pos2 := 0
pos3 := 0
pos4 := 0
pos5 := 0

low := 0
high := 0

if WinExist("ahk_class TTOTAL_CMD") && WinExist("ahk_exe TOTALCMD64.EXE")
pos1 := 1
if WinExist("ahk_class MozillaWindowClass") && WinExist("ahk_exe firefox.exe")
pos2 := 1
if WinExist("ahk_class rctrl_renwnd32") && WinExist("ahk_exe OUTLOOK.EXE")
pos3 := 1
if WinExist("ahk_class Chrome_WidgetWin_1") && WinExist("ahk_exe WhatsApp.exe")
pos4 := 1
if WinExist("ahk_class MainWindowFull") && WinExist("ahk_exe TeamViewer.exe")
pos5 := 1

order = %pos1%%pos2%%pos3%%pos4%%pos5%

if order = 10000
{
total := %first%
low := 50
high := 100
}

ImageSearch, x, y, 50, 1399, 1774, 1439, c:\Programe Instalate\TotalCommander.png
if x not between %low% and %high%
{
BlockInput, MouseMove
MouseGetPos, xnow, ynow
MouseClickDrag, left, %x%, %y%, %total%, %y%, 0
MouseMove, xnow, ynow, 0
BlockInput, MouseMoveOff
}

ImageSearch, x, y, 50, 1399, 1774, 1439, c:\Programe Instalate\Firefox.png
if x not between 215 and 250 
{
BlockInput, MouseMove
MouseGetPos, xnow, ynow
MouseClickDrag, left, %x%, %y%, %fire%, %y%, 0
MouseMove, xnow, ynow, 0
BlockInput, MouseMoveOff
}

ImageSearch, x, y, 50, 1399, 1774, 1439, c:\Programe Instalate\Outlook.png
if x not between 280 and 410 
{
BlockInput, MouseMove
MouseGetPos, xnow, ynow
MouseClickDrag, left, %x%, %y%, %out%, %y%, 0
MouseMove, xnow, ynow, 0
BlockInput, MouseMoveOff
}

ImageSearch, x, y, 50, 1399, 1774, 1439, c:\Programe Instalate\Whatsapp.png
if x not between 535 and 570 
{
BlockInput, MouseMove
MouseGetPos, xnow, ynow
MouseClickDrag, left, %x%, %y%, %what%, %y%, 0
MouseMove, xnow, ynow, 0
BlockInput, MouseMoveOff
}

ImageSearch, x, y, 50, 1399, 1774, 1439, c:\Programe Instalate\TeamViewer.png
if x not between 695 and 735 
{
BlockInput, MouseMove
MouseGetPos, xnow, ynow
MouseClickDrag, left, %x%, %y%, %team%, %y%, 0
MouseMove, xnow, ynow, 0
BlockInput, MouseMoveOff
}

}

}
I don't know how to continue from here :(

Any idea how to make this automation?

Thank you in advance
Last edited by pickone on 19 Sep 2022, 08:09, edited 1 time in total.
RussF
Posts: 1301
Joined: 05 Aug 2021, 06:36

Re: Changing window app position on taskbar

19 Sep 2022, 07:12

I like the icons on my taskbar in a certain order as well - at least for the ones that I use frequently. I solve it by pinning the app to the taskbar. Simple, no code involved, no processor overhead. Just my $0.02 worth.

Russ
pickone
Posts: 16
Joined: 30 Sep 2017, 10:02

Re: Changing window app position on taskbar

19 Sep 2022, 08:12

RussF wrote:
19 Sep 2022, 07:12
I like the icons on my taskbar in a certain order as well - at least for the ones that I use frequently. I solve it by pinning the app to the taskbar. Simple, no code involved, no processor overhead. Just my $0.02 worth.

Russ
I don't use small icons on taskbar. I use large like in the image
image.png
image.png (15.88 KiB) Viewed 502 times
and... when I close the app, if I use "Pin to taskbar", it will still show me a small icon.
Now, your solution could be great for me, only if I can hide the pinned icons :D If not, I still need to find a similar way, using a script or app...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 193 guests