ZoltanE Posted February 9, 2010 Posted February 9, 2010 Hello, I'd like to make a custom toolbar for Photoshop. I had the "click on a button to send a shortcut to PS" part covered, but I have difficulties with the toolbar windows. What I'd like to have is my toolbar "AlwaysOnTop" if PS is active, but not if PS is not active. (So the toolbar won't be visible on top of other apps.) This is where I'm at: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", 2) ;Looks for partial matches in window titles. GUICreate("My Photoshop toolbar", 200, 100, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUISetState(@SW_SHOW) $AlreadyOnTop = false While 1 $msg = GUIGetMsg() ;If Photoshop is active and not always on top... If WinActive("Adobe Photoshop CS") <> 0 AND Not($AlreadyOnTop) then GUISetStyle(-1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $AlreadyOnTop = True GUICtrlSetData($okbutton,"OnTop!") EndIf ;If neither Photoshop or our toolbar is active... If WinActive("Adobe Photoshop CS") = 0 AND WinActive("My Photoshop toolbar") = 0 then GUISetStyle(-1, $WS_EX_TOOLWINDOW) $AlreadyOnTop = False GUICtrlSetData($okbutton,"NOT OnTop.") EndIf Select Case $msg = $okbutton WinActivate("Adobe Photoshop CS") ;Sleep(10) WinWaitActive("Adobe Photoshop CS") Send("^!+{F1}") Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd The button's label changes as expected but the toolbar isn't on top of PS for some reason. Also, the set style makes the button flicker, so I was wondering if there is a better way to check active windows. I'd appreciate any help.
Moderators Melba23 Posted February 9, 2010 Moderators Posted February 9, 2010 ZoltanE, This is the function I use to keep a toolbar on another app synchronised with the app: Func _Toolbar_State() ; If Application minimised, then hide toolbar and do nothing If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ; If Application not minimised Else ; Hide ToolBar when Application not active If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And $fToolBar_Vis = True Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $fToolBar_Vis = False Then GUISetState(@SW_SHOW, $hToolBar) WinActivate($hApplication_Wnd) $fToolBar_Vis = True EndIf ; If visible check toolbar position If $fToolBar_Vis = True Then _Toolbar_Follow() EndIf EndFunc ;==>_Toolbar_State If anything is not clear, please ask. 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
ZoltanE Posted February 9, 2010 Author Posted February 9, 2010 Wow, thanks! But I'm not sure how to use it... I assume $hApplication_Wnd is a var storing the ID (?) of the app I'm interested in. How can I get that? $hToolBar is the window I created, right? What does the _Toolbar_Follow() function do? Where should I place this function in my main loop (which checks the control events)?
Moderators Melba23 Posted February 9, 2010 Moderators Posted February 9, 2010 ZoltanE, Take a look at this: expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", 2) Global $iLast_X, $iLast_Y, $fToolBar_Vis = True Global $sMain_Title = "Notepad" If Not WinExists($sMain_Title) Then Run("Notepad.exe") WinWait($sMain_Title) EndIf Global $hApplication_Wnd = WinGetHandle($sMain_Title) Global $iApplication_PID = WinGetProcess($sMain_Title) ConsoleWrite($hApplication_Wnd & @CRLF) Global $hToolBar = GUICreate("ToolBar", 100, 30, 10, 10, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Global $hLabel = GUICtrlCreateLabel("", 0, 0, 100, 30) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState() _Toolbar_Follow() While 1 ; Check Application is running If Not ProcessExists($iApplication_PID) Then Exit ; Hide/show toolbar as required _Toolbar_State() Local $iMsg = GUIGetMsg() Switch $iMsg Case $hLabel ; Deal with the event MsgBox(0, "ToolBar", "Toolbar clicked") ; Reset Application window focus WinActivate($hApplication_Wnd) EndSwitch WEnd Func _Toolbar_Follow() Local $aApplication_Pos = WinGetPos($hApplication_Wnd) If $aApplication_Pos[0] <> $iLast_X Or $aApplication_Pos[1] <> $iLast_Y Then $iLast_X = $aApplication_Pos[0] $iLast_Y = $aApplication_Pos[1] WinMove($hToolBar, '', $aApplication_Pos[0] + 360, $aApplication_Pos[1] + 5) EndIf EndFunc ;==>_Toolbar_Follow Func _Toolbar_State() ; If Application minimised, then hide toolbar and do nothing If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ; If Application not minimised Else ; Hide ToolBar when Application not active If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And $fToolBar_Vis = True Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $fToolBar_Vis = False Then GUISetState(@SW_SHOW, $hToolBar) WinActivate($hApplication_Wnd) $fToolBar_Vis = True EndIf ; If visible check toolbar position If $fToolBar_Vis = True Then _Toolbar_Follow() EndIf EndFunc ;==>_Toolbar_State Ask if anything is unclear. 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
ZoltanE Posted February 10, 2010 Author Posted February 10, 2010 Thank you very much dear Sir! Nicely done. /me tips hat.
ZoltanE Posted February 10, 2010 Author Posted February 10, 2010 One last thing: how can I detect if the toolbar was moved manually? I'm now using the following style for the toolbar: BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST) I tested if WinGetState is 8, but it only worked if I dragged the window and then clicked on the header quickly. (I think I was able to hit the label created on the toolbar through the header.) Only dragging didn't make the toolbar active. I also tried $GUI_EVENT_MOUSEMOVE, which only works when you first go to the toolbar and move it. If your mouse doesn't move between drags then it won't register. I don't get why I lose focus from the toolbar after I click on its title bar.
ZoltanE Posted February 10, 2010 Author Posted February 10, 2010 (edited) I don't get why I lose focus from the toolbar after I clickon its title bar.Okay, that I understand now. Slowly but surely. EDIT: I got everything working. Instead of a tool window, I went back using your original popup style and handled the dragging myself.Cheers again. Edited February 10, 2010 by ZoltanE
Moderators Melba23 Posted February 10, 2010 Moderators Posted February 10, 2010 ZoltanE, Getting the toolbar to stay in a new position after it is dragged there is easy. But before I post a new version, what do you want to happen to the toolbar when you click the closure [X]? Exit? Hide? If Hide, then how do you want to get it back? HotKey? If so, which one? 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
ZoltanE Posted February 10, 2010 Author Posted February 10, 2010 (edited) Everything is working as a prototype, yay! At this point the only way to close the toolbar directly is through the AutoIt systray icon which is fine with me. And of course if I close the watched app it exits as well. I'll post the whole thing when I had everything up and running. Maybe someone will find it useful later one. In theory it should be easy to adapt it to any application. Edited February 10, 2010 by ZoltanE
Moderators Melba23 Posted February 10, 2010 Moderators Posted February 10, 2010 ZoltanE, Her is my version to keep the toolbar where you put it. The toolbar closes when the [X] is clicked. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Opt("WinTitleMatchMode", 2) Global $iLast_X, $iLast_Y, $fToolBar_Vis = True, $iX = 360, $iY = 5 Global $sMain_Title = "Notepad" If Not WinExists($sMain_Title) Then Run("Notepad.exe") WinWait($sMain_Title) EndIf Global $hApplication_Wnd = WinGetHandle($sMain_Title) Global $iApplication_PID = WinGetProcess($sMain_Title) ConsoleWrite($hApplication_Wnd & @CRLF) Global $hToolBar = GUICreate("ToolBar", 90, 30, 10, 10, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Global $hLabel_1 = GUICtrlCreateLabel("1", 0, 0, 30, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) Global $hLabel_2 = GUICtrlCreateLabel("2", 30, 0, 30, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) Global $hLabel_3 = GUICtrlCreateLabel("3", 60, 0, 30, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUISetState() _Toolbar_Follow() ;Register move event GUIRegisterMsg($WM_MOVE, "MY_WM_MOVE") While 1 ; Check Application is running If Not ProcessExists($iApplication_PID) Then Exit ; Hide/show toolbar as required _Toolbar_State() Local $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ; Quit Exit Case $hLabel_1 ; Deal with the event MsgBox(0, "ToolBar", "Button 1 clicked") ; Reset Application window focus WinActivate($hApplication_Wnd) Case $hLabel_2 ; Deal with the event MsgBox(0, "ToolBar", "Button 2 clicked") ; Reset Application window focus WinActivate($hApplication_Wnd) Case $hLabel_3 ; Deal with the event MsgBox(0, "ToolBar", "Button 3 clicked") ; Reset Application window focus WinActivate($hApplication_Wnd) EndSwitch WEnd Func MY_WM_MOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $hWnd = $hToolBar Then ; if toolbar moved set new relative position Local $aApplication_Pos = WinGetPos($hApplication_Wnd) Local $aToolBarPos = WinGetPos($hToolBar) $iX = Abs($aApplication_Pos[0] - $aToolBarPos[0]) $iY = Abs($aApplication_Pos[1] - $aToolBarPos[1]) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_MOVE Func _Toolbar_Follow() Local $aApplication_Pos = WinGetPos($hApplication_Wnd) If $aApplication_Pos[0] <> $iLast_X Or $aApplication_Pos[1] <> $iLast_Y Then $iLast_X = $aApplication_Pos[0] $iLast_Y = $aApplication_Pos[1] WinMove($hToolBar, '', $aApplication_Pos[0] + $iX, $aApplication_Pos[1] + $iY) EndIf EndFunc ;==>_Toolbar_Follow Func _Toolbar_State() ; If Application minimised, then hide toolbar and do nothing If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ; If Application not minimised Else ; Hide ToolBar when Application not active If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And $fToolBar_Vis = True Then GUISetState(@SW_HIDE, $hToolBar) $fToolBar_Vis = False ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $fToolBar_Vis = False Then GUISetState(@SW_SHOW, $hToolBar) WinActivate($hApplication_Wnd) $fToolBar_Vis = True EndIf ; If visible check toolbar position If $fToolBar_Vis = True Then _Toolbar_Follow() EndIf EndFunc ;==>_Toolbar_State Looking forward to your script. 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
ZoltanE Posted February 12, 2010 Author Posted February 12, 2010 Here is the alpha release:expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=.\mypstoolbar.kxf Global $hToolBar = GUICreate("ToolBar", 755, 56, 0, 0, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(0xD6D6D6) $DragLabel = GUICtrlCreatePic(".\DragArea.bmp", 0, 0, 20, 55, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetCursor (-1, 9) $_New = GUICtrlCreateButton("_New", 25, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x60.bmp", -1, 0) $_Open = GUICtrlCreateButton("_Open", 50, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x61.bmp", -1) $_Save = GUICtrlCreateButton("_Save", 75, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x62.bmp", -1) $_Saveas = GUICtrlCreateButton("_Saveas", 100, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x63.bmp", -1) $_Exportpng = GUICtrlCreateButton("_Exportpng", 125, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x64.bmp", -1) $_Exporttga = GUICtrlCreateButton("_Exporttga", 150, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x66.bmp", -1) $_Exportjpg = GUICtrlCreateButton("_Exportjpg", 175, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x65.bmp", -1) $_Showgrid = GUICtrlCreateButton("_Showgrid", 235, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x67.bmp", -1) $_Snaptogrid = GUICtrlCreateButton("_Snaptogrid", 260, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x68.bmp", -1) $_Showguides = GUICtrlCreateButton("_Showguides", 285, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x69.bmp", -1) $_Snaptoguides = GUICtrlCreateButton("_Snaptoguides", 310, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x70.bmp", -1) $_Gridsetup = GUICtrlCreateButton("_Gridsetup", 335, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x71.bmp", -1) $_Offset = GUICtrlCreateButton("_Offset", 370, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x72.bmp", -1) $_Resize = GUICtrlCreateButton("Button4", 395, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x76.bmp", -1) $_Rotateleft = GUICtrlCreateButton("Button5", 420, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x73.bmp", -1) $_Rotateright = GUICtrlCreateButton("Button1", 445, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x74.bmp", -1) $_Rotatefree = GUICtrlCreateButton("Button2", 470, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x75.bmp", -1) $_Mirrorh = GUICtrlCreateButton("Button3", 495, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x77.bmp", -1) $_Mirrorv = GUICtrlCreateButton("Button4", 520, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x78.bmp", -1) $_Crop = GUICtrlCreateButton("Button5", 555, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x16.bmp", -1) $_Move = GUICtrlCreateButton("Button1", 25, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x1.bmp", -1) $_Selectpath = GUICtrlCreateButton("Button2", 50, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x2.bmp", -1) $_Selectrect = GUICtrlCreateButton("Button3", 80, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x7.bmp", -1) $_Lasso = GUICtrlCreateButton("Button4", 105, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x11.bmp", -1) $_Lassopoly = GUICtrlCreateButton("Button5", 130, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x12.bmp", -1) $_Lassomagnet = GUICtrlCreateButton("Button1", 155, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x13.bmp", -1) $_Quickselect = GUICtrlCreateButton("Button2", 180, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x14.bmp", -1) $_Magicwand = GUICtrlCreateButton("Button3", 205, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x15.bmp", -1) $_Spothealing = GUICtrlCreateButton("Button4", 240, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x23.bmp", -1) $_Healing = GUICtrlCreateButton("Button5", 265, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x24.bmp", -1) $_Patch = GUICtrlCreateButton("Button1", 290, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x25.bmp", -1) $_Clone = GUICtrlCreateButton("Button2", 315, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x32.bmp", -1) $_Brush = GUICtrlCreateButton("Button3", 350, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x27.bmp", -1) $_Pencil = GUICtrlCreateButton("Button4", 375, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x28.bmp", -1) $_Eraserback = GUICtrlCreateButton("Button5", 475, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x35.bmp", -1) $_Erasermagic = GUICtrlCreateButton("Button1", 500, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x36.bmp", -1) $_Blur = GUICtrlCreateButton("Button2", 535, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x39.bmp", -1) $_Sharpen = GUICtrlCreateButton("Button3", 560, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x40.bmp", -1) $_Smudge = GUICtrlCreateButton("Button4", 585, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x41.bmp", -1) $_Gradient = GUICtrlCreateButton("Button5", 450, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x38.bmp", -1) $_Pen = GUICtrlCreateButton("_Pen", 400, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x45.bmp", -1) $_Paintbucket = GUICtrlCreateButton("_Paintbucket", 425, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x37.bmp", -1) $_Layernew = GUICtrlCreateButton("_Layernew", 590, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x80.bmp", -1) $_Layercopy = GUICtrlCreateButton("_Layercopy", 615, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x81.bmp", -1) $_Groupmake = GUICtrlCreateButton("_Groupmake", 640, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x83.bmp", -1) $_Mergedown = GUICtrlCreateButton("_Mergedown", 665, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x84.bmp", -1) $_Mergevisible = GUICtrlCreateButton("_Mergevisible", 690, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x86.bmp", -1) $_Layerdelete = GUICtrlCreateButton("_Layerdelete", 725, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x87.bmp", -1) $_FBlurgauss = GUICtrlCreateButton("_FBlurgauss", 615, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x88.bmp", -1) $_FBlursmart = GUICtrlCreateButton("_FBlursmart", 640, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x89.bmp", -1) $_FSharpen = GUICtrlCreateButton("_FSharpen", 665, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x90.bmp", -1) $_FFilterforge = GUICtrlCreateButton("_FFilterforge", 690, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x91.bmp", -1) $_Exporttexture = GUICtrlCreateButton("_Exporttexture", 200, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x92.bmp", -1) GUICtrlCreateLabel("", 22, 28, 730, 1, $SS_BLACKRECT) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Opt("WinTitleMatchMode", 2) Global $bToolBar_OnTop = True ; Store "AlwaysOnTop" state. Global $aLastPos[2] ; Last position of the target app. Global $aOffset[2] ; The toolbar's offset relative to the target app. Global $aMouseInfo ; Mouse info. Global $aMouseLastPos[2] ; Previous position of the mouse. Global $aMouseDelta[2] ; The relative movement of the maouse since last check. Global $sMain_Title = "Adobe Photoshop CS" ; The (partial) name of the target application. Global $hApplication_Wnd = WinGetHandle($sMain_Title) ; Target app window handle. Global $iApplication_PID = WinGetProcess($sMain_Title) ; Target app process ID. Global $aApplicationPos ; The position of the target app. Global $aToolbarPos ; The position of the toolbar. $aApplicationPos = WinGetPos($hApplication_Wnd) ; Get target app position. $aMouseDelta[0] = 0 ; Initialize variable. $aMouseDelta[1] = 0 ; Initialize variable. $aOffset[0] = 985 ; Initial toolbar offset, X. $aOffset[1] = 8 ; Initial toolbar offset, Y. If Not ProcessExists($iApplication_PID) Then Exit ; Check Application is running. WinActivate($sMain_Title) ; If its running then activate it. WinWaitActive($sMain_Title) WinMove($hToolBar, '', $aApplicationPos[0] + $aOffset[0], $aApplicationPos[1] + $aOffset[1]) ; Move toolbar to desired position. Toolbar_Follow() While 1 If Not ProcessExists($iApplication_PID) Then Exit ; Exit if the target app is not running. Toolbar_State() ; Toggle "AlwaysOnTop" setting as required. Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI. Switch $iMsg ; Handle controls. Case $_New WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^n") Case $_Open WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^o") Case $_Save WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^s") Case $_Saveas WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("+^s") Case $_Exportpng WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exporttga WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exportjpg WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exporttexture WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Showgrid WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^{'}") Case $_Snaptogrid WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F1}") Case $_Showguides WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^{;}") Case $_Snaptoguides WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F2}") Case $_Gridsetup WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F3}") Case $_Offset WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F4}") Case $_Resize WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!i") Case $_Rotateleft WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F5}") Case $_Rotateright WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F6}") Case $_Rotatefree WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F7}") Case $_Mirrorh WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F8}") Case $_Mirrorv WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F9}") Case $_Crop WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("c") Case $_Layernew WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+n") Case $_Layercopy WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^j") Case $_Groupmake WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{'}") Case $_Mergedown WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^e") Case $_Mergevisible WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+e") Case $_Layerdelete WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+{'}") Case $_Move WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("v") Case $_Selectpath WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("a") Case $_Selectrect WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("m") Case $_Lasso WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("l") Case $_Lassopoly WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("d") Case $_Lassomagnet WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("f") Case $_Quickselect WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("k") Case $_Magicwand WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("w") Case $_Spothealing WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("j") Case $_Healing WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("n") Case $_Patch WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("r") Case $_Clone WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("s") Case $_Brush WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("b") Case $_Pencil WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("q") Case $_Pen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("p") Case $_Paintbucket WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("t") Case $_Gradient WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("g") Case $_Eraserback WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("e") Case $_Erasermagic WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("y") Case $_Blur WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("o") Case $_Sharpen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("z") Case $_Smudge WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("h") Case $_FBlurgauss WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F10}") Case $_FBlursmart WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F11}") Case $_FSharpen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F12}") Case $_FFilterforge WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{`}") Case $DragLabel $aMouseInfo = GUIGetCursorInfo($hToolbar) $aMouseLastPos[0] = $aMouseInfo[0] $aMouseLastPos[1] = $aMouseInfo[1] While $aMouseInfo[2] = 1 ; While LMB is held down... $aToolbarPos = WinGetPos($hToolbar) ; Get actual toolbar position. $aMouseInfo = GUIGetCursorInfo($hToolbar) ; Get mouse info. $aMouseDelta[0] = $aMouseInfo[0] - $aMouseLastPos[0] ; Get relative mouse movement on X. $aMouseDelta[1] = $aMouseInfo[1] - $aMouseLastPos[1] ; Get relative mouse movement on Y. $aOffset[0] = $aOffset[0]+$aMouseDelta[0] ; Modify the target app relative offset on X. $aOffset[1] = $aOffset[1]+$aMouseDelta[1] ; Modify the target app relative offset on Y. WinMove($hToolBar, '', $aToolbarPos[0] + $aMouseDelta[0], $aToolbarPos[1] + $aMouseDelta[1]) ; Move the toolbar. WEnd WinActivate($hApplication_Wnd) ; Switch back to the target app. EndSwitch WEnd Func Toolbar_Follow() $aApplicationPos = WinGetPos($hApplication_Wnd) If $aApplicationPos <> 0 then ; If the target app is still around... If $aApplicationPos[0] <> $aLastPos[0] Or $aApplicationPos[1] <> $aLastPos[1] Then ; If the target app has moved... $aLastPos[0] = $aApplicationPos[0] ; Store actual X position. $aLastPos[1] = $aApplicationPos[1] ; Store actual Y position. WinMove($hToolBar, '', $aApplicationPos[0] + $aOffset[0], $aApplicationPos[1] + $aOffset[1]) ; Relocate the toolbar. EndIf EndIf EndFunc Func Toolbar_State() If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then ; If the target app is minimised... WinSetOnTop($hToolBar,"",0) ; Turn off "AlwaysOnTop". $bToolBar_OnTop = False ; Remember this state. Else ; If the target app is not minimised... ; If neither the target app nor the toolbar is active but the toolbar is still "AlwaysOnTop"... If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And BitAND(WinGetState($hToolBar), 8) <> 8 And $bToolBar_OnTop = True Then WinSetOnTop($hToolBar,"",0) ; Turn off "AlwaysOnTop". $bToolBar_OnTop = False ; Remember this state. ; If the target app is active but the toolbar is not yet "AlwaysOnTop"... ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $bToolBar_OnTop = False Then WinSetOnTop($hToolBar,"",1) ; Turn on "AlwaysOnTop". WinActivate($hApplication_Wnd) ; Switch to target app. $bToolBar_OnTop = True ; Remember this state. EndIf If $bToolBar_OnTop = True Then ; If toolbar is "AlwaysOnTop"... Toolbar_Follow() ; Reposition it. EndIf EndIf EndFuncThe images for the buttons are here: http://www.sparkingspot.com/temp/MyPSToolbar_icons.zipPlease note that without my customized shortcuts not all buttons will work.
Moderators Melba23 Posted February 12, 2010 Moderators Posted February 12, 2010 (edited) ZoltanE,Nice looking. But have you tried to minimize the App window? I have to use Notepad becasue I do not have PhotoShop but that should not change the price of fish. When I minimize the App, it pops up again instantly! I am trying to locate the problem - I will keep you posted.M23Edit:Got it! You are WinActivating the App every pass through the While...WEnd loop so it can never be minimised! Just comment out that line.But you do not hide the toolbar when the app window is minimised - hardly surprising as you obviously were not intending to minimize it! Look at the code I posted just above yours - I was hiding/showing the toolbar when the app was minimized rather than playing with the ONTOP style. It is a simple fix to the Toolbar_State function - just replace as follows:WinSetOnTop($hToolBar,"",1) ; lines with GUISetState(@SW_SHOW, $hToolBar) ; And WinSetOnTop($hToolBar,"",0) ; lines with GUISetState(@SW_HIDE, $hToolBar) Edited February 12, 2010 by Melba23 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
ZoltanE Posted February 12, 2010 Author Posted February 12, 2010 (edited) Damn, you're right... I screwed up something during the cleanup... EDIT: ...or more like before that. It seems to me that it happens if the target app gets minimized and the toolbar gets back the focus. I think I can fix it quickly, stay tuned. Edited February 12, 2010 by ZoltanE
Moderators Melba23 Posted February 12, 2010 Moderators Posted February 12, 2010 ZoltanE, Crossed posts - look at the edit above! 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
ZoltanE Posted February 12, 2010 Author Posted February 12, 2010 In the loop I switch back to the target app afterany kind of interaction. I do that so the toolbaritself won't keep focus and I end up where I was.What I'm trying to do is the following:- If the target app is not minimized then thetoolbar should be visible above it.Now I realize that I'd need a function likePutWindowAbove($Toolbar, $Targetapp). Is therea way to do this?- I'd like to keep the toolbar visible if thetarget app created a child window (like file open).My actual version stays on top sometimes even if the target app isn't active. No idea whyit's so inconsistent...There seems to be a difference between activatinga program by clicking on its taskbar button andclicking on its caption. In the former case thetoolbar stays on top until I click on the other app.Clicking on the taskbar button a few times fixesthe issue... o_OAlt+Tab works alright.I give it another hour and then fall back to yourshow/hide routine.Here is my actual state. The only changes are at thebeginning of the Toolbar_State() function.expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=.\mypstoolbar.kxf Global $hToolBar = GUICreate("ToolBar", 755, 56, 0, 0, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(0xD6D6D6) $DragLabel = GUICtrlCreatePic(".\DragArea.bmp", 0, 0, 20, 55, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetCursor (-1, 9) $_New = GUICtrlCreateButton("_New", 25, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x60.bmp", -1, 0) $_Open = GUICtrlCreateButton("_Open", 50, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x61.bmp", -1) $_Save = GUICtrlCreateButton("_Save", 75, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x62.bmp", -1) $_Saveas = GUICtrlCreateButton("_Saveas", 100, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x63.bmp", -1) $_Exportpng = GUICtrlCreateButton("_Exportpng", 125, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x64.bmp", -1) $_Exporttga = GUICtrlCreateButton("_Exporttga", 150, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x66.bmp", -1) $_Exportjpg = GUICtrlCreateButton("_Exportjpg", 175, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x65.bmp", -1) $_Showgrid = GUICtrlCreateButton("_Showgrid", 235, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x67.bmp", -1) $_Snaptogrid = GUICtrlCreateButton("_Snaptogrid", 260, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x68.bmp", -1) $_Showguides = GUICtrlCreateButton("_Showguides", 285, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x69.bmp", -1) $_Snaptoguides = GUICtrlCreateButton("_Snaptoguides", 310, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x70.bmp", -1) $_Gridsetup = GUICtrlCreateButton("_Gridsetup", 335, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x71.bmp", -1) $_Offset = GUICtrlCreateButton("_Offset", 370, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x72.bmp", -1) $_Resize = GUICtrlCreateButton("Button4", 395, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x76.bmp", -1) $_Rotateleft = GUICtrlCreateButton("Button5", 420, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x73.bmp", -1) $_Rotateright = GUICtrlCreateButton("Button1", 445, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x74.bmp", -1) $_Rotatefree = GUICtrlCreateButton("Button2", 470, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x75.bmp", -1) $_Mirrorh = GUICtrlCreateButton("Button3", 495, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x77.bmp", -1) $_Mirrorv = GUICtrlCreateButton("Button4", 520, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x78.bmp", -1) $_Crop = GUICtrlCreateButton("Button5", 555, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x16.bmp", -1) $_Move = GUICtrlCreateButton("Button1", 25, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x1.bmp", -1) $_Selectpath = GUICtrlCreateButton("Button2", 50, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x2.bmp", -1) $_Selectrect = GUICtrlCreateButton("Button3", 80, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x7.bmp", -1) $_Lasso = GUICtrlCreateButton("Button4", 105, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x11.bmp", -1) $_Lassopoly = GUICtrlCreateButton("Button5", 130, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x12.bmp", -1) $_Lassomagnet = GUICtrlCreateButton("Button1", 155, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x13.bmp", -1) $_Quickselect = GUICtrlCreateButton("Button2", 180, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x14.bmp", -1) $_Magicwand = GUICtrlCreateButton("Button3", 205, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x15.bmp", -1) $_Spothealing = GUICtrlCreateButton("Button4", 240, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x23.bmp", -1) $_Healing = GUICtrlCreateButton("Button5", 265, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x24.bmp", -1) $_Patch = GUICtrlCreateButton("Button1", 290, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x25.bmp", -1) $_Clone = GUICtrlCreateButton("Button2", 315, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x32.bmp", -1) $_Brush = GUICtrlCreateButton("Button3", 350, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x27.bmp", -1) $_Pencil = GUICtrlCreateButton("Button4", 375, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x28.bmp", -1) $_Eraserback = GUICtrlCreateButton("Button5", 475, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x35.bmp", -1) $_Erasermagic = GUICtrlCreateButton("Button1", 500, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x36.bmp", -1) $_Blur = GUICtrlCreateButton("Button2", 535, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x39.bmp", -1) $_Sharpen = GUICtrlCreateButton("Button3", 560, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x40.bmp", -1) $_Smudge = GUICtrlCreateButton("Button4", 585, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x41.bmp", -1) $_Gradient = GUICtrlCreateButton("Button5", 450, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x38.bmp", -1) $_Pen = GUICtrlCreateButton("_Pen", 400, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x45.bmp", -1) $_Paintbucket = GUICtrlCreateButton("_Paintbucket", 425, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x37.bmp", -1) $_Layernew = GUICtrlCreateButton("_Layernew", 590, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x80.bmp", -1) $_Layercopy = GUICtrlCreateButton("_Layercopy", 615, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x81.bmp", -1) $_Groupmake = GUICtrlCreateButton("_Groupmake", 640, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x83.bmp", -1) $_Mergedown = GUICtrlCreateButton("_Mergedown", 665, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x84.bmp", -1) $_Mergevisible = GUICtrlCreateButton("_Mergevisible", 690, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x86.bmp", -1) $_Layerdelete = GUICtrlCreateButton("_Layerdelete", 725, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x87.bmp", -1) $_FBlurgauss = GUICtrlCreateButton("_FBlurgauss", 615, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x88.bmp", -1) $_FBlursmart = GUICtrlCreateButton("_FBlursmart", 640, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x89.bmp", -1) $_FSharpen = GUICtrlCreateButton("_FSharpen", 665, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x90.bmp", -1) $_FFilterforge = GUICtrlCreateButton("_FFilterforge", 690, 30, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x91.bmp", -1) $_Exporttexture = GUICtrlCreateButton("_Exporttexture", 200, 0, 26, 26, BitOR($BS_BITMAP,$WS_GROUP)) GUICtrlSetImage(-1, ".\Icons_1x92.bmp", -1) GUICtrlCreateLabel("", 22, 28, 730, 1, $SS_BLACKRECT) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Opt("WinTitleMatchMode", 2) Global $bToolBar_OnTop = True ; Store "AlwaysOnTop" state. Global $aLastPos[2] ; Last position of the target app. Global $aOffset[2] ; The toolbar's offset relative to the target app. Global $aMouseInfo ; Mouse info. Global $aMouseLastPos[2] ; Previous position of the mouse. Global $aMouseDelta[2] ; The relative movement of the maouse since last check. Global $sMain_Title = "Adobe Photoshop CS" ; The (partial) name of the target application. Global $hApplication_Wnd = WinGetHandle($sMain_Title) ; Target app window handle. Global $iApplication_PID = WinGetProcess($sMain_Title) ; Target app process ID. Global $aApplicationPos ; The position of the target app. Global $aToolbarPos ; The position of the toolbar. $aApplicationPos = WinGetPos($hApplication_Wnd) ; Get target app position. $aMouseDelta[0] = 0 ; Initialize variable. $aMouseDelta[1] = 0 ; Initialize variable. $aOffset[0] = 985 ; Initial toolbar offset, X. $aOffset[1] = 8 ; Initial toolbar offset, Y. If Not ProcessExists($iApplication_PID) Then Exit ; Check Application is running. WinActivate($sMain_Title) ; If its running then activate it. WinWaitActive($sMain_Title) WinMove($hToolBar, '', $aApplicationPos[0] + $aOffset[0], $aApplicationPos[1] + $aOffset[1]) ; Move toolbar to desired position. Toolbar_Follow() While 1 If Not ProcessExists($iApplication_PID) Then Exit ; Exit if the target app is not running. Toolbar_State() ; Toggle "AlwaysOnTop" setting as required. Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI. Switch $iMsg ; Handle controls. Case $_New WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^n") Case $_Open WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^o") Case $_Save WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^s") Case $_Saveas WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("+^s") Case $_Exportpng WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exporttga WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exportjpg WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Exporttexture WinActivate($sMain_Title) WinWaitActive($sMain_Title) ;Send("^o") Case $_Showgrid WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^{'}") Case $_Snaptogrid WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F1}") Case $_Showguides WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^{;}") Case $_Snaptoguides WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F2}") Case $_Gridsetup WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F3}") Case $_Offset WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F4}") Case $_Resize WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!i") Case $_Rotateleft WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F5}") Case $_Rotateright WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F6}") Case $_Rotatefree WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F7}") Case $_Mirrorh WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F8}") Case $_Mirrorv WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F9}") Case $_Crop WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("c") Case $_Layernew WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+n") Case $_Layercopy WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^j") Case $_Groupmake WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{'}") Case $_Mergedown WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^e") Case $_Mergevisible WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+e") Case $_Layerdelete WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^+{'}") Case $_Move WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("v") Case $_Selectpath WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("a") Case $_Selectrect WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("m") Case $_Lasso WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("l") Case $_Lassopoly WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("d") Case $_Lassomagnet WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("f") Case $_Quickselect WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("k") Case $_Magicwand WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("w") Case $_Spothealing WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("j") Case $_Healing WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("n") Case $_Patch WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("r") Case $_Clone WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("s") Case $_Brush WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("b") Case $_Pencil WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("q") Case $_Pen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("p") Case $_Paintbucket WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("t") Case $_Gradient WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("g") Case $_Eraserback WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("e") Case $_Erasermagic WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("y") Case $_Blur WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("o") Case $_Sharpen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("z") Case $_Smudge WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("h") Case $_FBlurgauss WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F10}") Case $_FBlursmart WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F11}") Case $_FSharpen WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{F12}") Case $_FFilterforge WinActivate($sMain_Title) WinWaitActive($sMain_Title) Send("^!+{`}") Case $DragLabel $aMouseInfo = GUIGetCursorInfo($hToolbar) $aMouseLastPos[0] = $aMouseInfo[0] $aMouseLastPos[1] = $aMouseInfo[1] While $aMouseInfo[2] = 1 ; While LMB is held down... $aToolbarPos = WinGetPos($hToolbar) ; Get actual toolbar position. $aMouseInfo = GUIGetCursorInfo($hToolbar) ; Get mouse info. $aMouseDelta[0] = $aMouseInfo[0] - $aMouseLastPos[0] ; Get relative mouse movement on X. $aMouseDelta[1] = $aMouseInfo[1] - $aMouseLastPos[1] ; Get relative mouse movement on Y. $aOffset[0] = $aOffset[0]+$aMouseDelta[0] ; Modify the target app relative offset on X. $aOffset[1] = $aOffset[1]+$aMouseDelta[1] ; Modify the target app relative offset on Y. WinMove($hToolBar, '', $aToolbarPos[0] + $aMouseDelta[0], $aToolbarPos[1] + $aMouseDelta[1]) ; Move the toolbar. WEnd WinActivate($hApplication_Wnd) ; Switch back to the target app. EndSwitch WEnd Func Toolbar_Follow() $aApplicationPos = WinGetPos($hApplication_Wnd) If $aApplicationPos <> 0 then ; If the target app is still around... If $aApplicationPos[0] <> $aLastPos[0] Or $aApplicationPos[1] <> $aLastPos[1] Then ; If the target app has moved... $aLastPos[0] = $aApplicationPos[0] ; Store actual X position. $aLastPos[1] = $aApplicationPos[1] ; Store actual Y position. WinMove($hToolBar, '', $aApplicationPos[0] + $aOffset[0], $aApplicationPos[1] + $aOffset[1]) ; Relocate the toolbar. EndIf EndIf EndFunc Func Toolbar_State() If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then ; If the target app is minimised... WinSetState($hToolbar, "", @SW_HIDE) ; Hide toolbar. Else ; If the target app is not minimised... WinSetState($hToolbar, "", @SW_SHOW) ; Show toolbar. If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 Then ; If the target app is not active... If $bToolBar_OnTop = True then ; If the toolbar is "AlwaysOnTop"... WinSetOnTop($hToolBar,"",0) ; Turn off "AlwaysOnTop". $bToolBar_OnTop = False ; Remember this state. Endif ; If the target app is active but the toolbar is not yet "AlwaysOnTop"... ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $bToolBar_OnTop = False Then WinSetOnTop($hToolBar,"",1) ; Turn on "AlwaysOnTop". WinActivate($hApplication_Wnd) ; Switch to target app. $bToolBar_OnTop = True ; Remember this state. EndIf If $bToolBar_OnTop = True Then ; If toolbar is "AlwaysOnTop"... Toolbar_Follow() ; Reposition it. EndIf EndIf EndFunc
Moderators Melba23 Posted February 12, 2010 Moderators Posted February 12, 2010 ZoltanE,In the loop I switch back to the target app after any kind of interactionYou are quite correct in doing this - I misread your code. Sorry. Now I realize that I'd need a function like PutWindowAbove($Toolbar, $Targetapp).As a matter of fact there is! Look at _WinAPI_SetWindowPos in the Help file.And I still prefer my WM_MOVE setting of the coordinates to your $DragLabel code - but then we could be arguing all day! 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
ZoltanE Posted February 12, 2010 Author Posted February 12, 2010 Thanks for the tip, I'll check out that SetWindowPos thing. I totally forgot to dissect your drag solution... :] I have to wrap this thing up today, we'll see how far I can get. Then I start using this in production and see if it needs some more polish. Then I post the whole pack with icons and the workspace file.
ZoltanE Posted February 14, 2010 Author Posted February 14, 2010 As it turns out the "toolbar stays on top for no good reason" issue had a pretty good reason: an unecessary WinSetState($hToolbar, "", @SW_SHOW) line. It wasn't needed in the "app window inactive" branch of the state checks, because it is not possible to bring back an app from minimize right into an inactive state. But the line was not just unnecessary but actually screwed up things: it showed the window, but also brought it to the top of the window list as well. (Not "always on top", just once.) The randomness was caused by the timing: sometimes the set state command was quick enough to do its job before other apps became active, so the newcomer covered up the toolbar. But sometimes the set state finished after another app was already on the top of the Z order, forcing the toolbar above the wrong app. Live and learn...
Moderators Melba23 Posted February 14, 2010 Moderators Posted February 14, 2010 ZoltanE,Live and learn... Always!When you are satisifed with what you have, please post it so we can all see another implementation of the toolbar idea.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
ZoltanE Posted February 17, 2010 Author Posted February 17, 2010 I've made a topic for the actual (and any new) version: http://www.autoitscript.com/forum/index.php?showtopic=110172
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