LukasChury Posted September 27, 2023 Share Posted September 27, 2023 (edited) Hi, I have the code, that create an element, which hide (overlay) Close a Minimalize buttons of the Chromium App. (Because I need that users close the App on the Web in Chromium, because beforeunload dont work already in these days and I need make some clear things before App exit...). I found an solution that hide the buttons (overlay them) and works fine (if is better solution, maybe without overlay, happy to listen! 🙂 ) But I need run my AutoIt program without taskbar icon - only in tray, if needed. All that I tried and found on this forum do not work 😞 If I use @SW_HIDE, element that overlay the close buttons will disappears too. My code: expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <ColorConstants.au3> #include <WinAPISys.au3> #include <Constants.au3> Local $ySize=_WinAPI_GetSystemMetrics ( 31 ) + 8 ;~ SM_CYSIZE Local $xSize=_WinAPI_GetSystemMetrics ( 30 ) + 56 ;~ SM_CXSIZE Local $sizeBlock=86 Local $adjustment=$sizeBlock+ 8 + 6 Local $hGui=GUICreate("Welcome", $xSize, $ySize, 100, 100, BitOR($WS_SYSMENU,$WS_POPUP), 0) GUISetBkColor($COLOR_WHITE,$hGui) ; Display the GUI. $hwndActive=wingethandle("My App", "") GUISetState(@SW_SHOW, $hGUI) WinActivate($hwndActive) ; Loop until the user exits. While 1 $hwndActive=wingethandle("My App", "") if ($hWndActive <> $hGui) Then $hwndPrevious=$hwndActive $aPos = WinGetPos("My App") $newColor=pixelgetcolor($apos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor,$hGui) EndIf ;~ WinMove($hGui,"",$apos[0], $aPos[1]) ; Apply the style _WinAPI_SetWindowPos($hGui, $HWND_TOPMOST, $apos[0] + $aPos[2] - $adjustment, $apos[1]+1, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOSIZE)) WEnd Is there a way to OTHER SOLUTION FOR HIDE CLOSE/MINIMALIZE BUTTON or HIDE ICON OF AUTOIT COMPILED EXE SCRIPT IN TASKBAR (with the overlay show on)? Thanks a lot. Edited September 27, 2023 by LukasChury Link to comment Share on other sites More sharing options...
ioa747 Posted September 27, 2023 Share Posted September 27, 2023 one way i know is with $WS_EX_TOOLWINDOW #NoTrayIcon #include <WindowsConstants.au3> $xSize = 200 $ySize = 200 Local $hGui=GUICreate("Welcome", $xSize, $ySize, 100, 100, $WS_SYSMENU, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;********************************** Xandy 1 I know that I know nothing Link to comment Share on other sites More sharing options...
LukasChury Posted September 27, 2023 Author Share Posted September 27, 2023 15 minutes ago, ioa747 said: one way i know is with $WS_EX_TOOLWINDOW #NoTrayIcon #include <WindowsConstants.au3> $xSize = 200 $ySize = 200 Local $hGui=GUICreate("Welcome", $xSize, $ySize, 100, 100, $WS_SYSMENU, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;********************************** It doesnt work as I need to. Link to comment Share on other sites More sharing options...
LukasChury Posted September 27, 2023 Author Share Posted September 27, 2023 But i finally found the solution (thanks to ChatGPT 🙂 ). #include <WinAPI.au3> ;Just for where the $hGui variable is: ;Local $hGui=GUICreate("Welcome", $xSize, $ySize, 100, 100, BitOR($WS_SYSMENU,$WS_POPUP), 0) _WinAPI_ShowWindow($hGui, @SW_HIDE) ; Hide the window _WinAPI_SetWindowLong($hGui, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hGui, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW)) ; Set the window as a tool window WinSetState($hGui, "", @SW_HIDE) ; Hide the window from the taskbar Iam so happy 🙂 Xandy 1 Link to comment Share on other sites More sharing options...
Nine Posted September 27, 2023 Share Posted September 27, 2023 Another approach, that allows to move the window and change z-order of windows : #NoTrayIcon #include <WinAPI.au3> #include <GUIConstants.au3> Run("Notepad") Local $hApp = WinWait("[CLASS:Notepad]") Local $iHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Local $iWidth = 100 Local $aPos = WinGetPos($hApp), $aPosPrev = $aPos Local $hOver = GUICreate("Over", $iWidth - 8, $iHeight, $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOWNOACTIVATE) _WinAPI_SetWindowLong($hOver, $GWL_HWNDPARENT, $hApp) While WinExists($hApp) Sleep(10) $aPos = WinGetPos($hApp) If $aPos[0] = $aPosPrev[0] And $aPos[1] = $aPosPrev[1] Then ContinueLoop WinMove($hOver, "", $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1) WEnd LukasChury 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Solution LukasChury Posted September 27, 2023 Author Solution Share Posted September 27, 2023 6 hours ago, Nine said: Another approach, that allows to move the window and change z-order of windows : #NoTrayIcon #include <WinAPI.au3> #include <GUIConstants.au3> Run("Notepad") Local $hApp = WinWait("[CLASS:Notepad]") Local $iHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Local $iWidth = 100 Local $aPos = WinGetPos($hApp), $aPosPrev = $aPos Local $hOver = GUICreate("Over", $iWidth - 8, $iHeight, $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOWNOACTIVATE) _WinAPI_SetWindowLong($hOver, $GWL_HWNDPARENT, $hApp) While WinExists($hApp) Sleep(10) $aPos = WinGetPos($hApp) If $aPos[0] = $aPosPrev[0] And $aPos[1] = $aPosPrev[1] Then ContinueLoop WinMove($hOver, "", $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1) WEnd Thank you! I add the changing the background of the overlay, and now it works nicely! 🙂 The final code: #NoTrayIcon #include <WinAPI.au3> #include <GUIConstants.au3> Local $hApp = WinWait("My App") Local $iHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Local $iWidth = 100 Local $aPos = WinGetPos($hApp), $aPosPrev = $aPos Local $hOver = GUICreate("Over", $iWidth - 8, $iHeight+7, $aPos[0] + $aPos[2] - $iWidth, $aPos[1]+1, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOWNOACTIVATE) $newColor=pixelgetcolor($apos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor,$hOver) _WinAPI_SetWindowLong($hOver, $GWL_HWNDPARENT, $hApp) While WinExists($hApp) Sleep(10) $newColor=pixelgetcolor($apos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor,$hOver) $aPos = WinGetPos($hApp) If $aPos[0] = $aPosPrev[0] And $aPos[1] = $aPosPrev[1] Then ContinueLoop WinMove($hOver, "", $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1) WEnd Link to comment Share on other sites More sharing options...
Nine Posted September 27, 2023 Share Posted September 27, 2023 Man you don't seem to understand the principle of "Solution". Maybe you should take a moment to reflect on it.... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ioa747 Posted September 28, 2023 Share Posted September 28, 2023 #NoTrayIcon #include <WinAPI.au3> #include <GUIConstants.au3> Local $hApp = WinWait("My App") Local $iHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Local $iWidth = 100 Local $aPos = WinGetPos($hApp), $aPosPrev = $aPos Local $hOver = GUICreate("Over", $iWidth - 8, $iHeight + 7, $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1, $WS_POPUP, $WS_EX_TOOLWINDOW, $hApp) ; * <- 1 ;~ GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOWNOACTIVATE) WinActivate($hApp) ; * <- 2 $newColor = PixelGetColor($aPos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor, $hOver) ;~ _WinAPI_SetWindowLong($hOver, $GWL_HWNDPARENT, $hApp) While WinExists($hApp) Sleep(10) ;~ $newColor = PixelGetColor($aPos[0] + $aPos[2] - 106, $aPos[1] + 14) ;~ GUISetBkColor($newColor, $hOver) If WinActive($hOver) Then WinActivate($hApp) ; * <- 3 $aPos = WinGetPos($hApp) If @error Then Exit ConsoleWrite('-> unexpected exit' & @CRLF) ; * <- 4 If $aPos[0] = $aPosPrev[0] And $aPos[1] = $aPosPrev[1] Then ContinueLoop $aPosPrev = $aPos ; * <- 5 WinMove($hOver, "", $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1) WEnd LukasChury 1 I know that I know nothing Link to comment Share on other sites More sharing options...
LukasChury Posted September 28, 2023 Author Share Posted September 28, 2023 (edited) 1 hour ago, ioa747 said: #NoTrayIcon #include <WinAPI.au3> #include <GUIConstants.au3> Local $hApp = WinWait("My App") Local $iHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Local $iWidth = 100 Local $aPos = WinGetPos($hApp), $aPosPrev = $aPos Local $hOver = GUICreate("Over", $iWidth - 8, $iHeight + 7, $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1, $WS_POPUP, $WS_EX_TOOLWINDOW, $hApp) ; * <- 1 ;~ GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOWNOACTIVATE) WinActivate($hApp) ; * <- 2 $newColor = PixelGetColor($aPos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor, $hOver) ;~ _WinAPI_SetWindowLong($hOver, $GWL_HWNDPARENT, $hApp) While WinExists($hApp) Sleep(10) ;~ $newColor = PixelGetColor($aPos[0] + $aPos[2] - 106, $aPos[1] + 14) ;~ GUISetBkColor($newColor, $hOver) If WinActive($hOver) Then WinActivate($hApp) ; * <- 3 $aPos = WinGetPos($hApp) If @error Then Exit ConsoleWrite('-> unexpected exit' & @CRLF) ; * <- 4 If $aPos[0] = $aPosPrev[0] And $aPos[1] = $aPosPrev[1] Then ContinueLoop $aPosPrev = $aPos ; * <- 5 WinMove($hOver, "", $aPos[0] + $aPos[2] - $iWidth, $aPos[1] + 1) WEnd Thank you! 🙂 But if you remove this two lines inside While: $newColor = PixelGetColor($aPos[0] + $aPos[2] - 106, $aPos[1] + 14) GUISetBkColor($newColor, $hOver) Then the background of "Over" is no updated while the window is active/unactive. (because the background of Title window has different color when Window is active/unactive) Is there a better solution with this? Edited September 28, 2023 by LukasChury 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