help with feature for gui Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

help with feature for gui

11 Feb 2022, 00:44

hey guys, I would like that when the person places the mouse over the Picture in GUI, a Tooltip appears with some instructions.
The way I found to do it was like this:
could there be a better way?

Code: Select all

#SingleInstance, Force

Gui, Add, Picture, x15 y15 w50 h50, ERROR.png
Gui, Show, w200 h200, Test
SetTimer, Feature, On
return

Feature:
	MouseGetPos, mouse_Pos_X, mouse_Pos_Y
	if ((mouse_Pos_X > 15 && mouse_Pos_X < 65) && (mouse_Pos_Y > 15 && mouse_Pos_Y < 65)) {
		ToolTip, Description `nDescription `nDescription `nDescription `n
		RETURN
	}
	ToolTip
RETURN
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: help with feature for gui  Topic is solved

11 Feb 2022, 02:45

Hi ibieel, another way

Code: Select all

#SingleInstance, Force
OnMessage(0x200,"MouseHover")
Gui, Add, Picture , HwndIdIMAGE x15 y15 w50 h50, ERROR.jpg
Gui, Show, w200 h200, Test
return

MouseHover(wParam, lParam, msg, hwnd) {
	 Global IdIMAGE 
   MouseGetPos, , , , CurrControl  ,2
   If (CurrControl=IdIMAGE)   {
       ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
       Return
   }
   ToolTip
}

Donec Perficiam
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: help with feature for gui

11 Feb 2022, 02:47

Also can reference Gui example #5 in the docs.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: help with feature for gui

13 Feb 2022, 18:29

jmeneses wrote:
11 Feb 2022, 02:45
Hi ibieel, another way

Code: Select all

#SingleInstance, Force
OnMessage(0x200,"MouseHover")
Gui, Add, Picture , HwndIdIMAGE x15 y15 w50 h50, ERROR.jpg
Gui, Show, w200 h200, Test
return

MouseHover(wParam, lParam, msg, hwnd) {
	 Global IdIMAGE 
   MouseGetPos, , , , CurrControl  ,2
   If (CurrControl=IdIMAGE)   {
       ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
       Return
   }
   ToolTip
}

the code worked fine.
but I didn't understand the part of: "HwndIdIMAGE" and "Global IdIMAGE"

how did the value of HwndIdIMAGE go to IdIMAGE?
I can't see in the code the part where one value is inserted into the other.

I'm trying to do it for more than 1 image and I couldn't :(
I would like that depending on the image the mouse is in, it sends itself a different tooltip.

can you help me?

Code: Select all

#SingleInstance, Force
OnMessage(0x200,"MouseHover")
Gui, Add, Picture , HwndIdIMAGE x15 y15 w50 h50, ERROR.jpg
Gui, Add, Picture, HwndIdIMAGE x100 y100 w50 h50, ERROR.jpg
Gui, Show, w200 h200, Test
return

MouseHover() {
	 Global IdIMAGE
   MouseGetPos, , , , CurrControl  ,2
   If (CurrControl=IdIMAGE)   {
      ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
       Return
   }
   ToolTip
}

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: help with feature for gui

13 Feb 2022, 22:25

Maybe something like:

Code: Select all

#SingleInstance, Force
OnMessage(0x200,"MouseHover")
Gui, Add, Picture , HwndIdIMAGE x15 y15 w50 h50, ERROR.jpg
Gui, Add, Picture, HwndIdIMAGE2 x100 y100 w50 h50, ERROR.jpg
Gui, Show, w200 h200, Test
return

MouseHover() {
   Global
   MouseGetPos, , , , CurrControl  ,2
   switch CurrControl
   {
       case IdIMAGE:ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
       case IdIMAGE2:ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
   }
}
Using HwndIdIMAGE as a gui option tells the script to assign that control hwnd to the var IdIMAGE.
Click Gui in the code box to bring up the help file.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: help with feature for gui

14 Feb 2022, 00:43

Xtra wrote:
13 Feb 2022, 22:25
Maybe something like:

Code: Select all

#SingleInstance, Force
OnMessage(0x200,"MouseHover")
Gui, Add, Picture , HwndIdIMAGE x15 y15 w50 h50, ERROR.jpg
Gui, Add, Picture, HwndIdIMAGE2 x100 y100 w50 h50, ERROR.jpg
Gui, Show, w200 h200, Test
return

MouseHover() {
   Global
   MouseGetPos, , , , CurrControl  ,2
   switch CurrControl
   {
       case IdIMAGE:ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
       case IdIMAGE2:ToolTip, Description `nDescription1 `nDescription2  `nDescription3 
   }
}
Using HwndIdIMAGE as a gui option tells the script to assign that control hwnd to the var IdIMAGE.
Click Gui in the code box to bring up the help file.
very good, thxx

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, GEOVAN, Google [Bot] and 92 guests