I want to create a toaster popup in a specific window at for instance top left corner that will move with the window if window is moved or resized.
Is this possible?
Many thanx
Link something like toaster popup to specific window
Re: Link something like toaster popup to specific window
This is how I manage moving a window, though I think a better way was shared on the forums.
Code: Select all
#Persistent ; this is a code snippet; there are otherwise hotkeys that make this script persistent
SetTimer, chatmove, 100 ; make it more frequent if you'd like it to be smoother when updating, though a higher frequency is a bit more work on the CPU
return
chatmove:
IfWinExist, fd://0 - VLC media player
WinSetTitle, fd://0 - VLC media player,,%streamer%
IfWinNotExist, %streamer% ahk_exe vlc.exe
{
SetTimer, chatmove, Off
return
}
; So the stuff above is not necessary to the chat movement, technically
WinGetPos, x, y, w, h, %streamer% ahk_exe vlc.exe
If (x=xo) && (y=yo) && (w=wo) && (h=ho)
return
; We get the position of the parent window that we want to tie another window to. If it has not changed, no need to do anything to the tied window.
; the vlc.exe is the parent window
; This script actually has two tied windows to one parent (three total). FirefoxLS and Twitch Emotes are the tied windows.
WinMove, ahk_pid %firefoxLS%,, % x+w, % y+emoteH, 316,% h-emoteH
WinMove, Twitch Emotes,, % x+w, % y, 316, % emoteH
; because we recognize the window has moved, we will update the "old" coordinates to the current coordinates, so we can track future changes.
xo:=x
yo:=y
wo:=w
ho:=h
return
Re: Link something like toaster popup to specific window
Many thanx u set me on the right road and I sorted it out
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Link something like toaster popup to specific window
Below is an example of setting a window as a parent of a Gui.
This will make a button on an Excel window that will then move, minimize, maximize, etc. with the parent window.
The key is DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd).
FG
Code: Select all
Win_Hwnd := WinExist("ahk_exe excel.exe ahk_class XLMAIN")
; Gui Create
Gui, Font, s12, Bold Verdana
Gui, Margin, 0, 0
Gui, Add, Button, xp yp Default gButton, CHILD BUTTON
Gui, +LastFound +ToolWindow +AlwaysOnTop -Caption -Border HWNDGui_Hwnd
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
Gui, Show, x200 y0, Child Button
return
Button:
MsgBox CRY
return
The key is DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd).
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Link something like toaster popup to specific window
Many thanx again but is there a way of giving background colors and font color?
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Link something like toaster popup to specific window
The same as you would for any GUI.smbs wrote:Many thanx again but is there a way of giving background colors and font color?
There is a Font and Color option for GUIs.
Code: Select all
Gui,MyGUI:Color, 202020 ;background color
Gui,MyGUI:Font, c5C5CF0 s17 wbold, Arial ; font color, size, weight, style
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Link something like toaster popup to specific window
FG
Sorry --never saw your post regarding colors
Your suggestions
Does not seem to work unless I am missing something
Have searched the forum and found this in an old post--- see code below
How can I implement above code into your script you posted and change the background and font colors of the GUI?
Sorry --never saw your post regarding colors
Your suggestions
Code: Select all
Gui,MyGUI:Color, 202020 ;background color
Gui,MyGUI:Font, c5C5CF0 s17 wbold, Arial ; font color, size, weight, style
Have searched the forum and found this in an old post--- see code below
Code: Select all
Gui, -Caption +e0x80 +Toolwindow
TransColor = D4D1C8
Gui, Color, %transColor%
Gui, Add, Button, x2 y2 w100 h24 , Test1
;~ Gui, Add, Button, x104 y2 w100 h24 , Test2
;~ Gui, Add, Button, x206 y2 w100 h24 , Test3
Gui, Show, x800 y500 w308 h28
WinGet, k_ID, ID, A ; Get its window ID.
WinSet, AlwaysOnTop, On, ahk_id %k_ID%
WinSet, TransColor, %TransColor% 400, ahk_id %k_ID%
Gui, 2:-Caption +e0x80 +Toolwindow
Gui, 2:Color, white
Gui, 2:Add, Progress, x2 y2 w100 h24 c00B050, 100 ; cFFFF66, 100
;~ Gui, 2:Add, Progress, x104 y2 w100 h24 c87BBFF, 100
;~ Gui, 2:Add, Progress, x206 y2 w100 h24 c00B050, 100
Gui, 2:Show, x800 y500 w308 h28
Return
ButtonTest1:
MsgBox You clicked Test1.
Return
ButtonTest2:
MsgBox You clicked Test2.
Return
ButtonTest3:
MsgBox You clicked Test3.
Return
Esc::ExitApp
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Link something like toaster popup to specific window
I misspoke. Font and Color does not work with buttons. Buttons are special and Windows does most of the work in creating them and uses the default colors of the theme of the window.smbs wrote:FG
Sorry --never saw your post regarding colors
Your suggestionsDoes not seem to work unless I am missing somethingCode: Select all
Gui,MyGUI:Color, 202020 ;background color Gui,MyGUI:Font, c5C5CF0 s17 wbold, Arial ; font color, size, weight, style
The code you show tries to get around this by making a button, setting its background to transparent, and then putting another Gui with a colored progress bar under it to simulate a background.
This is not a great solution but it is one of the simpler ones. There are a ton of post on the forums about making pretty buttons. Another common work around is to create a picture of a button and use Gui, Add, Picture and then make the picture respond to mouse clicks.
But your original post was about a toaster popup, if you don't actually need a button, then you can just use a text Gui. I only used a button as an example because it is what I had in one of my scripts that I could easily copy and paste to show how to "link" a Gui to a window.
This will add a simple text box with green background and red text.
Code: Select all
Win_Hwnd := WinExist("ahk_exe excel.exe ahk_class XLMAIN")
; Gui Create
Gui, Color, Green
Gui, Font, s12 cRed, Bold Verdana
Gui, Add, Text,, This is Text
Gui, +LastFound +ToolWindow +AlwaysOnTop -Caption -Border HWNDGui_Hwnd
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
Gui, Show, x200 y100
return
Esc::ExitApp
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Link something like toaster popup to specific window
Many thanx thats exactly what I needed
Re: Link something like toaster popup to specific window
The above code has been working for me since first posted using vlc media player- I want to use it with mpv media player however it does not work when I input the correct mpv parameters into first line of script-the script runs but no popup is seen---why is mpv behavior different from other media apps?Win_Hwnd := WinExist("ahk_exe excel.exe ahk_class XLMAIN")
; Gui Create
Gui, Font, s12, Bold Verdana
Gui, Margin, 0, 0
Gui, Add, Button, xp yp Default gButton, CHILD BUTTON
Gui, +LastFound +ToolWindow +AlwaysOnTop -Caption -Border HWNDGui_Hwnd
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
Gui, Show, x200 y0, Child Button
return
Button:
MsgBox CRY
return
Many thanx
Who is online
Users browsing this forum: No registered users and 121 guests