update text of toolTipGui is not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

update text of toolTipGui is not working

15 Feb 2019, 08:50

update text of littleGui is not working

step by step. today much often with your help. thanks.

Code: Select all

loop,3
	toolTipGui1 := toolTipGui(x,y,A_Tickcount ":" A_ScriptName) 
inside the function i tried:

Code: Select all

GuiControl,  , % HGUI, text ; update text
; ^--- not working
		
GuiControl,  , % "ahk_id " HGUI, text ; update text
; ^--- not working

Code: Select all

;/¯¯¯¯ toolTipGui ¯¯ 190214201449 ¯¯ 14.02.2019 20:14:49 ¯¯\
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=62024&p=263617#p263617
; Gui1 := toolTipGui(10,10,"1 1 1 1") ; toolTipGui(x, y, text, title := "", bgColor := "", fontSize := 0)
; GuiControl,  , % Gui1.HTXT, 11111111
; Gui2 := toolTipGui(10,100,"2 2 2 2")
toolTipGui(x, y, text, title := "", bgColor := "", fontSize := 0){
	if(!title)
		title := "title1902121943"
	if(!bgColor)
		bgColor := "Green"
	if(!fontSize)
		fontSize := 10
	DetectHiddenWindows,Off
	settitlematchmode,3
	; ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe 
	; UniqueID := WinExist(WinTitle , WinText, ExcludeTitle, ExcludeText)
	titleClass := title " ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe"
	If( HGUI := WinExist( titleClass )){ ; eturns the Unique ID (HWND) (

		GuiControl,  , % HGUI, text ; update text
		; ^--- not working
		
		GuiControl,  , % "ahk_id " HGUI, text ; update text
		; ^--- not working
		
		WinMove, % titleClass, , % x , % y - 30 ; - 15
		; msgbox, % HGUI " was found: " titleClass " at x,y ? " x "," y
		
		;WinMove, A,, 10, 10,
		Gui1 := {HGUI: HGUI, HTXT: text} ; HTXT???????????????
		return {HGUI: HGUI, HTXT: text}
	}
	;msgbox, % HGUI " was NOT: " titleClass " at x,y ? " x "," y
	
	; Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +HwndHGUI
	Gui, New, +ToolWindow -SysMenu -Caption +HwndHGUI
	Gui, Color, %bgColor%
	Gui, Font, cWhite s%fontSize% q1, Arial Narrow ;red ; changed s11 to s10
	Gui, Add, Text, y0 hwndHTXT, %text%
	; Return {HGUI: HGUI, HTXT: HTXT} ; Gui1 := toolTipGui()
	Gui1 := {HGUI: HGUI, HTXT: HTXT}
	Gui, % Gui1.HGUI . ":Show", NoActivate x%x% y%y% , % title
	tooltip,WinWait4564213
	WinWait,% title
	tooltip,
	return Gui1 ; older:
}
;\____ toolTipGui __ 190214201453 __ 14.02.2019 20:14:53 __/

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: update text of littleGui is not working

15 Feb 2019, 09:06

I could be misreading something, but it looks like you are trying to get the handle to a window that doesn't exist yet.

If that is the case, then first create the window then get the handle.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 09:09

Hellbent wrote:
15 Feb 2019, 09:06
I could be misreading something, but it looks like you are trying to get the handle to a window that doesn't exist yet.

If that is the case, then first create the window then get the handle.
hmmm. doku says it returns the handle (
returns the Unique ID (HWND)
)
and all hapens isde this if clouse. msgbox works inside and shows me an handly. also winmove works.

Code: Select all

If( HGUI := WinExist( titleClass )){ ; returns the Unique ID (HWND) 

		GuiControl,  , % HGUI, text ; update text
		; ^--- not working
		
		GuiControl,  , % HGUI, text ; update text
		; ^--- not working
		
		GuiControl,  , % "ahk_id " HGUI, text ; update text
		; ^--- not working
		
		WinMove, % titleClass, , % x , % y - 30 ; - 15
		; msgbox, % HGUI " was found: " titleClass " at x,y ? " x "," y
		
		;WinMove, A,, 10, 10,
		Gui1 := {HGUI: HGUI, HTXT: text} ; HTXT???????????????
		return {HGUI: HGUI, HTXT: text}
	}
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: update text of littleGui is not working

15 Feb 2019, 09:18

Is there a reason you are doing


GuiControl, , % HGUI, text ; update text

And not

GuiControl, , % HTXT, text ; update text

?

If that is not the issue, do you have a working sample I can run.

***EDIT***

GuiControl,% HGUI ":" , % HTXT, text ; update text
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 10:09

Hellbent wrote:
15 Feb 2019, 09:18
Is there a reason you are doing


GuiControl, , % HGUI, text ; update text

And not

GuiControl, , % HTXT, text ; update text

?

If that is not the issue, do you have a working sample I can run.

***EDIT***

GuiControl,% HGUI ":" , % HTXT, text ; update text
yes. becouse i dont have HTXT.
HTXT is only the text and not a handle. right?

HGUI is the handle. and gives me not the text.

If( HGUI := WinExist( titleClass )){ ; returns the Unique ID (HWND)
Attachments
working-samle.ahk
(2.1 KiB) Downloaded 20 times
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: update text of littleGui is not working

15 Feb 2019, 10:22

SL5 wrote:
15 Feb 2019, 10:09
HTXT is only the text and not a handle. right?
HGUI is the handle. and gives me not the text.
From what I can see, you are using the handle of the gui as the name
So rather than

Gui,1:,Show,

You have what equates to basically

Gui, 23342122:Show ie. Gui,% HGui ":Show"

So if everything is as shown above

GuiControl,% HGUI ":" , % HTXT , Some Text

Should work.

HTXT is the handel to your text control right?

So it should be

GuiControl, gui name / Subcommand , Control , Output


Edit, Noticed you are using a object.

So

GuiControl,% Gui1.HGUI ":" , % Gui1.HTXT , Some Text
or whatever the returned object is
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 11:44

Hellbent wrote:
15 Feb 2019, 10:22

... HTXT is the handel to your text control right?
if yes, then that would surprise me.
i thought it simply the text.

did you tried the "working-samle.ahk" ?
Hellbent wrote:
15 Feb 2019, 10:22
So it should be
GuiControl,% Gui1.HGUI ":" , % Gui1.HTXT , Some Text
This works from outside.
this also works from outside:
GuiControl, , % Gui1.HTXT, 11111111

but i try change it from inside.
i works moving the GUI like this. only works not changing the text.
you could easy see it in the "working-samle.ahk"

i got a handle inside the function by WinExist and move the GUI. This works:
If( HGUI := WinExist( titleClass )){ ; eturns the Unique ID (HWND) (

did you tried the "working-samle.ahk" ? may this helps
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: update text of littleGui is not working

15 Feb 2019, 12:36

SL5 wrote:
15 Feb 2019, 11:44
did you tried the "working-samle.ahk" ? may this helps
Sorry I didn't see it, but unfortunately I don't download anything so I can't get access to it.


I am curious about 1 thing.

How are you able to use the hwnd of the gui as its name?
As far as I was aware, you need to create a instance of a gui to get its handle, and it's when you create the gui that you give it its name.

In your code you have

Code: Select all

Gui,add
Gui,color
Gui,Font
All of that is the same as

Code: Select all

Gui,1:add
Gui,1:color
Gui,1:Font
Then at the end you have

Gui, % Gui1.HGUI . ":Show", NoActivate x%x% y%y% , % title

How is this working ?
I really don't understand that part.


Anyway, I made this little script a few mins ago.
I wasn't really sure what you are trying to do whit your script, so I just made a guess.

Code: Select all

#SingleInstance,Force
BC:=[]
Output:={}
BC[1]:={X:20,Y:20,W:260,H:30,Message:"`nThis is button 1`nBlah Blah Blah"}
BC[2]:={X:20,Y:70,W:260,H:30,Message:"`nThis is button 2`nBlah Blah Blah"}

Gui,1:+AlwaysOnTop +HwndMainHwnd
Loop 2	{
	Gui,1:Add,Button,% "x" BC[A_Index].X " y" BC[A_Index].Y " w" BC[A_Index].W " h" BC[A_Index].H " hwndbtn" A_Index "hwnd",Button %A_Index%
	BC[A_Index].HWND := btn%A_Index%hwnd
}
Gui,1:Show,w300 h120,Example
SetTimer,Watch_Cursor,100
return
GuiClose:
*^ESC::
	ExitApp
Watch_Cursor:
	MouseGetPos,,,,out,2
	Loop,% BC.Length()
		(out=BC[A_Index].hwnd)?((Active=out)?(return):(OutPut:=ToolTip(Get_Pos(BC[A_Index].hwnd),BC[A_Index],Output,MainHwnd),Active:=BC[A_Index].hwnd))
	if(Active!=out&&WinExist("ahk_id" Output.hwnd)){
		Active:=""
		Gui,ToolTipWindow:Destroy
	}
	return
tooltip(Position,GCon,This,Owner){
	WinGetPos,X,Y,W,H,ahk_id %Owner%,
	if(!WinExist("ahk_id" This.hwnd)){
		Gui,ToolTipWindow:+Owner1 +HWNDName -Caption -SysMenu +Border
		Gui,ToolTipWindow:Color,222222
		Gui,ToolTipWindow:Font,cWhite s12 w600
		This.Hwnd:= Name
		Gui,TooltipWindow:Add,Progress,x10 y10 w200 h100 BackgroundWhite cTeal ,100
		Gui,ToolTipWindow:Add,Text,x10 y10 w200 h100 Center BackgroundTrans hwndHTXT,% GCon.Message
		This.HTXT:=HTXT
		Gui,ToolTipWindow:Show,% "x" X+Position.X+Position.W+10 " y" Y+Position.Y-10 " w220 h120 NA",
		return This
	}else	{
		GuiControl,TooltipWindow:,% This.HTXT,% GCon.Message
		Gui,ToolTipWindow:Show,% "x" X+Position.X+Position.W+10 " y" Y+Position.Y-10 " w220 h120 NA",
		return This
	}
}
Get_Pos(handle){
	GuiControlGet,Pos,pos,% handle
	return {X: posx, Y: posy, W: posw, H: posh}
}
If you can, please post your code here or to pastebin.com or something. Even if I can't help, i'd like to see that name switch in action.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 15:30

> Sorry I didn't see it, but unfortunately I don't download anything so I can't get access to it.
not so bad :-) then I'll send here inline completely (bottom).

> How are you able to use the hwnd of the gui as its name?
>As far as I was aware, you need to create a instance of a gui to get its handle, and it's when you create the gui that you give it its name.
yes. in the first step.

>How is this working ?
>I really don't understand that part.

maybe that's the first time that I have AHK-GUI from the beginner myself.
I have already made many stupid mistakes.
Anyway.

>Anyway, I made this little script a few mins ago.
>I wasn't really sure what you are trying to do whit your script, so I just made a guess.

thanks for your script I have not understood it yet. yes it is important that I explain exactly what I want.

I want a very simple function that requires only one line.
which works much like a tooltip.
that is why she is called like that (tooltipGUI).
If you use the title a second time, the body text will be overwritten.
a bit similar to Tooltips the numbers (1 too 20).
tooltipGUI.gif
tooltipGUI.gif (69.04 KiB) Viewed 1893 times
> If you can, please post your code here or to pastebin.com or something. Even if I can't help, i'd like to see that name switch in action.
sure :-) I was being outside the house so the break.


toolTipGui(text, x, y, hiddenTitle, bgColor, fontSize)
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 16:33

19-02-15_22-31: problem is that i dont have the

ControlID (GuiControl, SubCommand, ControlID , Value)

i have used the GUI handle ( HGUI := WinExist( titleClass ) "ControlID can be the HWND of a control. GUI must also be specified -- except on [v1.1.20+] when ControlID is a HWND, since each HWND is unique." (https://www.autohotkey.com/docs/commands/GuiControl.htm)

so maybe thats not possible then. or i dont know
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

15 Feb 2019, 16:44

works :-)

ControlSetText, Static1, % text, % "ahk_id " HGUI
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: update text of littleGui is not working

15 Feb 2019, 17:25

SL5 wrote:
15 Feb 2019, 15:30
I found your errors.

Have a look.

***Note*** I played with the function call for fun, shouldn't be any harm.

Code: Select all

#SingleInstance,force
message:=["As","Far","As","I","Can","Tell","This","Script","Is","Now","Working","This is a multiline example`nit shows that the gui will auto`nsize even if there is loads of text"]
loop,12
{
toolTipGui1 := toolTipGui(55,55 * (A_Index+1), A_Index " : " message[A_Index], toolTipGui1) ;<--------- added passing the toolTipGui1 object to the function
	sleep,1000
}
return

toolTipGui(x, y, text, toolTipGui1, title := "", bgColor := "", fontSize := 0){
	if(!title)
		title := "title1902121943"
	if(!bgColor)
		bgColor := "Blue"
	if(!fontSize)
		fontSize := 10
	DetectHiddenWindows,Off
	settitlematchmode,3
	titleClass := title " ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe"
	If( HGUI := WinExist( titleClass )){ 
		
		;************Attention**************************
		; if the text changes, then it may not fit any more
		; the best solution might be to just start with a fresh gui each time, but here is a work around
		; steps: create a dummy gui to get the size that the control need to be chaged to and then apply that change and then destroy the dummy gui
		
		;To fully get the point of this. Comment this out and see how it looks.
		;----------------------------------------------------------------------------------------------------
		Gui,Dummy_Gui:Font,s%fontSize% q1, Arial Narrow 										; creating a dummy gui and setting the font to the same as the real gui
		Gui,Dummy_Gui:Add,Text,hwndtemp_Dummy,% text 											; Adding a text control to the dummy gui to get the new size
		GuiControlGet,pos,Dummy_Gui:Pos,% temp_Dummy  											; getting the auto sized dimentions for the new text
		Gui,Dummy_Gui:Destroy 																	; Now that the dimentions are know, the dummy gui gets destroyed.
		GuiControl,% toolTipGui1.HGUI ":Move",% toolTipGui1.Htxt,% "y0 w" posw " h" posh  		; Applying the new dimentions to the real text control
		;----------------------------------------------------------------------------------------------------
		
		
		GuiControl,% toolTipGui1.HGUI ":"  , % toolTipGui1.Htxt,% text   							; Updated sytax
		Gui,% toolTipGui1.HGUI ":Show",% "x" x " y" y-30 " w" posw+20 " h" posh  " NA"				; Winmove works fine, so you can use your old code here np.
		
		

		Gui1 := {HGUI: HGUI, HTXT: text} 
		return {HGUI: HGUI, HTXT: text}
	}
	Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +HwndHGUI
	Gui, Color, %bgColor%
	Gui, Font, cWhite s%fontSize% q1, Arial Narrow 
	Gui,Margin,10,0 													;I added this to keep the updated text with the same margins
	Gui, Add, Text, y0 hwndHTXT, %text%  
	Gui1 := {HGUI: HGUI, HTXT: HTXT}
	Gui, % Gui1.HGUI . ":Show", NoActivate x%x% y%y% , % title
	
	return Gui1 
}
*ESC::ExitApp
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: update text of littleGui is not working

16 Feb 2019, 03:39

Hellbent wrote:
15 Feb 2019, 17:25
I found your errors.
another error?
As you could see i found the error yesterday. solbed it, updated the script here:
:arrow: https://www.autohotkey.com/boards/viewtopic.php?p=263755#p263778 :thumbup: or here: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=62057&p=263778#p263786 :thumbup:

but yes i will take a look in your other version. I am very curious what you did differently.
ah, ok i see. your solution uses a Dummy_Gui and needt therfore 4lines of code more. interesting. Thanks for your ideas, suggestions and your help. hope your feeling great :-)

in the next step I will install that the ifo is _ (bottom) or ¯ (up) or /¯ (leftUp) ... is placed. probably as a value of y.
Hellbent wrote:
15 Feb 2019, 17:25

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 398 guests