Delete a field of text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Delete a field of text

16 Sep 2015, 10:36

I have some field I want to change the information in.

My idea is to use the command below, to clear the field .:

Code: Select all

ControlSend , Edit1, {End}{LShift Down}{Home}{LShift Up}{Delete}, %WinID%
it seems to work.

But how do I know that field have been emptied before new data is written in the field?

Need the field be checked by the instructions below, before the new information is written in the field?

Code: Select all

ControlGetText Var1, Edit1, %WinID%
If StrLen(Var1) > 0
	MsgBox the field was not empty
else
	ControlSend , Edit1, %Info1%, %WinID%
or is it unnecessary?
Some other way / better way, to solve my wishes?

It is not good if the information does not have time to be erased, before new information is written.

//Jan
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Delete a field of text

16 Sep 2015, 10:52

try this

Code: Select all

PGDN::
ControlGetText, ctext, Edit1, Untitled - Notepad
if ctext = 
   ControlSetText, Edit1, hello`, this is the new text, Untitled - Notepad
else
   ControlSetText, Edit1, , Untitled - Notepad
return
:wave: There is always more than one way to solve a problem. ;)
Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Re: Delete a field of text

18 Sep 2015, 07:21

Thank you!
The problem is that if there is already text in the field, the text shall be cleared / deleted.
Maybe is the best way to be sure that the field is empty is to read the field again and wait if the field is not empty.

//Jan

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mstrauss2021 and 332 guests