Jump to content

Recommended Posts

Posted (edited)

I have been playing with this for a very long time... so heres where I am now. Basically... The important fact is that the taskbar is a window, and is far from untouchable. what you see there now is a button control, and 2 toolbars. These are very easy to manipulate:

Script 1: Setting the transparency (Also an example of how to copy the volume icon :) )

#NoTrayIcon
Opt ("GUIOnEventMode", 1)
Opt ("TrayOnEventMode", 1)
Opt ("TrayMenuMode", 3)

Global $hStartMenu = WinGetHandle ("[Class:DV2ControlHost]"), $hTaskbar = WinGetHandle ("[Class:Shell_TrayWnd]")

; GUI ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Global $hGUI = GUICreate ("Taskbar transparency Slider", 81, 136, -1, -1, 0x840000C4, 0x00010189)
   GUISetOnEvent (-3, "_Exit")

   GUICtrlCreateLabel ("Transparency", 0, 7, 75, 13, 0x50020001, 0x00000004)

   Global $hSlider = GUIctrlCreateSlider (24, 24, 30, 81, 0x5001061A, 0x00000004)
      GUICtrlSetLimit (-1, 255, 0)
      GUICtrlSetData (-1, 255 - WinGetTrans ($hTaskBar))

   Global $hStart = GUICtrlCreateCheckBox ("&Start menu", 6, 114, 90, 13, 0x50010003, 0x00000004)

   GUIRegisterMsg (0x004E, "WM_NOTIFY")

; TRAY +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TrayCreateItem ("&Slider", -1, 0, 0)
   TrayItemSetState (-1, 512)
   TrayItemSetOnEvent (-1, "_ShowGUI")
TrayCreateItem ("Set &Opaque", -1, 1, 0)
   TrayItemSetOnEvent (-1, "_SetOp")
TrayCreateItem ("Set &invisible", -1, 2, 0)
   TrayItemSetOnEvent (-1, "_SetIn")
TrayCreateItem ("", -1, 3, 0)
TrayCreateItem ("&Exit", -1, 4, 0)
   TrayItemSetOnEvent (-1, "_Exit")

TraySetIcon ("C:\WINDOWS\system32\SHELL32.dll", 40)
TraySetOnEvent (-8, "_ShowGUI")
TraySetClick (16)
TraySetState ()
TraySetToolTip ("Current transparency is: " & WinGetTrans ($hTaskBar))

While 1
   Sleep (1000)
WEnd

Func _ShowGUI ()
   Local $aMousePos = MouseGetPos (), $aWinPos = WinGetClientSize ($hGUI)

   If $aMousePos[0] + $aWinPos[0] > @DesktopWidth Then $aMousePos[0] -= $aWinPos[0]
   If $aMousePos[1] + $aWinPos[1] > @DesktopHeight Then $aMousePos[1] -= $aWinPos[1]
   WinMove ($hGUI, "", $aMousePos[0], $aMousePos[1])

   GUISetState (@SW_SHOW, $hGUI)
   While WinActive ($hGUI)
      Sleep (100)
   WEnd
   GUISetState (@SW_HIDE, $hGUI)
EndFunc ; ==> _ShowGUI

Func _SetOp ()
   _SetTrans (255, True, True)
   GUICtrlSetData ($hSlider, 255)
   TraySetToolTip ("Current transparency is: 255")
EndFunc ; ==> _SetOp

Func _SetIn ()
   _SetTrans (1, True, True)
   GUICtrlSetData ($hSlider, 0)
   TraySetToolTip ("Current transparency is: 0")
EndFunc ; ==> _SetIn

Func WM_NOTIFY ($hWnd, $msgID, $wParam, $lParam)
   If $wParam = $hSlider Then _SetTrans (255 - GUICtrlRead ($hSlider), BitAnd (GUICtrlRead ($hStart), 1), False)
   TraySetToolTip ("Current transparency is: " & 255 - GUICtrlRead ($hSlider))
   If $wParam = $hStart Then
      If BitAnd (GUICtrlRead ($hStart), 1) Then
         _SetTrans (255 - GUICtrlRead ($hSlider), True, False)
         TraySetToolTip ("Current transparency is: " & 255 - GUICtrlRead ($hSlider))
      Else
         WinSetTrans ($hStartMenu, "", 255)
         TraySetToolTip ("Current transparency is: " & 255)
      EndIf
   EndIf
EndFunc ; ==> WM_NOTIFY

Func WinGetTrans($sTitle, $sText = "")
    Local $hWnd = WinGetHandle($sTitle, $sText)
    If Not $hWnd Then Return -1
    Local $aRet = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hWnd, "ptr", 0, "ubyte*", 0, "ptr", 0)
    If @error Or Not $aRet[0] Then Return -1
    Return $aRet[3]
EndFunc ; ==> WinGetTrans

