Moving the TaskBar
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Moving the TaskBar
I was given some autohotkey code which purported to create hotkeys for moving the Task Bar around. I thought I might adapt it to my specific purpose. So I copied it into a text file and saved it as a filename.ahk. I was disappointed to find that double-clicking that produced only an error message. So I see two needs : to get that code working; and THEN to change it so that I can put it into a batchfile, the clicking of which would toggle the position of the TaskBar from bottom to right. I will see what response I get to this before trying to post the code.
Re: Moving the TaskBar
There is not much info to go with in your post.
What is the error message?
Which AHK version did you install?
How does the code look?
If AHK is correctly installed and you have working code in an ahk-file, it should execute after double-clicking (of course, then, you could also compile in into an exe)...
If you want to look at the basics of AHK, there is a beginner's tutorial. The 'Usage & Syntax' section of the docs is also recommended to get an overview.
What is the error message?
Which AHK version did you install?
How does the code look?
If AHK is correctly installed and you have working code in an ahk-file, it should execute after double-clicking (of course, then, you could also compile in into an exe)...
If you want to look at the basics of AHK, there is a beginner's tutorial. The 'Usage & Syntax' section of the docs is also recommended to get an overview.
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
I answered all your questions and submitted it, but an empty window appeared into which i am now typing this. I do not know if my reply was sent.
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
I do not see my reply in the thread, so will 'do' it again, but one question at a time.
Error message :
TaskBarMove.ahk
Error: Missing "}"
Line#
035:}
036: Return
040: WinMove(sleft, s%p_pos%, sRight, 0]
041: Return
045: WinMove[s%p_pos%, sTop, 0, sBottom]
046: Return
047}
---> 049: {
050: WM_ENTERSIZEMOVE := 0x0231
051: WM_EXITSIZEMOVE := 0x0232
053: if [p_hwnd!= "")
053: {
054: WinExist("ahk_id " p_hwnd)
055:}
057: SendMessage,WM_ENTERSlZEMOVE
The program will exit.
Error message :
TaskBarMove.ahk
Error: Missing "}"
Line#
035:}
036: Return
040: WinMove(sleft, s%p_pos%, sRight, 0]
041: Return
045: WinMove[s%p_pos%, sTop, 0, sBottom]
046: Return
047}
---> 049: {
050: WM_ENTERSIZEMOVE := 0x0231
051: WM_EXITSIZEMOVE := 0x0232
053: if [p_hwnd!= "")
053: {
054: WinExist("ahk_id " p_hwnd)
055:}
057: SendMessage,WM_ENTERSlZEMOVE
The program will exit.
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
AHK version : v1.1.30.00
I am already using many AHK 'applications' Mostly to enter scraps of text by hotkey pressing.
I am already using many AHK 'applications' Mostly to enter scraps of text by hotkey pressing.
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
Code :
;
; AutoHotkey Version: 1.0.48.5
/*
** TaskbarMove.ahk - Move the taskbar (startbar) around the screen with Hotkeys
**
** Updated: Sat, Nov 19, 2011 --- 11/19/11, 4:19:19pm EST
** Keywords: move taskbar, move startbar, move task bar, move start bar
** Location: r.secsrv.net/AutoHotkey/Scripts/TaskbarMove
**
** Author: JSLover - r.secsrv.net/JSLover - r.secsrv.net/JSLoverAHK
** Web: http jslover.secsrv.net /AutoHotkey/Scripts/TaskbarMove.ahk Broken Link for safety
*/
#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
#Numpad8::TaskbarMove("Top")
#Numpad2::TaskbarMove("Bottom")
#Numpad4::TaskbarMove("Left")
#Numpad6::TaskbarMove("Right")
TaskbarMove(p_pos) {
label:="TaskbarMove_" p_pos
WinExist("ahk_class Shell_TrayWnd")
SysGet, s, Monitor
if (IsLabel(label)) {
Goto, %label%
}
return
TaskbarMove_Top:
TaskbarMove_Bottom:
WinMove(sLeft, s%p_pos%, sRight, 0)
return
TaskbarMove_Left:
TaskbarMove_Right:
WinMove(s%p_pos%, sTop, 0, sBottom)
return
}
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") {
WM_ENTERSIZEMOVE:=0x0231
WM_EXITSIZEMOVE :=0x0232
if (p_hwnd!="") {
WinExist("ahk_id " p_hwnd)
}
SendMessage, WM_ENTERSIZEMOVE
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%)
WinMove, , , p_x, p_y, p_w, p_h
SendMessage, WM_EXITSIZEMOVE
;
; AutoHotkey Version: 1.0.48.5
/*
** TaskbarMove.ahk - Move the taskbar (startbar) around the screen with Hotkeys
**
** Updated: Sat, Nov 19, 2011 --- 11/19/11, 4:19:19pm EST
** Keywords: move taskbar, move startbar, move task bar, move start bar
** Location: r.secsrv.net/AutoHotkey/Scripts/TaskbarMove
**
** Author: JSLover - r.secsrv.net/JSLover - r.secsrv.net/JSLoverAHK
** Web: http jslover.secsrv.net /AutoHotkey/Scripts/TaskbarMove.ahk Broken Link for safety
*/
#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
#Numpad8::TaskbarMove("Top")
#Numpad2::TaskbarMove("Bottom")
#Numpad4::TaskbarMove("Left")
#Numpad6::TaskbarMove("Right")
TaskbarMove(p_pos) {
label:="TaskbarMove_" p_pos
WinExist("ahk_class Shell_TrayWnd")
SysGet, s, Monitor
if (IsLabel(label)) {
Goto, %label%
}
return
TaskbarMove_Top:
TaskbarMove_Bottom:
WinMove(sLeft, s%p_pos%, sRight, 0)
return
TaskbarMove_Left:
TaskbarMove_Right:
WinMove(s%p_pos%, sTop, 0, sBottom)
return
}
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") {
WM_ENTERSIZEMOVE:=0x0231
WM_EXITSIZEMOVE :=0x0232
if (p_hwnd!="") {
WinExist("ahk_id " p_hwnd)
}
SendMessage, WM_ENTERSIZEMOVE
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%)
WinMove, , , p_x, p_y, p_w, p_h
SendMessage, WM_EXITSIZEMOVE
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
Breaking it into three consecutive posts appears to have been successful.
Re: Moving the TaskBar
I can't test the code at the moment, but afaics, the last function, called WinMove(), misses a closing bracket }, like the error message indicates:
(probably a copy/paste error; Edit: Here, the bracket is present - if this is the source of this script: https://github.com/gerdami/AutoHotkey/blob/master/TaskbarMove.ahk)
All openend brackets need to be closed sooner or later... meaningful indentation (and a good editor) can help to keep an overview.
(To be able to indent code in the forum, you can use [code][/code] tags around your code to create a code box like above;
(in the Full Editor & Preview mode you can also use the </> button to insert these tags instead of typing them)
(probably a copy/paste error; Edit: Here, the bracket is present - if this is the source of this script: https://github.com/gerdami/AutoHotkey/blob/master/TaskbarMove.ahk)
Code: Select all
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") {
WM_ENTERSIZEMOVE:=0x0231
WM_EXITSIZEMOVE :=0x0232
if (p_hwnd!="") {
WinExist("ahk_id " p_hwnd)
}
SendMessage, WM_ENTERSIZEMOVE
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%)
WinMove, , , p_x, p_y, p_w, p_h
SendMessage, WM_EXITSIZEMOVE
} ; <<<<<<<<<<<<<<< add this
(To be able to indent code in the forum, you can use [code][/code] tags around your code to create a code box like above;
(in the Full Editor & Preview mode you can also use the </> button to insert these tags instead of typing them)
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
Having added that last missing '}', now clicking the AHK no longer triggers an error window. Nor does ANYTHING appear to happen.
Presumably, if there are no errors, then some hotkeys have been enabled.
I deduce from the code that those hotkeys are Numpad 8 (top), 2(bottom), 4 (left) and 6 (right)
After pressing NUMLOCK, and then those numpad keys, nothing appears to happen.
I'll claim SOME progress, but not nearly enough.
Presumably, if there are no errors, then some hotkeys have been enabled.
I deduce from the code that those hotkeys are Numpad 8 (top), 2(bottom), 4 (left) and 6 (right)
After pressing NUMLOCK, and then those numpad keys, nothing appears to happen.
I'll claim SOME progress, but not nearly enough.
Re: Moving the TaskBar
Your script wants to be tested like this:
Run it, Press WinKey+NumPad 2. also 4, 6, 8 respectively.
I think looking at keynames in hotkey definition will explain # means the left or right Win-key.
see https://www.autohotkey.com/docs/KeyList.htm#modifier => read the green note.
Run it, Press WinKey+NumPad 2. also 4, 6, 8 respectively.
I think looking at keynames in hotkey definition will explain # means the left or right Win-key.
see https://www.autohotkey.com/docs/KeyList.htm#modifier => read the green note.
-
- Posts: 28
- Joined: 10 Mar 2019, 23:42
Re: Moving the TaskBar
Thank you.
I managed to get the AHK icon showing in the systray.
After pressing NUMLOCK, then the Winkey and numpad6, the Task Bar moved to the left, NOT to the right. Response to '8' was correct (but unwanted).
I can move the bar to the right manually, but not by autohotkey
I suspect the Sidebar for Gadgets prevents it.
I may have to settle for a left move.
Having to set the Numlock first - which I do NOT want on all the time - introduces another step
which makes the autohotkey procedure no quicker than doing it manually.
So my goal is still to create a batchfile to click once.
In addition to running the autohotkey, it would have to toggle the numlock as well.
I guess that achievement is outside of the purview of Autohotkey.
The suggestion to compile it into an exe - I suppose that is an alternative to using a batch file ?
I managed to get the AHK icon showing in the systray.
After pressing NUMLOCK, then the Winkey and numpad6, the Task Bar moved to the left, NOT to the right. Response to '8' was correct (but unwanted).
I can move the bar to the right manually, but not by autohotkey
I suspect the Sidebar for Gadgets prevents it.
I may have to settle for a left move.
Having to set the Numlock first - which I do NOT want on all the time - introduces another step
which makes the autohotkey procedure no quicker than doing it manually.
So my goal is still to create a batchfile to click once.
In addition to running the autohotkey, it would have to toggle the numlock as well.
I guess that achievement is outside of the purview of Autohotkey.
The suggestion to compile it into an exe - I suppose that is an alternative to using a batch file ?
- Justin-TestBot101a
- Posts: 33
- Joined: 04 Aug 2022, 20:00
Re: Moving the TaskBar
First, this script works very well and I really appreciate this code.
Just wondering if anyone could help me with my setup...
This code works only for the first screen, but my setup
I have 3 screens and I need all 3 taskbars to move at the
same time when pressing the corresponding hotkey.
Can someone help me add all three screens to this code?
Also, Code will not move the Taskbar if its hidden or not focused..
I did some research and found out from Windows Spy that the task bar on the second and third
screen are as follows:
Second Screen:
ahk_class Shell_SecondaryTrayWnd
ahk_exe explorer.exe
ahk_pid 8352
ahk_id 65976
Third Screen:
ahk_class Shell_SecondaryTrayWnd
ahk_exe explorer.exe
ahk_pid 8352
ahk_id 4589244
Now to figure out how to add it to the code and then all three will switch at the same time..
I'm going to figure this out!
-Justin
Just wondering if anyone could help me with my setup...
This code works only for the first screen, but my setup
I have 3 screens and I need all 3 taskbars to move at the
same time when pressing the corresponding hotkey.
Can someone help me add all three screens to this code?
Also, Code will not move the Taskbar if its hidden or not focused..
Code: Select all
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Move the Task bar
F9::TaskbarMove("Bottom")
F10::TaskbarMove("Top")
F11::TaskbarMove("Left")
F12::TaskbarMove("Right")
TaskbarMove(p_pos) {
label:="TaskbarMove_" p_pos
WinExist("ahk_class Shell_TrayWnd")
SysGet, s, Monitor
if (IsLabel(label)) {
Goto, %label%
}
return
TaskbarMove_Top:
TaskbarMove_Bottom:
WinMove(sLeft, s%p_pos%, sRight, 0)
return
TaskbarMove_Left:
TaskbarMove_Right:
WinMove(s%p_pos%, sTop, 0, sBottom)
return
}
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") {
WM_ENTERSIZEMOVE:=0x0231
WM_EXITSIZEMOVE :=0x0232
if (p_hwnd!="") {
WinExist("ahk_id " p_hwnd)
}
SendMessage, WM_ENTERSIZEMOVE
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%)
WinMove, , , p_x, p_y, p_w, p_h
SendMessage, WM_EXITSIZEMOVE
}
return
screen are as follows:
Second Screen:
ahk_class Shell_SecondaryTrayWnd
ahk_exe explorer.exe
ahk_pid 8352
ahk_id 65976
Third Screen:
ahk_class Shell_SecondaryTrayWnd
ahk_exe explorer.exe
ahk_pid 8352
ahk_id 4589244
Now to figure out how to add it to the code and then all three will switch at the same time..
I'm going to figure this out!
-Justin
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Moving the TaskBar
I am looking to do the same... Did you ever figure it out?