How to get a semi transparent windowless popup?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

How to get a semi transparent windowless popup?

07 Dec 2017, 14:17

I want to have a popup message box with data...

I want the background to be semi transparent

I'd love it to be 'Windowless' - i.e. not have the standard outline and title

+ Within the popup... I'd like to have buttons

AND... I'd like to have the popup be 'always ontop'

Can someone tell me where to start?
Happy to follow some pointers and guidelines

Thanks
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: How to get a semi transparent windowless popup?

07 Dec 2017, 14:38

You want the Gui command. Adding -NoCaption to the Gui, Show line's Options section will make it border- and titlebar-less. After showing it, you can use the WinSet command to make the window always be on top and transparent.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: How to get a semi transparent windowless popup?

08 Dec 2017, 04:34

Code: Select all

#SingleInstance, force
#Persistent
#NoEnv
SetBatchLines, -1
SetWinDelay, -1
SetTitleMatchMode 2

OnMessage(0x0201, "WM_LBUTTONDOWN")
gui, -caption +AlwaysOnTop
gui, margin,10,5
gui,color, E4C2B4
gui,add,edit,r5 w200 +HwndEId, % "line#1`nline#2`nline#3`nline#4`nline#5"
gui,add,Button,vBut1 w200 gBut,Do something
gui,add,Button,vBut2 w200 gBut,Do other things
gui,add,Button,vBut3 w200 gBut,Exit
gui,show,x800 y100
SendMessage, 0xB1, -1, 0, , % "ahk_id" EId
WinSet, Transparent, 160,A
return

but:
   if (A_GuiControl = "But3")
      ExitApp
   MsgBox You pressed : %A_GuiControl%   
return

WM_LBUTTONDOWN() {
   If (A_Gui)
      PostMessage, 0xA1, 2
}

GuiClose:
GuiEscape:
   ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

Re: How to get a semi transparent windowless popup?

14 Dec 2017, 18:23

@Odlanir - that is just awesome :)

I have some questions...

1. how do I have a timer and make it disappear after x seconds?

2. Let's say I run code that makes this semi transparent popup with the text in...
Next time I run, I want to detect if the window is already there. If it is, replace the text.
How would I do this?

3. OnMessage(0x0201, "WM_LBUTTONDOWN")
Why is this necessary? I read up and kind of understand that it might be needed.
But if you have buttons, then dont they by default have monitoring around them - so they know when they have been clicked?

4. SendMessage, 0xB1, -1, 0, , % "ahk_id" EId
Erm... where does this come from??

5. but: ??????
erm... where did this come from?
is this some kind of AHK hack?

6. assigning a bespoke action to a button press... how is this done?
I spent 10 minutes trying to read up - cant find anything!
(Surely you dont do it through a series of if statements?)

7. if (A_GuiControl = "But3")
what happened to to the v? as in: vBut3?

8. +HwndEId what is this?
I searched google and not a single result :)

9. SetTitleMatchMode 2
I read this up and dont get what it's useful for?

ANY feedback on my above questions would be great.
Thanks.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: How to get a semi transparent windowless popup?

15 Dec 2017, 06:49

First of all I suggest you to read the AHK manual wich will give you almost all the answers to your questions.
1. how do I have a timer and make it disappear after x seconds?
Just put settimer in your script.
Doing so you should also code a way to reshow the hidden gui.
Some like this:

Code: Select all

settimer, NoShow, -5000 ; will run the subroutine only once after 5 seconds
...
NoShow:
	gui, hide
return
#o:: ; the hotkey windows+o reshow the gui
	settimer, NoShow, -5000
	gui, show
return
2. Let's say I run code that makes this semi transparent popup with the text in...
Next time I run, I want to detect if the window is already there. If it is, replace the text.
How would I do this?
2.You can save your data in the clipboard and with the Guicontrol you can replace the control content with the clipboard data.
3. OnMessage(0x0201, "WM_LBUTTONDOWN")
Why is this necessary? I read up and kind of understand that it might be needed.
But if you have buttons, then dont they by default have monitoring around them - so they know when they have been clicked?
3. This let you drag and move a window with no caption.
4. SendMessage, 0xB1, -1, 0, , % "ahk_id" EId
Erm... where does this come from??
4. The purpose is to unselect the text in edit contol (Eid ) wich otherwise is shown fully selected, sending a message EM_SETSEL ( 0xB1 ) to the handle of the control positioning the caret at the end of the text.
5. but: ??????
erm... where did this come from?
is this some kind of AHK hack?
....
6. assigning a bespoke action to a button press... how is this done?
I spent 10 minutes trying to read up - cant find anything!
(Surely you dont do it through a series of if statements?)
....
7. if (A_GuiControl = "But3")
what happened to to the v? as in: vBut3?
5-6-7. When you want to bind an action on a Gui element ( in this case a Button ) you must specify a subroutine to run when you press the button. As you can see I've code gBut in each button definition. When you press any of the three button the subroutine But will be executed.
To store the control's content in a variable you must specify a variable name prefixed by a v.

read this to better understand the above concepts: https://autohotkey.com/docs/commands/Gui.htm#Events
8. +HwndEId what is this?
I searched google and not a single result :)
8. If you specify Hwndxxx when adding a gui control you get in the var xxx the handle of the control which can be used in several ways, for example to send a window message to the control as explained in point 3.
9. SetTitleMatchMode 2
I read this up and dont get what it's useful for?
9. A window's title can contain WinTitle anywhere inside it to be a match.

This is a version wich will hide the windows after 5 seconds. You can specify a different time ( in milliseconds) in the edit control.
To reshow the gui press windows+o.

Hope this helps.

Code: Select all

#SingleInstance, force
#Persistent
#NoEnv
SetBatchLines, -1
SetWinDelay, -1
SetTitleMatchMode 2

showTime := 5000
OnMessage(0x0201, "WM_LBUTTONDOWN")
gui, -caption +AlwaysOnTop
gui, margin,10,5
gui,color, E4C2B4
gui,add,edit,r5 w200 +HwndEId1 vEdit1, % "line#1`nline#2`nline#3`nline#4`nline#5"
gui,add,text,,Hide after
gui,add,edit,r1 x80 w50 yp-5 +HwndEId2 vEdit2, % showTime
gui,add,Button,x10 vBut1 w200 gBut,Do something
gui,add,Button,vBut2 w200 gBut,Do other things
gui,add,Button,vBut3 w200 gBut,Exit
gui,show,x800 y100,SemiTransparent window
SendMessage, 0xB1, -1, 0, , % "ahk_id" EId1
WinSet, Transparent, 160,A
settimer, NoShow, -%showTime%
return

#IfWinExist, SemiTransparent window
#o::
	gui, submit
	settimer, NoShow, % "-" Edit2
	gui, show
return
#IfWinExist

NoShow:
	gui, hide
return

but:
   if (A_GuiControl = "But3")
      ExitApp
   MsgBox You pressed : %A_GuiControl%   
return

WM_LBUTTONDOWN() {
   If (A_Gui)
      PostMessage, 0xA1, 2
}
esc::
GuiClose:
GuiEscape:
exitapp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Frogrammer and 275 guests