Jump to content

Windows 7 - Move Taskbar


IanN1990
 Share

Recommended Posts

A Function to Move the Windows 7 Taskbar.

; #FUNCTION# ====================================================================================================================
; Name ..........: _MoveTaskBar
; Description ...: Moves the Windows 7 Taskbar to a New Location on the Screen.
; Syntax ........: _MoveTaskBar([$ScreenPosX [, $ScreenPosY = '']])
; Parameters ....: $ScreenPosX = Left, Right, Top, Bottom
;                or $ScreenPosX And $ScreenPosY = New Window Location
; Return values .: Success - True
;                 Failure - False
; Author ........: IanN1990
; Remarks .......:
; Example .......:
; Note ..........:
; ===============================================================================================================================
Func _MoveTaskBar($ScreenPosX, $ScreenPosY='')
    Local $LockState = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSizeMove") ;Get Lock State
    Local $TaskBarPos = WinGetPos('[Class:Shell_TrayWnd]') ;Get Current TaskBar State
    
    If Not $LockState Then DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", WinGetHandle("[CLASS:Shell_TrayWnd]"), "uint", 273, "wparam", 424, "lparam", 0) ;Unlock Taskbar
    ControlSend('[Class:Shell_TrayWnd]', '', '', '!{Space}' & '{m}' & '{Up}') ;Prepare TaskBar For Movement

        If $ScreenPosX = 'Left' Then
            MouseMove(0, @DesktopHeight/2, 0)
        ElseIf $ScreenPosX = 'Right' Then
            MouseMove(@DesktopWidth/1.25, @DesktopHeight/2, 0)
        ElseIf $ScreenPosX = 'Top' Then
            MouseMove(@DesktopWidth/2, 0, 0)
        Elseif $ScreenPosX = 'Bottom' Then
            MouseMove(@DesktopWidth/2, @DesktopHeight, 0)
        ElseIf IsNumber($ScreenPosX) And IsNumber($ScreenPosY) Then
            MouseMove($ScreenPosX, $ScreenPosY, 0)
        EndIf
        
    ControlSend('[Class:Shell_TrayWnd]', '', '', '{Enter}') ;Complete Movemenet
    ControlHide('[Class:Shell_TrayWnd]', '', '[CLASS:TrayClockWClass; INSTANCE:1]') ;Refresh Icons To New Location
    ControlShow('[Class:Shell_TrayWnd]', '', '[CLASS:TrayClockWClass; INSTANCE:1]')
    
    If Not $LockState Then DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", WinGetHandle("[CLASS:Shell_TrayWnd]"), "uint", 273, "wparam", 424, "lparam", 1) ;Relock Taskbar
    
    Local $NewTaskBarPos = WinGetPos('[Class:Shell_TrayWnd]') ;Get New TaskBar State
    
    If IsArray($TaskBarPos) And IsArray($NewTaskBarPos) And Not($TaskBarPos[0]+$TaskBarPos[1]=$NewTaskBarPos[0]+$NewTaskBarPos[1]) Then
        Return 1 ;Sucess
    Else
        Return 0 ;Failure    
    EndIf    
EndFunc

Example

#Region Varaibles
    #NoTrayIcon
    #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w7
    #AutoIt3Wrapper_UseUpx=n
    Opt('SendKeyDelay', 0)
#EndRegion

_MoveTaskBar('Left') ;Move to Left Side of Main Screen
Sleep(1250)

_MoveTaskBar('Right') ;Move to Right Side of Main Screen
Sleep(1250)

_MoveTaskBar('Bottom') ;Move to Bottom of Main Screen
Sleep(1250)

_MoveTaskBar('Top') ;Move to Top of Main Screen
Sleep(1250)

_MoveTaskBar(960, 0) ;Move to Top Screen, on a 1920 / 1080 Resoulation. This function can be used for muti-moitor screens.
Edited by IanN1990
Link to comment
Share on other sites

So you finally came up with a method.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...