enneract Posted February 24, 2010 Posted February 24, 2010 (edited) I'm trying to move the taskbar from the bottom to the right side of the screen using autoit. I don't want to simply open the properties menu and use the dropdown box, I'd like it to move without obviously being 'scripted' as such. I also got it to work by using MouseClickDrag(), but I also hate this. the following does not work. WinMove([CLASS:Shell_TrayWnd]", "", 1218, 0, 62, 800) Excuse the hardcoded values, but they are the correct position and size of the window, and I'm just trying to get proof of concept going. Does anyone have any ideas? Edited February 24, 2010 by enneract
PsaltyDS Posted February 24, 2010 Posted February 24, 2010 (edited) Call SHAppBarMessage, with an ABM_SETPOS message. Edited February 24, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
enneract Posted February 24, 2010 Author Posted February 24, 2010 I think that may be way over my head. Any chance you could point me in the direction for something similar, utilizing such a call & dealing with the pointer it requires?
enneract Posted February 24, 2010 Author Posted February 24, 2010 I think that may be way over my head.Any chance you could point me in the direction for something similar, utilizing such a call & dealing with the pointer it requires?Apparently I can't edit. I think I may have it, mostly. I just am having trouble dealing with the element, which is of type 'uint', which specifies which edge the bar is on. However, all the possible values of this are strings.... so I am confused.
PsaltyDS Posted February 24, 2010 Posted February 24, 2010 The strings are variable names of constants, i.e. GLOBAL CONST $ABE_LEFT = 0x0 GLOBAL CONST $ABE_TOP = 0x1 GLOBAL CONST $ABE_RIGHT = 0x2 GLOBAL CONST $ABE_BOTTOM = 0x3 Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
enneract Posted February 24, 2010 Author Posted February 24, 2010 Global Const $ABM_SETPOS = 0x00000003 GLOBAL CONST $ABE_LEFT = 0x0 GLOBAL CONST $ABE_TOP = 0x1 GLOBAL CONST $ABE_RIGHT = 0x2 GLOBAL CONST $ABE_BOTTOM = 0x3 $hwnd = HWnd(WinGetHandle("[CLASS:Shell_TrayWnd]")) $AppBarData = DllStructCreate("dword;hwnd;uint;uint;int[4];int") DllStructSetData($AppBarData,1,DllStructGetSize($AppBarData)) DllStructSetData($AppBarData,2,$hwnd) DllStructSetData($AppBarData,4,$ABE_RIGHT) DllCall("shell32.dll", "BOOLEAN", "SHAppBarMessage", "int", $ABM_SETPOS, "ptr", DllStructGetPtr($AppBarData)) Exit Is what I have... and if I am understanding the concept correctly, this should work as soon as I figure out how to define the 'rc' array element.
PsaltyDS Posted February 24, 2010 Posted February 24, 2010 (edited) I actually had to ask about that "rc" element myself. It just means insert the RECT structure definitions inside the others, like expanding a PATH variable. I tried this with $ABM_GETTASKBARPOS, but got zeroes: expandcollapse popup; AppBar Messages Global Const $ABM_QUERYPOS = 0x2 ; Requests a size and screen position for an appbar. Global Const $ABM_SETPOS = 0x3 ; Sets the size and screen position of an appbar. Global Const $ABM_GETSTATE = 0x4 ; Retrieves the autohide and always-on-top states of the Windows taskbar. Global Const $ABM_GETTASKBARPOS = 0x5 ; Retrieves the bounding rectangle of the Windows taskbar. Global Const $ABM_GETAUTOHIDEBAR = 0x7 ; Retrieves the handle to the autohide appbar associated with a particular edge of the screen. Global Const $ABM_SETAUTOHIDEBAR = 0x8 ; Registers or unregisters an autohide appbar for an edge of the screen. Global Const $ABM_WINDOWPOSCHANGED = 0x9 ; Notifies the system when an appbar's position has changed. Global Const $ABM_SETSTATE = 0xA ; Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes. ; AppBar Edges Global Const $ABE_LEFT = 0x0 Global Const $ABE_TOP = 0x1 Global Const $ABE_RIGHT = 0x2 Global Const $ABE_BOTTOM = 0x3 ; AppBar States Global Const $ABS_MANUAL = 0x0 Global Const $ABS_AUTOHIDE = 0x1 Global Const $ABS_ALWAYSONTOP = 0x2 Global Const $ABS_AUTOHIDEANDONTOP = 0x3 Global $tagRECT = "LONG left; LONG top; LONG right; LONG bottom" Global $tagAPPBARDATA = "DWORD cbSize;HWND hWnd;UINT uCallbackMessage;UINT uEdge;" & $tagRECT & ";LPARAM lParam" Global $tAPPBARDATA = DllStructCreate($tagAPPBARDATA) Global $ptAPPBARDATA = DllStructGetPtr($tAPPBARDATA) Global $hAPPBAR = WinGetHandle("[CLASS:Shell_TrayWnd]", "") ; Get handle of taskbar DllStructSetData($tAPPBARDATA, "hWnd", $hAPPBAR) ; Set handle to taskbar DllStructSetData($tAPPBARDATA, "cbSize", DllStructGetSize($tAPPBARDATA)) ; Set size of struct DllCall("Shell32.dll", "int", "SHAppBarMessage", "int", $ABM_GETTASKBARPOS, "ptr", $ptAPPBARDATA) Global $sMsg = "hWnd = " & DllStructGetData($tAPPBARDATA, "hWnd") & @CRLF & _ "cbSize = " & DllStructGetData($tAPPBARDATA, "cbSize") & @CRLF & _ "RECT:" & @CRLF & _ @TAB & "left = " & DllStructGetData($tAPPBARDATA, "left") & @CRLF & _ @TAB & "top = " & DllStructGetData($tAPPBARDATA, "top") & @CRLF & _ @TAB & "right = " & DllStructGetData($tAPPBARDATA, "right") & @CRLF & _ @TAB & "bottom = " & DllStructGetData($tAPPBARDATA, "bottom") & @CRLF ConsoleWrite($sMsg) Edit: Bad DllCall(), works now. Edited February 24, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
enneract Posted February 24, 2010 Author Posted February 24, 2010 (edited) DllCall("Shell32.dll", "int", "SHAppBarMessage", "int", $ABM_GETTASKBARPOS, "ptr", $ptAPPBARDATA) Your DLLCall() was wrong, didn't have enough information. That returns real values. However, using that same code and just setting the values that it should be on the right side of the screen, and switching to $ABM_SETPOS, results in nothing at all. I'm at a loss... Edited February 24, 2010 by enneract
PsaltyDS Posted February 24, 2010 Posted February 24, 2010 Your DLLCall() was wrong.Will have a working script in a few, if anyone cares. Thanks for the help, PsaltyDS. The RECT thing confused the hell out of me.To quote the sage philosopher, Homer: "Doh!" Corrected script edited in my previous, and it works now. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
PsaltyDS Posted February 24, 2010 Posted February 24, 2010 (edited) However, using that same code and just setting the values that it should be on the right side of the screen, and switching to $ABM_SETPOS, results in nothing at all. I'm at a loss...The write ups say you have to ABM_QUERYPOS to request the desktop space and then ABM_SETPOS to move into that space. Hmm... this was my attempt to change it (didn't work): expandcollapse popup; AppBar Messages Global Const $ABM_QUERYPOS = 0x2 ; Requests a size and screen position for an appbar. Global Const $ABM_SETPOS = 0x3 ; Sets the size and screen position of an appbar. Global Const $ABM_GETSTATE = 0x4 ; Retrieves the autohide and always-on-top states of the Windows taskbar. Global Const $ABM_GETTASKBARPOS = 0x5 ; Retrieves the bounding rectangle of the Windows taskbar. Global Const $ABM_GETAUTOHIDEBAR = 0x7 ; Retrieves the handle to the autohide appbar associated with a particular edge of the screen. Global Const $ABM_SETAUTOHIDEBAR = 0x8 ; Registers or unregisters an autohide appbar for an edge of the screen. Global Const $ABM_WINDOWPOSCHANGED = 0x9 ; Notifies the system when an appbar's position has changed. Global Const $ABM_SETSTATE = 0xA ; Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes. ; AppBar Edges Global Const $ABE_LEFT = 0x0 Global Const $ABE_TOP = 0x1 Global Const $ABE_RIGHT = 0x2 Global Const $ABE_BOTTOM = 0x3 ; AppBar States Global Const $ABS_MANUAL = 0x0 Global Const $ABS_AUTOHIDE = 0x1 Global Const $ABS_ALWAYSONTOP = 0x2 Global Const $ABS_AUTOHIDEANDONTOP = 0x3 Global $tagRECT = "LONG left; LONG top; LONG right; LONG bottom" Global $tagAPPBARDATA = "DWORD cbSize;HWND hWnd;UINT uCallbackMessage;UINT uEdge;" & $tagRECT & ";LPARAM lParam" Global $tAPPBARDATA = DllStructCreate($tagAPPBARDATA) Global $ptAPPBARDATA = DllStructGetPtr($tAPPBARDATA) Global $hAPPBAR = WinGetHandle("[CLASS:Shell_TrayWnd]", "") ; Get handle of taskbar DllStructSetData($tAPPBARDATA, "hWnd", $hAPPBAR) ; Set handle to taskbar DllStructSetData($tAPPBARDATA, "cbSize", DllStructGetSize($tAPPBARDATA)) ; Set size of struct DllCall("Shell32.dll", "int", "SHAppBarMessage", "int", $ABM_GETTASKBARPOS, "ptr", $ptAPPBARDATA) Global $sMsg = @CRLF & "Result of ABM_GETTASKBARPOS ----" & @CRLF & _ "hWnd = " & DllStructGetData($tAPPBARDATA, "hWnd") & @CRLF & _ "cbSize = " & DllStructGetData($tAPPBARDATA, "cbSize") & @CRLF & _ "RECT:" & @CRLF & _ @TAB & "left = " & DllStructGetData($tAPPBARDATA, "left") & @CRLF & _ @TAB & "top = " & DllStructGetData($tAPPBARDATA, "top") & @CRLF & _ @TAB & "right = " & DllStructGetData($tAPPBARDATA, "right") & @CRLF & _ @TAB & "bottom = " & DllStructGetData($tAPPBARDATA, "bottom") & @CRLF ConsoleWrite($sMsg) ; Display binary contents of struct for geekiness sake... ConsoleWrite(@CRLF & DllStructGetData(DllStructCreate("byte[" & DllStructGetSize($tAPPBARDATA) & "]", $ptAPPBARDATA), 1) & @CRLF) DllStructSetData($tAPPBARDATA, "uEdge", $ABE_TOP) ; Set top edge DllStructSetData($tAPPBARDATA, "left", 0) ; Set pos DllStructSetData($tAPPBARDATA, "top", 0) ; Set pos DllStructSetData($tAPPBARDATA, "right", 1920) ; Set pos DllStructSetData($tAPPBARDATA, "bottom", 34) ; Set pos DllStructSetData($tAPPBARDATA, "hWnd", $hAPPBAR) ; Set handle to taskbar DllStructSetData($tAPPBARDATA, "cbSize", DllStructGetSize($tAPPBARDATA)) ; Set size of struct DllCall("Shell32.dll", "int", "SHAppBarMessage", "int", $ABM_QUERYPOS, "ptr", $ptAPPBARDATA) Global $sMsg = @CRLF & "Result of ABM_QUERYPOS ----" & @CRLF & _ "hWnd = " & DllStructGetData($tAPPBARDATA, "hWnd") & @CRLF & _ "cbSize = " & DllStructGetData($tAPPBARDATA, "cbSize") & @CRLF & _ "uEdge = " & DllStructGetData($tAPPBARDATA, "uEdge") & @CRLF & _ "RECT:" & @CRLF & _ @TAB & "left = " & DllStructGetData($tAPPBARDATA, "left") & @CRLF & _ @TAB & "top = " & DllStructGetData($tAPPBARDATA, "top") & @CRLF & _ @TAB & "right = " & DllStructGetData($tAPPBARDATA, "right") & @CRLF & _ @TAB & "bottom = " & DllStructGetData($tAPPBARDATA, "bottom") & @CRLF ConsoleWrite($sMsg) DllCall("Shell32.dll", "int", "SHAppBarMessage", "int", $ABM_SETPOS, "ptr", $ptAPPBARDATA) Of course, some of those write ups say this is only for "A taskbar", not "THE Taskbar", as in, you're not supposed to be able to do this via API to the real Windows Taskbar. Edit: Added geeky-cool method to display struct contents as binary (example from SkinnyWhiteGuy). Edited February 25, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
enneract Posted February 25, 2010 Author Posted February 25, 2010 (edited) The write ups say you have to ABM_QUERYPOS to request the desktop space and then ABM_SETPOS to move into that space. Hmm... this was my attempt to change it (didn't work): Of course, some of those write ups say this is only for "A taskbar", not "THE Taskbar", as in, you're not supposed to be able to do this via API to the real Windows Taskbar.Edit: Added geeky-cool method to display struct contents as binary (example from SkinnyWhiteGuy).I don't see any other way to attempt this. (Although, using ABM_QUERYPOS right after setting the data, but before ABM_SETPOS seems pointless, as ABM_QUERYPOS returns info in that same struct... switching it doesn't help, though.) I don't think it is doable through this API.I think I figured out a method by writing registry values and forcing explorer to reload. Meh.Unless there is a way to manipulate the settings window while it is 'hidden'? Edited February 25, 2010 by enneract
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now