Func _SetTrans ($nTrans, $bStart = True, $bGrad = True, $nSpeed = 1)
   If Not $bGrad Then
      WinSetTrans ($hTaskbar  , "", $nTrans)
      If $bStart Then WinSetTrans ($hStartMenu, "", $nTrans)
   Else
      Local $nCurTrans = WinGetTrans ($hTaskbar)
      If $nCurTrans > $nTrans Then $nSpeed *= - 1

      For $x = $nCurTrans to $nTrans Step $nSpeed
         WinSetTrans ($hTaskbar  , "", $x)
         If $bStart Then WinSetTrans ($hStartMenu, "", $x)
      Next
   EndIf

   Return 1
Endfunc ; ==> _SetTrans

Func _Exit ()
   Exit
Endfunc ; ==> _Exit

Script 2: A rather irritating prank for people who like the start menu.

ControlHide ("[Class:Shell_TrayWnd]", "", "[CLASS:Button; INSTANCE:1]")

While 1
   Sleep (1000)
WEnd

Func OnAutoitExit ()
   ControlShow ("[Class:Shell_TrayWnd]", "", "[CLASS:Button; INSTANCE:1]")
EndFunc ; ==> OnAutoitExit

Script 3: Whats the time?

$sText = ControlGetText ("[Class:Shell_TrayWnd]", "", "[CLASS:TrayClockWClass; INSTANCE:1]")

MsgBox (0, "The time is:", $sText)

Script 4: Hiding a taskbar item.

$hGUI = GUICreate ("Now you see me...")
GUISetState ()
Sleep (1000)
_HideTaskBarItem ($hGUI)
Sleep (5000)

Func _HideTaskBarItem ($hWnd, $sText = "")
   Local $sTitle = WinGetTitle ($hWnd, $sText), $hTray = ControlGetHandle ("[CLASS:Shell_TrayWnd]", "", "[CLASS:ToolbarWindow32; INSTANCE:2]")

   For $i = 0 to _SendMessage($hTray, 1024 + 24)
      $sText = _ToolbarGetText ($i)
      If $sText = $sTitle Then Return _SendMessage($hTray, 1024 + 22, $i)
   Next
EndFunc ; ==> _HideTaskBarItem

Func _ToolbarGetText($iCommandID)
    Local $hTray = ControlGetHandle ("[CLASS:Shell_TrayWnd]", "", "[CLASS:ToolbarWindow32; INSTANCE:2]"), _
      $iBuffer = _SendMessage($hTray, 1024 + 75, $iCommandID)
    If $iBuffer = 0 Then Return SetError(True, 0, "")
    If $iBuffer = 1 Then Return SetError(False, 0, "")
    If $iBuffer <= -1 Then Return SetError(False, -1, "")

    $iBuffer += 1
    $iBuffer *= 2

    Local $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]"), $pBuffer = DllStructGetPtr($tBuffer), $iRet
    Local $tMemMap, $pMemory = _MemInit($hTray, $iBuffer, $tMemMap)
    $iRet = _SendMessage($hTray, 1024 + 75, $iCommandID, $pMemory, 0, "wparam", "ptr")
    _MemRead($tMemMap, $pMemory, $pBuffer, $iBuffer)
    _MemFree($tMemMap)
    Return SetError($iRet > 0, 0, DllStructGetData($tBuffer, "Text"))
EndFunc ; ==> _ToolbarGetText

Mat

Edited by Mat
Posted

thats kinda cool XD

Posted

Which one? the middle two are pretty simple, the first one is me giving it a slightly more user friendly aspect, and the last one... I had to rip GUIToolbar.au3 to shreds to get that one :)

The one problem with the last one is that explorer keeps trying to recreate it. There is probably a way to trigger a function as soon as this happens, but I don't know how to that with a Autoit made GUI, let alone another window!

Mat

Posted

well i was playin around with downloadable WinXP themes to get the transparency of the taskbar... there are a few out there, but i never even thought of trying to do it with autoit it so now i know that you can change the TrayTRANS..... also the hiden items, can't ya just use a Child of the Program Manager (this is an autoit GUI mind you) and your example is good for removing all types of window items.

Posted

well i was playin around with downloadable WinXP themes to get the transparency of the taskbar... there are a few out there, but i never even thought of trying to do it with autoit it so now i know that you can change the TrayTRANS..... also the hiden items, can't ya just use a Child of the Program Manager (this is an autoit GUI mind you) and your example is good for removing all types of window items.

I have seen people setting the parents but... Doesn't that mean that the new child has to inherit certain carecteristics of the parent, such as being now "bottomMost"??

I will try and see what I find.

Mat

Posted

i just add winsetontop ('','',1) in the while loop for that particular autoitGUI if its sent to the back... $WS_EX_TOPMOST sometimes works :\ not always though lol and yeah your right about the characteristics.

Posted

the other (more useful?) thing you can do is edit the text for the item, change the icon etc. I will put together an example for that too :)

Using GUIToolbar.au3 allows you to do it very easily too, I only found that out after having done the hard work!

Mat

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
  • Recently Browsing   0 members

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