Page 1 of 1

help with feature for gui

Posted: 11 Feb 2022, 00:44
by ibieel
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

Re: help with feature for gui  Topic is solved

Posted: 11 Feb 2022, 02:45
by jmeneses
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
}


Re: help with feature for gui

Posted: 11 Feb 2022, 02:47
by Xtra
Also can reference Gui example #5 in the docs.

Re: help with feature for gui

Posted: 13 Feb 2022, 18:29
by ibieel
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
}


Re: help with feature for gui

Posted: 13 Feb 2022, 22:25
by Xtra
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.

Re: help with feature for gui

Posted: 14 Feb 2022, 00:43
by ibieel
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