[AHKv2] - Update the GUI Edit value with visible text Topic is solved

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
Finallf
Posts: 7
Joined: 30 Oct 2020, 13:52

[AHKv2] - Update the GUI Edit value with visible text

17 Nov 2020, 12:09

Hello little friends ...

I have a problem to dynamically update the display of a text in a simple GUI.
I'm using this code that I adapted from Window Spy as a debug:

Code: Select all

DebugGui := Gui.New()
DebugGui.Add("Edit","w320 r3 ReadOnly vDebugView")
DebugGui.Show("NoActivate")

DetectHiddenText 0				;
ovVisText := WinGetText()			; put in the loop of my code
UpdateText("DebugView", ovVisText)  ;

UpdateText(vCtl, NewText) {
	static OldText := {}
	ctl := DebugGui[vCtl], hCtl := Integer(ctl.hwnd)
    ;msgbox hCtl
	
	if (!oldText.HasProp(hCtl) Or OldText.%hCtl% != NewText) {
		ctl.Value := NewText
		OldText.%hCtl% := NewText
	}
}
It is working well, without problems, but I wanted to learn how to pass the value directly to Gui Edit, without checking the old text with the new one and without this function.
It would look something like this:

Code: Select all

DebugGui := Gui.New()
DebugGui.Add("Edit","w320 r3 ReadOnly vDebugView")
DebugGui.Show("NoActivate")

DetectHiddenText 0
DebugGui.DebugView.Value := WinGetText()
Already tried:

Code: Select all

DebugGui.vDebugView.Value := WinGetText()
vDebugView.Value := WinGetText()
DebugGui.DebugView.Value := WinGetText()
DebugView.Value := WinGetText()
DebugGui.Value := WinGetText()
But there is always an error, whether the variable has no value or does not exist or is not an object.
How would be the simplest way to pass the value taken by WinGetText (), directly to Gui Edit?

Thanks to All: D
Finallf
Posts: 7
Joined: 30 Oct 2020, 13:52

Re: [AHKv2] - Update the GUI Edit value with visible text

17 Nov 2020, 12:14

Sorry, I only saw the AHK2 help topic after clicking.
Could a moderator please move there.
Thanks again.
Last edited by gregster on 17 Nov 2020, 12:57, edited 1 time in total.
Reason: Done!
swagfag
Posts: 4092
Joined: 11 Jan 2017, 17:59

Re: [AHKv2] - Update the GUI Edit value with visible text  Topic is solved

17 Nov 2020, 12:38

Code: Select all

DebugGui['DebugView'].Value := WinGetText()
Finallf
Posts: 7
Joined: 30 Oct 2020, 13:52

Re: [AHKv2] - Update the GUI Edit value with visible text

17 Nov 2020, 13:02

swagfag wrote:
17 Nov 2020, 12:38

Code: Select all

DebugGui['DebugView'].Value := WinGetText()
Thanks, it worked.

I tried it with square brackets before, but I hadn't used the quotes.

Thanks again.

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 2 guests