IanN1990 Posted December 7, 2012 Posted December 7, 2012 (edited) I have very limited when it comes to C. I am assuming for this post C#, C, C++ are all very similar. Making my post here valid I am looking to convert some C# "lest i think it is c# " into autoit.**Extra Information. This is C# code which is ment to be able to move a windows 7 Taskbar. Something to do with Calling SHAppBarMessage with ABM_SETPOS. That idea lead to the link below.Original Linkhttp://bytes.com/topic/c-sharp/answers/247701-moving-windows-takbarOriginal Codeexpandcollapse popup[DllImport("User32.dll", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Aut o)] private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint); [DllImport("Shell32.dll", CharSet=CharSet.Auto)] private static extern int SHAppBarMessage(int dwMessage, ref APP_BAR_DATA abd); private const int ABM_NEW = 0x00; private const int ABM_REMOVE = 0x01; private const int ABM_QUERYPOS = 0x02; private const int ABM_SETPOS = 0x03; private const int ABM_SETAUTOHIDEBAR = 0x08; private const int ABM_SETSTATE = 0x0000000a; private const int ABE_LEFT = 0; private const int ABE_TOP = 1; private const int ABE_RIGHT = 2; private const int ABE_BOTTOM = 3; private const int ABS_AUTOHIDE = 0x01; private const int ABS_ALWAYSONTOP = 0x02; [StructLayout(LayoutKind.Sequential)] private struct APP_BAR_DATA { public int cbSize; public IntPtr hWnd; public int uCallbackMessage; public int uEdge; public RECT rc; public IntPtr lParam; } [StructLayout(LayoutKind.Sequential)] private struct RECT { public int left; public int top; public int right; public int bottom; public RECT(int left, int top, int right, int bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } public static RECT FromXYWH(int x, int y, int width, int height) { return new RECT(x, y, x + width, y + height); } } internal static void DockAppBar(IntPtr hWnd, int edge, Size idealSize) { APP_BAR_DATA abd = new APP_BAR_DATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = hWnd; abd.uEdge = edge; if (edge == ABE_LEFT || edge == ABE_RIGHT) { abd.rc.top = 0; abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height; if (edge == ABE_LEFT) { abd.rc.right = idealSize.Width; } else { abd.rc.right = SystemInformation.PrimaryMonitorSize.Width; abd.rc.left = abd.rc.right - idealSize.Width; } } else { abd.rc.left = 0; abd.rc.right = SystemInformation.PrimaryMonitorSize.Width; if (edge == ABE_TOP) { abd.rc.bottom = idealSize.Height; } else { abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height; abd.rc.top = abd.rc.bottom - idealSize.Height; } } // Query the system for an approved size and position. SHAppBarMessage(ABM_QUERYPOS, ref abd); // Adjust the rectangle, depending on the edge to which the // appbar is anchored. switch (edge) { case ABE_LEFT: abd.rc.right = abd.rc.left + idealSize.Width; break; case ABE_RIGHT: abd.rc.left= abd.rc.right - idealSize.Width; break; case ABE_TOP: abd.rc.bottom = abd.rc.top + idealSize.Height; break; case ABE_BOTTOM: abd.rc.top = abd.rc.bottom - idealSize.Height; break; } // Pass the final bounding rectangle to the system. SHAppBarMessage(ABM_SETPOS, ref abd); // Move and size the appbar so that it conforms to the // bounding rectangle passed to the system. MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true); }My Attempt so far.expandcollapse popup[DllImport("User32.dll", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Aut o)] private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint); [DllImport("Shell32.dll", CharSet=CharSet.Auto)] private static extern int SHAppBarMessage(int dwMessage, ref APP_BAR_DATA abd); Const $ABM_NEW = 0x00 Const $ABM_REMOVE = 0x01 Const $ABM_QUERYPOS = 0x02 Const $ABM_SETPOS = 0x03 Const $ABM_SETAUTOHIDEBAR = 0x08 Const $ABM_SETSTATE = 0x0000000a Const $ABE_LEFT = 0 Const $ABE_TOP = 1 Const $ABE_RIGHT = 2 Const $ABE_BOTTOM = 3 Const $ABS_AUTOHIDE = 0x01 Const $ABS_ALWAYSONTOP = 0x02 [StructLayout(LayoutKind.Sequential)] private struct APP_BAR_DATA { public int cbSize public IntPtr hWnd public int uCallbackMessage public int uEdge public RECT rc public IntPtr lParam } [StructLayout(LayoutKind.Sequential)] private struct RECT { public int left public int top public int right public int bottom public RECT(int left, int top, int right, int bottom) { this.left = left this.top = top this.right = right this.bottom = bottom } public static RECT FromXYWH(int x, int y, int width, int height) { return new RECT(x, y, x + width, y + height); } } internal static void DockAppBar(IntPtr hWnd, int edge, Size idealSize) { APP_BAR_DATA abd = new APP_BAR_DATA() abd.cbSize = Marshal.SizeOf(abd) abd.hWnd = hWnd abd.uEdge = edge if (edge == $ABE_LEFT || edge == $ABE_RIGHT) { abd.rc.top = 0; abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height; if (edge == $ABE_LEFT) { abd.rc.right = idealSize.Width; } else { abd.rc.right = SystemInformation.PrimaryMonitorSize.Width; abd.rc.left = abd.rc.right - idealSize.Width; } } else { abd.rc.left = 0; abd.rc.right = SystemInformation.PrimaryMonitorSize.Width; if (edge == $ABE_TOP) { abd.rc.bottom = idealSize.Height; } else { abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height; abd.rc.top = abd.rc.bottom - idealSize.Height; } } ; Query the system for an approved size and position. SHAppBarMessage($ABM_QUERYPOS, ref abd); ; Adjust the rectangle, depending on the edge to which the ; appbar is anchored. switch (edge) case $ABE_LEFT abd.rc.right = abd.rc.left + idealSize.Width break case $ABE_RIGHT abd.rc.left= abd.rc.right - idealSize.Width break case $ABE_TOP abd.rc.bottom = abd.rc.top + idealSize.Height break case $ABE_BOTTOM abd.rc.top = abd.rc.bottom - idealSize.Height break EndSwitch ; Pass the final bounding rectangle to the system. SHAppBarMessage($ABM_SETPOS, ref abd); ; Move and size the appbar so that it conforms to the ; bounding rectangle passed to the system. MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true) }My Old Code i used to move the taskbar hoping to replace with this C#$TaskBarLocation=WinGetPos('[Class:Shell_TrayWnd]') If $TaskBarLocation[0]>960 then ;Move right to left MoveTaskbar(1920,-1920,-10) ElseIf $TaskBarLocation[0]<960 then ;Move left to right MoveTaskbar(-2,3840,1930) endif Func MoveTaskbar($PrimPos,$SecPos,$ThirPos) $MouseTaskbar = Mousegetpos() Mousemove($PrimPos,975,0) MouseDown('') MouseMove($SecPos,1080,1) MouseMove($ThirPos,975,0) MouseUp('') MouseMove($MouseTaskbar[0],$MouseTaskbar[1],0) endfunc Edited December 7, 2012 by IanN1990
Andreik Posted December 7, 2012 Posted December 7, 2012 (edited) What kind of data type is Size idealSize ? Can you show me how it's defined? EDIT: I suppose your code should be something like this expandcollapse popupGlobal Const $ABM_NEW = 0x00 Global Const $ABM_REMOVE = 0x01 Global Const $ABM_QUERYPOS = 0x02 Global Const $ABM_SETPOS = 0x03 Global Const $ABM_SETAUTOHIDEBAR = 0x08 Global Const $ABM_SETSTATE = 0x0000000a Global Const $ABE_LEFT = 0 Global Const $ABE_TOP = 1 Global Const $ABE_RIGHT = 2 Global Const $ABE_BOTTOM = 3 Global Const $ABS_AUTOHIDE = 0x01 Global Const $ABS_ALWAYSONTOP = 0x02 Global Const $tagSize = "long Width; long Height" Global Const $tagRECT = "long Left;long Top;long Right;long Bottom;" Global Const $tagAPPBARDATA = "DWORD cbSize;HWND hWnd;UINT uCallbackMessage;UINT uEdge;" & $tagRECT & "LPARAM lParam;" Global $abd Global $IdealSize = DllStructCreate($tagSize) DllStructSetData($idealSize,"Widht","DesiredValue") ; <<-------- PUT YOUR VALUE HERE DllStructSetData($idealSize,"Height","DesiredValue") ; <<-------- PUT YOUR VALUE HERE Func DockAppBar($hWnd,$Edge,$IdealSize) ; In your code this function is defined but never called ?? $abd = DllStructCreate($tagAPPBARDATA) DllStructSetData($abd,"cbSize",DllStructGetSize($abd)) DllStructSetData($abd,"hWnd",$hWnd) DllStructSetData($abd,"uEdge",$Edge) If ($Edge = $ABE_LEFT) Or ($Edge = $ABE_RIGHT) Then DllStructSetData($abd,"Top",0) DllStructSetData($abd,"Bottom",@DesktopHeight) If $Edge = $ABE_LEFT Then DllStructSetData($abd,"Right",DllStructGetData($idealSize,"Width")) Else DllStructSetData($abd,"Right",@DesktopWidth) DllStructSetData($abd,"Left",@DesktopWidth-DllStructGetData($idealSize,"Width")) EndIf Else DllStructSetData($abd,"Left",0) DllStructSetData($abd,"Right",@DesktopWidth) If $Edge = $ABE_TOP Then DllStructSetData($abd,"Bottom",DllStructGetData($idealSize,"Height")) Else DllStructSetData($abd,"Bottom",@DesktopHeight) DllStructSetData($abd,"Top",@DesktopHeight-DllStructGetData($idealSize,"Height")) EndIf EndIf EndFunc DllCall("shell32.dll","UINT_PTR","SHAppBarMessage","DWORD",$ABM_QUERYPOS,"ptr",DllStructGetPtr($abd)) Switch DllStructGetData($abd,"uEdge") Case $ABE_LEFT DllStructSetData($abd,"Right",DllStructGetData($abd,"Left") + DllStructGetData($idealSize,"Width")) Case $ABE_RIGHT DllStructSetData($abd,"Left",DllStructGetData($abd,"Right") - DllStructGetData($idealSize,"Width")) Case $ABE_TOP DllStructSetData($abd,"Bottom",DllStructGetData($abd,"Top") + DllStructGetData($idealSize,"Height")) Case $ABE_BOTTOM DllStructSetData($abd,"Top",DllStructGetData($abd,"Bottom") - DllStructGetData($idealSize,"Height")) EndSwitch DllCall("shell32.dll","UINT_PTR","SHAppBarMessage","DWORD",$ABM_SETPOS,"ptr",DllStructGetPtr($abd)) WinMove(DllStructGetData($abd,"hWnd"),"",DllStructGetData($abd,"Left"),DllStructGetData($abd,"Top"), _ DllStructGetData($abd,"Right") - DllStructGetData($abd,"Left"), _ DllStructGetData($abd,"Bottom") - DllStructGetData($abd,"Top")) Edited December 7, 2012 by Andreik
IanN1990 Posted December 7, 2012 Author Posted December 7, 2012 (edited) @Andreik. I honestly dont know. I double checked the site in the link, "which is where i got the orginal code" but drew blanks. as from what i can gather you have to declare the "state" of a variable. Maybe its a typo mistake ?. I see lines like abd.rc.right = idealSize.Width; abd.rc.left = abd.rc.right - idealSize.Width; abd.rc.bottom = idealSize.Height; abd.rc.top = abd.rc.bottom - idealSize.Height; case ABE_LEFT: abd.rc.right = abd.rc.left + idealSize.Width; break; case ABE_RIGHT: abd.rc.left= abd.rc.right - idealSize.Width; break; case ABE_TOP: abd.rc.bottom = abd.rc.top + idealSize.Height; break; case ABE_BOTTOM: abd.rc.top = abd.rc.bottom - idealSize.Height; break; Edited December 7, 2012 by IanN1990
Andreik Posted December 7, 2012 Posted December 7, 2012 Maybe it's better to tell us what exactly you try do do and maybe we can provide you a better solution then converting code from C# to AutoIt.
IanN1990 Posted December 7, 2012 Author Posted December 7, 2012 Ah your quite right, i should of included that. I will edit orginal post
jvanegmond Posted December 7, 2012 Posted December 7, 2012 The only piece of AutoIt you would need from that is a working call to SHAppBarMessage, the rest is just to make the C# more clear or to simulate functionality that AutoIt provides out of the box. WinMove is essentially MoveWindow with some additional AutoIt-specific logic. Fortunately you're not the first to ever need SHAppBarMessage in AutoIt: (thought it's old and requires some polish). github.com/jvanegmond
IanN1990 Posted December 7, 2012 Author Posted December 7, 2012 Aye but from my research into the forums some-people have tryed ShAppBarMessage to move the taskbar and failed. Kafu was the one who found the link in my orginal post which is why i am going down this wrote tryin to conver it into autoit. Was my reasoning wrong ?
jvanegmond Posted December 7, 2012 Posted December 7, 2012 (edited) Ah, some history: No, you're definitely not wrong, although the principle the C# code demonstrates is worth more than a straight up line-by-line copy of the C# code. Ultimately you only want to do:SHAppBarMessage(ABM_QUERYPOS, ...) SHAppBarMessage(ABM_SETPOS, ...) WinMove(...)Finding some proven working AutoIt code to call SHAppBarMessage is the most logical step. Edited December 7, 2012 by Manadar github.com/jvanegmond
IanN1990 Posted December 7, 2012 Author Posted December 7, 2012 Is only the semi-working working SHAppBarMessage, aside from your Progress above taskbar poast as well.
IanN1990 Posted December 11, 2012 Author Posted December 11, 2012 Ok. So trying to bring eveything togeather we have the code from post 2# expandcollapse popupGlobal Const $ABM_NEW = 0x00 Global Const $ABM_REMOVE = 0x01 Global Const $ABM_QUERYPOS = 0x02 Global Const $ABM_SETPOS = 0x03 Global Const $ABM_SETAUTOHIDEBAR = 0x08 Global Const $ABM_SETSTATE = 0x0000000a Global Const $ABE_LEFT = 0 Global Const $ABE_TOP = 1 Global Const $ABE_RIGHT = 2 Global Const $ABE_BOTTOM = 3 Global Const $ABS_AUTOHIDE = 0x01 Global Const $ABS_ALWAYSONTOP = 0x02 Global Const $tagSize = "long Width; long Height" Global Const $tagRECT = "long Left;long Top;long Right;long Bottom;" Global Const $tagAPPBARDATA = "DWORD cbSize;HWND hWnd;UINT uCallbackMessage;UINT uEdge;" & $tagRECT & "LPARAM lParam;" Global $abd Global $IdealSize = DllStructCreate($tagSize) DllStructSetData($idealSize,"Widht","DesiredValue") ; <<-------- PUT YOUR VALUE HERE DllStructSetData($idealSize,"Height","DesiredValue") ; <<-------- PUT YOUR VALUE HERE Func DockAppBar($hWnd,$Edge,$IdealSize) ; In your code this function is defined but never called ?? $abd = DllStructCreate($tagAPPBARDATA) DllStructSetData($abd,"cbSize",DllStructGetSize($abd)) DllStructSetData($abd,"hWnd",$hWnd) DllStructSetData($abd,"uEdge",$Edge) If ($Edge = $ABE_LEFT) Or ($Edge = $ABE_RIGHT) Then DllStructSetData($abd,"Top",0) DllStructSetData($abd,"Bottom",@DesktopHeight) If $Edge = $ABE_LEFT Then DllStructSetData($abd,"Right",DllStructGetData($idealSize,"Width")) Else DllStructSetData($abd,"Right",@DesktopWidth) DllStructSetData($abd,"Left",@DesktopWidth-DllStructGetData($idealSize,"Width")) EndIf Else DllStructSetData($abd,"Left",0) DllStructSetData($abd,"Right",@DesktopWidth) If $Edge = $ABE_TOP Then DllStructSetData($abd,"Bottom",DllStructGetData($idealSize,"Height")) Else DllStructSetData($abd,"Bottom",@DesktopHeight) DllStructSetData($abd,"Top",@DesktopHeight-DllStructGetData($idealSize,"Height")) EndIf EndIf EndFunc DllCall("shell32.dll","UINT_PTR","SHAppBarMessage","DWORD",$ABM_QUERYPOS,"ptr",DllStructGetPtr($abd)) Switch DllStructGetData($abd,"uEdge") Case $ABE_LEFT DllStructSetData($abd,"Right",DllStructGetData($abd,"Left") + DllStructGetData($idealSize,"Width")) Case $ABE_RIGHT DllStructSetData($abd,"Left",DllStructGetData($abd,"Right") - DllStructGetData($idealSize,"Width")) Case $ABE_TOP DllStructSetData($abd,"Bottom",DllStructGetData($abd,"Top") + DllStructGetData($idealSize,"Height")) Case $ABE_BOTTOM DllStructSetData($abd,"Top",DllStructGetData($abd,"Bottom") - DllStructGetData($idealSize,"Height")) EndSwitch DllCall("shell32.dll","UINT_PTR","SHAppBarMessage","DWORD",$ABM_SETPOS,"ptr",DllStructGetPtr($abd)) WinMove(DllStructGetData($abd,"hWnd"),"",DllStructGetData($abd,"Left"),DllStructGetData($abd,"Top"), _ DllStructGetData($abd,"Right") - DllStructGetData($abd,"Left"), _ DllStructGetData($abd,"Bottom") - DllStructGetData($abd,"Top")) The code belows is able to tell if the taskbar is autohidden or always on top. Global Const $ABS_ALWAYSONTOP = 0x2 Global Const $ABS_AUTOHIDE = 0x1 $result = _GetTaskBarState() If BitAND($result,$ABS_ALWAYSONTOP) = $ABS_ALWAYSONTOP Then ConsoleWrite("ALWAYSONTOP" & @LF) If BitAND($result,$ABS_AUTOHIDE) = $ABS_AUTOHIDE Then ConsoleWrite("AUTOHIDE" & @LF) Func _GetTaskBarState() Global Const $ABM_GETSTATE = 0x4 $h_taskbar = WinGetHandle("","Start") $AppBarData = DllStructCreate("dword;int;uint;uint;int;int;int;int;int") ;~ DWORD cbSize; ;~ HWND hWnd; ;~ UINT uCallbackMessage; ;~ UINT uEdge; ;~ RECT rc; ;~ LPARAM lParam; DllStructSetData($AppBarData,1,DllStructGetSize($AppBarData)) DllStructSetData($AppBarData,2,$h_taskbar) $lResult = DllCall("shell32.dll","int","SHAppBarMessage","int",$ABM_GETSTATE,"ptr",DllStructGetPtr($AppBarData)) If Not @error Then If $lResult[0] Then Return $lResult[0] EndIf SetError(1) Return 0 EndFunc The code below shows how you can get the hwnd, size, left, top, right, bottom using a SMessage. 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) Now i had an interseting idea, which is failed which is below. I looked though all sets of code but truth be told it doesnt make much sense to me but i figured the code from spoiler 3. Gets all the infromation about the taskbar in $ptAPPBARDATA which is a DLLStruct that can be used with a DLLCall. So i tryed this. 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) sleep(5000) DllCall("shell32.dll","UINT_PTR","SHAppBarMessage","DWORD",$ABM_SETPOS,"ptr",DllStructGetPtr($tAPPBARDATA)) WinMove("[Class:Shell_TrayWnd]", "", 1920, 0, 2200, 1080) If the idea was the orginal code gets the all the infromation with. SHAppBarMessage(ABM_QUERYPOS, ...). Then waits 5 seconds, i move the taskbar to a different location. I then use ABM_SETPOS, ...) WinMove(...) To set it back to its orginal location but it didn't work.
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