Sign in to follow this  
Followers 0
vestanpance

Adding an Input Control to the taskbar.

2 posts in this topic

Hi experts  :bye: 

This is my very first post, so please be gentle :)

I've been using AutoIt for about a year now, on and off creating useful scripts. I've never asked for help, preferring  to use the forums for ideas on how to proceed, the help file when i know what I'm looking for and Google when all else fails.

I recently created a gui with an input box. When you put in a mac address of a network device(for example:) A1-B2-C3-D4-E5-F6) into a textbox, with the click of a button it would automatically convert it into A1B2.C3D4.E5F6 and copy it to the clipboard. (this is the prefered style of mac-address)

For convenience and (maybe people would find it useful in other ways) i have posted that script below.

There are probably better ways of doing what i've concocted below but, it works...

(The resolution part is because sometimes my laptop is docked, other times it isnt...)

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <ColorConstants.au3>
#Include <Restart.au3>

Global $Input1
Global $resolution
GUISetState(@SW_SHOW)

_Desktop_Resolution()
_MacFormat()

Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon

Func _MacFormat()
    If $resolution = "1280 x 1024" Then $Form1 = GUICreate("MAC-Converter", 165, 35, 1110, 961, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    If $resolution = "1440 x 900" Then $Form1 = GUICreate("MAC-Converter", 165, 35, 1277, 833, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW))
    If $resolution = "1152 x 864" Then $Form1 = GUICreate("MAC-Converter", 200, 35, 946, 777, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW))

    ;Make the window slightly transparent
    WinSetTrans($Form1, "", 230)
    GUISetState(@SW_SHOW)
    $Input1 = GUICtrlCreateInput("MAC to convert", 5, 8, 98, 21)
    $Button1 = GUICtrlCreateButton("Convert", 108, 8, 50, 21)
    GUICtrlSetState($Input1, $GUI_FOCUS)

    Sleep(500)
    Local $hWnd = WinGetHandle("[ACTIVE]")
    WinSetOnTop($hWnd, "", 1)


    While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $Button1
                _ModMyMac()
        EndSwitch

    WEnd
EndFunc   ;==>_MacFormat

Func _ModMyMac()
    Global $datamac = GUICtrlRead($Input1)
    $datamac = StringLower($datamac)
    If StringInStr($datamac, ".") Then
        GUICtrlSetData($Input1, $datamac)
    EndIf

    If StringInStr($datamac, "-") Then
        Local $aDays = StringSplit($datamac, "-") ; Split the string of days using the delimeter "," and the default flag value.
        $datamac = $aDays[1] & $aDays[2] & "." & $aDays[3] & $aDays[4] & "." & $aDays[5] & $aDays[6]
    EndIf
    GUICtrlSetData($Input1, $datamac)
    GUICtrlSetState($Input1, $GUI_FOCUS)
    ClipPut($datamac)
    GUICtrlSetState($Input1, $GUI_NOFOCUS)
    _ScriptRestart()
EndFunc   ;==>_ModMyMac

Func _IsChecked($iControlID)
    Return BitAND(GUICtrlRead($iControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Func _Desktop_Resolution()
    Global $resolution
    Switch $resolution = ""
        Case @DesktopWidth = 1280 And @DesktopHeight = 1024;    Super eXtended Graphics Array
            $resolution = "1280 x 1024"

        Case @DesktopWidth = 1440 And @DesktopHeight = 900;     Wide Super eXtended Graphics Array
            $resolution = "1440 x 900"

        Case @DesktopWidth = 1152 And @DesktopHeight = 864;     Wide Super eXtended Graphics Array
            $resolution = "1152 x 864"


        Case Else
            Return SetError(1, 0, $resolution)
    EndSwitch
    Return $resolution

EndFunc   ;==>_Desktop_Resolution

What i am here to ask is...... I'd like to take this input box and place it into the taskbar itself, right next to the clock...

I used to use an Application in the past that created an input box in the taskbar, which gave me the initial idea..

There doesn't appear to be a great deal on this topic, but i did find something called 'rebar'

Going along those lines, so far i've come up with this.

#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <GuiComboBox.au3>
#include <GuiDateTimePicker.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>


  Local $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
        Local $hRebar = ControlGetHandle($hTaskBar, "", "ReBarWindow321")
    $hReBar =  ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ReBarWindow321")

;~ $hgui = GUICreate("", 100, 20, -1, -1, -1,0)
;~     DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hgui, "hwnd", WinGetHandle("Program Manager"))
;~     $hToolbar = _GUICtrlToolBar_Create($hReBar)
;~ $hInput = GUICtrlCreateInput("Input control", 10, 0, 120, 20)
$hInput = _GUICtrlEdit_Create($hReBar, "Input control", 950, 2, 120, 20)
While 1
    sleep(10)
    WEnd

It's not finished, but i have hit some complications. The input box isn't selectable, so i can't type anything in. 

It also seems the whole taskbar becomes 'locked' until the script is stopped.

I'm probably going down the wrong path, but i've proven to myself it's at least a little bit possible by even managing to get a textbox into the taskbar.

Can someone please point me in the right direction.

Many thanks,

Daz

Share this post


Link to post
Share on other sites



I'm still struggling to make this work..... :ermm: 

Can anyone please assist....?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0