[solved] Edit: activate label only if it user have changed it

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

[solved] Edit: activate label only if it user have changed it

29 Aug 2015, 19:01

Hi,

In the example below, how do I check if the edit has modified by the user?
The edit may have been changed via code (another part of the program) and I want to trigger MyLabel only if the user has typed something in it.

Code: Select all

Gui, Add, Edit, vMyTxt gMyLabel

MyLabel:
 ; how do I check if the user typed something?
return
Thanks
Last edited by Azevedo on 30 Aug 2015, 19:20, edited 1 time in total.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Edit: activate label only if it user have changed it

30 Aug 2015, 01:59

Actually what you have will trigger the label every time something is typed into the control

Code: Select all

Gui, Add, Edit, vMyTxt gMyLabel
Gui, Show
Return

MyLabel:
GuiControlGet, Text,, MyTxt
msgbox % Text
Return

GuiClose:
ExitApp
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

Re: Edit: activate label only if it user have changed it

30 Aug 2015, 10:49

"MyTxt" can be changed either by the user input OR by a function/label in the script. I only want "MyLabel" to be triggered when the user inputs.
gilliduck
Posts: 265
Joined: 06 Oct 2014, 15:01

Re: Edit: activate label only if it user have changed it

30 Aug 2015, 13:27

It's not elegant, but it may be a starting point for you. One of the more experienced people on here will probably have a cleaner method of doing so, but here's what I came up with quickly.

Code: Select all

#SingleInstance, Force

EditText := "Initial Text"

Gui, Font, s14
Gui, Add, Edit, vEdit1 gMyLabel, % EditText
Gui, Add, Button, gChange, Auto Change Text
Gui, Show
Return

GuiClose:
ExitApp

MyLabel:
GuiControlGet, Edit1
If (Edit1 != EditText)
	MsgBox % "Label Changed"
Return

Change:
EditText := "New Text"
GuiControl,,Edit1, % EditText
Return
just me
Posts: 9452
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Edit: activate label only if it user have changed it

30 Aug 2015, 15:25

Code: Select all

#NoEnv
Edit1Label := "MyLabel"
Gui, Add, Edit, w400 vEdit1 g%Edit1Label%, Initial Text!
Gui, Add, Button, gChange, Auto Change Text
Gui, Show, , Test
Return

GuiClose:
ExitApp

MyLabel:
GuiControlGet, Edit1
MsgBox, 0, %A_ThisLabel%, %Edit1%
Return

Change:
GuiControl, -g, Edit1
GuiControl, , Edit1, Changed by %A_ThisLabel%!
GuiControl, +g%Edit1Label%, Edit1
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 208 guests