AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Does gui edit control has a enter event?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
vital



Joined: 05 Oct 2005
Posts: 17
Location: china

PostPosted: Wed Mar 21, 2007 3:18 pm    Post subject: Does gui edit control has a enter event? Reply with quote

the gui has not any button,only a edit control. i want that when i input any text then stroke enter key, trigger a label.how can i do?
thanks
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Mar 21, 2007 3:34 pm    Post subject: Reply with quote

Quote:
In v1.0.35+, a g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user or the script changes the contents of the control.
Back to top
vital



Joined: 05 Oct 2005
Posts: 17
Location: china

PostPosted: Wed Mar 21, 2007 3:45 pm    Post subject: Reply with quote

thans bobo

bui i do not want that.
example: i want input "calc" and press enter to run calc.exe, but when i input the first letter "c",the g-label was triggered at once.
Back to top
View user's profile Send private message
Helpy
Guest





PostPosted: Wed Mar 21, 2007 5:07 pm    Post subject: Reply with quote

If I recall correctly, a way to do this is to create an hidden default Button, which will catch the Enter event.
Back to top
n-l-i-d
Guest





PostPosted: Wed Mar 21, 2007 5:25 pm    Post subject: Reply with quote

The easiest is to use a hidden button

Code:
Gui, Add, Edit, w200 h20 -WantReturn vEditContents
Gui, Add, Button, x-10 y-10 w1 h1 +default gGetContents
Gui Show
Return

GetContents:
  Gui, Submit, NoHide
  MsgBox % EditContents
Return

GuiClose:
  ExitApp
Return


You could simply set a hotkey too

Code:
Gui, Add, Edit, w200 h20 vEditContents
Gui Show
Return

#IfWinActive ahk_class AutoHotkeyGUI
Enter::
  Gui, Submit, NoHide
  MsgBox % EditContents
Return
#IfWinActive

GuiClose:
  ExitApp
Return
Back to top
BoBo
Guest





PostPosted: Wed Mar 21, 2007 5:49 pm    Post subject: Reply with quote

Quote:
example: i want input "calc" and press enter to run calc.exe, but when i input the first letter "c",the g-label was triggered at once.
So what?

Code:
Gui, Add, Edit, vMyEdit gMyLabel
Gui, Show
return

MyLabel:
Gui, Submit, NoHide
If (MyEdit = "calc")
   Run , calc.exe
Return
Not tested.
Back to top
BoBo
Guest





PostPosted: Wed Mar 21, 2007 5:55 pm    Post subject: Reply with quote

Code:
Gui, Add, Edit, vMyEdit gMyLabel
Gui, Show
return

MyLabel:
Sleep, 800
Gui, Submit, NoHide
If (MyEdit = "calc")
   Run , calc.exe
Return
That way it won't start calc.exe even if you'll enter a word like "calculation" (depends on if you type additional characters within the delay of 800ms.) Tested.
Back to top
vital



Joined: 05 Oct 2005
Posts: 17
Location: china

PostPosted: Wed Mar 21, 2007 6:06 pm    Post subject: Reply with quote

thanks n-l-i-d and BoBo very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group