Hi guys, I need you help because I'm not good with GUI stuff
I have a simple GUI showing some pictures and a mouseover code. I would like to apply a transparent layer on top of the pictures so that they will become darker or lighter on mouse over.
There's a simple way to do it?
Thank you
[SOLVED] [GUI] Picture mouse over
[SOLVED] [GUI] Picture mouse over
Last edited by cyruz on 20 May 2015, 12:03, edited 1 time in total.
ABCza on the old forum.
My GitHub.
My GitHub.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: [GUI] Picture mouse over
Not saying that this is simple but its useable
Hope it helps
Code: Select all
#NoEnv
#SingleInstance Force
OnMessage(0x200, "MouseMove")
Gui, Margin, 50, 50
Gui, Add, Picture, Icon8 vMyPic1 +0x0100, %A_WinDir%\System32\shell32.dll
Gui, Add, Picture, Icon22 vMyPic2 +0x0100, %A_WinDir%\System32\shell32.dll
Gui, Show,, test
Return
MouseMove(wParam, lParam, Msg, hWnd)
{
static shown, Overlay_id
Gui, %A_Gui%: +HwndhGui
if (hwnd = Overlay_id) ; return if mouse over overlay gui
return
if ((A_GuiControl = "MyPic1") || (A_GuiControl = "MyPic2")) and (!shown)
{
shown := true
GuiControlGet, %A_GuiControl%, Pos
X := %A_GuiControl%x
Y := %A_GuiControl%y
w := %A_GuiControl%w
h := %A_GuiControl%h
VarSetCapacity(POINT, 8, 0)
NumPut(X, POINT, 0, "Int")
NumPut(Y, POINT, 4, "Int")
DllCall("User32.dll\ClientToScreen", "Ptr", hGui, "Ptr", &POINT)
X := NumGet(POINT, 0, "Int")
Y := NumGet(POINT, 4, "Int")
DetectHiddenWindows on
Gui, 2: Color, FFFFFF
Gui, 2: +hwndOverlay_id +owner%hGui%
WinSet, Transparent, 100, ahk_id %Overlay_id%
Gui, 2: -Caption +ToolWindow
Gui, 2: show, x%x% y%y% h%h% w%w% NA
DetectHiddenWindows off
}
else
{
Gui, 2:Destroy
shown := false
}
}
Courses on AutoHotkey
My Autohotkey Blog
Re: [GUI] Picture mouse over
Ahahaha this is awesome
Showing a small transparent gui on top of the image... Clever!
Thank you Blackholyman.
PS: it works great. May I ask you what option is +0x0100?
Showing a small transparent gui on top of the image... Clever!
Thank you Blackholyman.
PS: it works great. May I ask you what option is +0x0100?
ABCza on the old forum.
My GitHub.
My GitHub.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: [GUI] Picture mouse over
Great thanks and np
+0x0100 is SS_NOTIFY
It's needed for static controls like Text, Pic to use OnMessage with WM_MOUSEMOVE, you can also get a similar result by giving the control a (dummy) g-label
+0x0100 is SS_NOTIFY
It's needed for static controls like Text, Pic to use OnMessage with WM_MOUSEMOVE, you can also get a similar result by giving the control a (dummy) g-label
Courses on AutoHotkey
My Autohotkey Blog
Re: [GUI] Picture mouse over
Thank you for the info
Unfortunately If I put a gLabel on the original picture to catch the click it doesn't work and if I create an empty text in the mouseover gui giving it the gLabel, it works but the over effect flickers a lot... Any idea?
Unfortunately If I put a gLabel on the original picture to catch the click it doesn't work and if I create an empty text in the mouseover gui giving it the gLabel, it works but the over effect flickers a lot... Any idea?
ABCza on the old forum.
My GitHub.
My GitHub.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: [GUI] Picture mouse over
Code: Select all
#NoEnv
#SingleInstance Force
OnMessage(0x200, "MouseMove")
Gui, Margin, 50, 50
Gui, Add, Picture, Icon8 vMyPic1 +0x0100, %A_WinDir%\System32\shell32.dll
Gui, Add, Picture, Icon22 vMyPic2 +0x0100, %A_WinDir%\System32\shell32.dll
Gui, Show,, test
Return
MouseMove(wParam, lParam, Msg, hWnd)
{
static shown, Overlay_id, Text_id
Gui, %A_Gui%: +HwndhGui
if (hwnd = Overlay_id) or (hwnd = Text_id) ; return if mouse over overlay gui
return
if ((A_GuiControl = "MyPic1") || (A_GuiControl = "MyPic2")) and (!shown)
{
shown := true
GuiControlGet, %A_GuiControl%, Pos
X := %A_GuiControl%x
Y := %A_GuiControl%y
w := %A_GuiControl%w
h := %A_GuiControl%h
VarSetCapacity(POINT, 8, 0)
NumPut(X, POINT, 0, "Int")
NumPut(Y, POINT, 4, "Int")
DllCall("User32.dll\ClientToScreen", "Ptr", hGui, "Ptr", &POINT)
X := NumGet(POINT, 0, "Int")
Y := NumGet(POINT, 4, "Int")
DetectHiddenWindows on
Gui, 2: Color, FFFFFF
Gui, 2: +hwndOverlay_id +owner%hGui%
WinSet, Transparent, 100, ahk_id %Overlay_id%
Gui, 2: -Caption +ToolWindow
Gui, 2: Margin, 0, 0
Gui, 2: add, Text, h%h% w%w% hwndText_id go
Gui, 2: show, x%x% y%y% h%h% w%w% NA
DetectHiddenWindows off
}
else
{
Gui, 2:Destroy
shown := false
}
return
o:
msgbox
return
}
Courses on AutoHotkey
My Autohotkey Blog
Re: [GUI] Picture mouse over
Yes that's exactly what I did, but the overlay flickers a lot when you move the mouse... I'm trying to do something with a hotkey.
ABCza on the old forum.
My GitHub.
My GitHub.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: [GUI] Picture mouse over
Hmm not in my tests did you try my example?
Courses on AutoHotkey
My Autohotkey Blog
Re: [GUI] Picture mouse over
Your example works great but if I use some png, like in my case, the overlay flickers a lot
EDIT: Looks like there is something strange, I adapted my gui to your example with 2 fixed images and it is not flickering. In my final code i calculate the size dinamically, depending on the number of images (it's a kind of launcher), but I get a lot of flicker... I have to find what is causing that.
EDIT2: Found the problem, i forgot to declare static the hwnd of the text control...
EDIT: Looks like there is something strange, I adapted my gui to your example with 2 fixed images and it is not flickering. In my final code i calculate the size dinamically, depending on the number of images (it's a kind of launcher), but I get a lot of flicker... I have to find what is causing that.
EDIT2: Found the problem, i forgot to declare static the hwnd of the text control...
ABCza on the old forum.
My GitHub.
My GitHub.
Who is online
Users browsing this forum: Lamron750 and 374 guests