3mustgetbeers Posted November 21, 2011 Share Posted November 21, 2011 hello I want to create a 'search bar' that is embedded into the taskbar. When a user enters something into the taskbar then presses enter, an ini file is searched. Does anybody know if this is possible? If not, is it possible to run a gui (with input box) from a single left click of the tray icon? I already the have the script funcioning - however it is by clicking on the tray icon and then selecting a tray icon menu, there is no need for multiple button clicks. If either of these are possible, does anybody know how!? Cheers! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 21, 2011 Moderators Share Posted November 21, 2011 3mustgetbeers, I found this lying around - seems pretty close to the option you say you will accept, although you still have some work to do: expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #Include <GuiToolBar.au3> Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown. TrayCreateItem("About") TrayItemSetOnEvent(-1, "On_About") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "On_Exit") TraySetState() TraySetClick(8) ; Set left click to act as Play/Pause or New TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "On_Dialog") ; Set tray icon tool tip $sToolTipText = "My Dialog" TraySetToolTip($sToolTipText) Global $iIcon_X, $iIcon_Y ; Find the tray icon _Locate_Icon() ; Create and hide the GUI GUICreate("My Dialog", 200, 200, $iIcon_X - 200, $iIcon_Y - 240) GUISetState(@SW_HIDE) While 1 Switch GUIGetMsg() ; Pressing either [_] or [X] rehides the GUI Case $GUI_EVENT_CLOSE, $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) EndSwitch WEnd Func On_Dialog() ; Show the GUI GUISetState(@SW_SHOW) EndFunc Func _Locate_Icon () ; Find taskbar Local $aPos = WinGetPos("[Class:Shell_TrayWnd]", "") ; Start icon position calculation $iIcon_X = $aPos[0] $iIcon_Y = $aPos[1] ; Get systray handle and position Local $hSysTray_Handle = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") $aPos = ControlGetPos("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return ; Continue icon position calculation $iIcon_X += $aPos[0] $iIcon_Y += $aPos[1] ; Get systray item count Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSysTray_ButCount = 0 Then Return ; Look for tooltip by finding track title For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1 Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) If StringInStr($sText, $sToolTipText) > 0 Then ; Get coords of icon $aPos = _GUICtrlToolbar_GetButtonRect($hSysTray_Handle, $iSysTray_ButtonNumber) ; Finalise icon position calculation $iIcon_X += $aPos[0] $iIcon_Y += $aPos[1] ExitLoop EndIf If $iSysTray_ButtonNumber = $iSysTray_ButCount - 1 Then Return 1 Next Return 0 EndFunc Func On_About() MsgBox(0, "About", "Whatever") EndFunc Func On_Exit() Exit EndFunc No idea about the first idea though, sorry. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rcmaehl Posted November 21, 2011 Share Posted November 21, 2011 (edited) Make the GUI an Always on Top Window without any window border or window controls. It won't be embedded into the Taskbar but it will look like it. Also, make sure to give it the tool window extended style so that an unneeded program won't appear in the list or Alt-Tab. This will accomplish what you are attempting. If you need help with what I recommended it can be found in the Autoit documentation. Also an example script will be available upon request. -RC Edited November 21, 2011 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
3mustgetbeers Posted November 21, 2011 Author Share Posted November 21, 2011 M23: Thanks for that. I now have it working to show the GUI on a left click and exit on the right click. -RC: I did toy with that idea but thought it would turn into a nightmare logistically - calculating how far into the taskbar from the right the existing system tray icons come in; then and from the left open programs that show there, what if there are so many open programs they are hidden under the gui etc. Unfortuantely I think these are insurmountable problems which is why it would need to be embedded Cheers! Link to comment Share on other sites More sharing options...
taietel Posted November 21, 2011 Share Posted November 21, 2011 3mustgetbeers, here's another attempt to work on: expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> Global $hSearch _SearchGUI(200, 27) Func _SearchGUI($iW, $iH) Local $hGui, $hExit, $hSrc, $hDum $hGui = GUICreate("Select drives", $iW, $iH, @DesktopWidth - $iW, @DesktopHeight - $iH - 30, BitOR($WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS)) GUISetBkColor(0x000000) $hExit = GUICtrlCreateIcon("shell32.dll", -28, $iW - 22, 5, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetTip(-1, "Close me!...") GUICtrlSetCursor(-1, 0) $hSrc = GUICtrlCreateIcon("shell32.dll", -23, $iW - 42, 5, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetTip(-1, "Start searching!...") GUICtrlSetCursor(-1, 0) $hDum = GUICtrlCreateButton("a", $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) $hSearch = GUICtrlCreateInput("Search...", 5, 5, $iW - 52, $iH - 10, BitOR($GUI_SS_DEFAULT_INPUT, $WS_BORDER), 0) GUICtrlSetColor(-1, 0xDEDEDE) GUICtrlSetBkColor(-1, 0x222222) GUICtrlCreatePic("", 1, 1, $iW - 2, $iH - 2, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS), $GUI_WS_EX_PARENTDRAG) WinSetTrans($hGui, "", 200) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Sleep(10) Switch GUIGetMsg() Case $hExit Exit Case $hSrc, $hDum MsgBox(32, "Found...", 'Here goes your search code for "' & GUICtrlRead($hSearch) & '"') EndSwitch WEnd EndFunc ;==>_SearchGUI Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndSearch If Not IsHWnd($hSearch) Then $hWndSearch = GUICtrlGetHandle($hSearch) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) Switch $hWndFrom Case $hSearch, $hWndSearch Switch $iCode Case $EN_CHANGE ConsoleWrite('changed to "' & GUICtrlRead($hSearch) & '"' & @CRLF) ;just for testing Case $EN_KILLFOCUS ;if nothing was entered, set to default text If GUICtrlRead($hSearch) = "" Then GUICtrlSetData($hSearch, "Search...") ConsoleWrite("lost focus" & @CRLF) ;just for testing Case $EN_SETFOCUS ;if focused, delete the default text If GUICtrlRead($hSearch) = "Search..." Then GUICtrlSetData($hSearch, "") ConsoleWrite("got focus" & @CRLF) ;just for testing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
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