AutoHotkey Community

It is currently May 25th, 2012, 5:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Working with a GUI
PostPosted: August 24th, 2007, 11:13 pm 
Offline

Joined: May 23rd, 2007, 3:31 pm
Posts: 17
I know how to make a GUI run a subroutine when changing an edit box. The problem is it is running on my changing of the first keystroke of the edit box. I'd like it to auto execute after I exit the editbox.

Don't see anything that would let me do that.

Ideas?

TIA


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 11:24 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
Quote:
The problem is it is running on my changing of the first keystroke of the edit box. I'd like it to auto execute after I exit the editbox.



You arent being clear with what you mean. What does exiting an edit box mean?

If you just want the variable in an edit box to be submitted when you choose then...

Code:
Gui, 1: Add, Edit, x10 y10 w100 vEdit
Gui, 1: Add, Button, y+10 w75 gEdit, Ok
Gui, 1: Show, w150 h80
Return

Edit:
Gui, 1: Submit, NoHide
MsgBox, %Edit% is typed in the edit box
Return


Last edited by tic on August 24th, 2007, 11:24 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 11:24 pm 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8660
Location: Salem, MA
you could have a timer checking your current focus.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 11:37 pm 
Offline

Joined: May 23rd, 2007, 3:31 pm
Posts: 17
tic wrote:
Quote:
The problem is it is running on my changing of the first keystroke of the edit box. I'd like it to auto execute after I exit the editbox.



You arent being clear with what you mean. What does exiting an edit box mean?

If you just want the variable in an edit box to be submitted when you choose then...

Code:
Gui, 1: Add, Edit, x10 y10 w100 vEdit gedit
Gui, 1: Show, w150 h80
Return

Edit:
Gui, 1: Submit, NoHide
MsgBox, %Edit% is typed in the edit box
Return


I am using the code you suggested already. I changed you code to reflect what I have now. What this does is execute the suboutine on the first keystroke entered in the box that can be edited (aka edit box in my language). I have more than one key to press before I'm ready to leave the edit box and execute, and I'd rather not have to press a button after I'm done inputting. I'd like to just be able to tab out of the edit box, or hit enter to accept the data in it, and have that cause the execution.

Hope that makes it more clear what I'm after.

TIA


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 11:40 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
oh well, just submit them all at the end would be the better way to do things.

You can submit them with timers but this is messy:

Code:
SetTimer, CheckState, 50


Gui, 1: Add, Edit, x10 y10 w100 vEdit
Gui, 1: Add, Text, x+10 w250, Type in this box and then when you move to another box then this box's variable will be submitted
Gui, 1: Add, Edit, xp-110 y+10 w100
Gui, 1: Add, Edit, y+10 w100
Gui, 1: Show, w400 h120
Return

CheckState:

GuiControlGet, ControlFocus, Focus

If ControlFocus != Edit1
{

   Gui, 1: Submit, NoHide
   MsgBox, %Edit% is typed in the first edit box and you have now changed focus
   ExitApp
}
Return


The best thing to do would be to type all the things you wanna type into each edit box and then click ok at the end and submit all of them with

Code:
Gui:Submit,NoHide


as this would be slow and unnecessary


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 11:56 pm 
Offline

Joined: May 23rd, 2007, 3:31 pm
Posts: 17
Looks like it's just too much trouble. Thanks anyway.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2007, 12:49 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
Quote:
Looks like it's just too much trouble. Thanks anyway.


It is honestly no trouble! its easy......
Im gonna force you to understand it :D
This is what you want.....

Code:
Gui, 1: Add, Edit, x10 y10 w100 vEdit1
Gui, 1: Add, Edit, y+10 w100 vEdit2
Gui, 1: Add, Edit, y+10 w100 vEdit3
Gui, 1: Add, Button, y+10 w75 gEdit Default, Ok
Gui, 1: Show, w150 h150
Return

Edit:
Gui, 1: Submit, NoHide
Loop, 3
{
   MsgBox, % Edit%A_Index% . " is typed in edit" . A_Index
}
Return


Edit:

Quote:
you could also add Default to the OK Button.


Indeed ^^

Now you just type, press tab and press enter when youre done!


Last edited by tic on August 25th, 2007, 1:22 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2007, 1:03 am 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8660
Location: Salem, MA
you could also add Default to the OK Button.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Working with a GUI
PostPosted: August 25th, 2007, 1:23 am 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
jetpilot86 wrote:
I know how to make a GUI run a subroutine when changing an edit box. The problem is it is running on my changing of the first keystroke of the edit box. I'd like it to auto execute after I exit the editbox.

Don't see anything that would let me do that.

Ideas?

TIA


I was looking for *EXACTLY* the same kind of behaviour last year and was provided with a great solution by Shimanov. Have a look at http://www.autohotkey.com/forum/topic8339.html and see if that helps. I ended up not using his code as another example by Peter fit the bill exactly. Having said that, I did test Shimanov's code and it worked flawlesy

Good luck

Gary


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2007, 4:24 am 
Offline

Joined: May 23rd, 2007, 3:31 pm
Posts: 17
Thanks all, I'll have to tinker with this more after the weekend.

Fortunately my basic concept is up and running. Now I'm trying to streamline my keystrokes to make things faster.

Jeremy, can you post the section of code that worked exactly? It turns out my edit box takes 2 or 3 characters of input also. Hopefully yours runs when you tab out of the last box.

Jet

Here's my current code. It runs but only after I tab to Run and click/enter:

Code:
gui, 2: color, blue
gui, 2: add, text,, Data1
gui, 2: add, edit, vdata1 xp+50 w50, %data1%
gui, 2: add, text, xs, Data2
gui, 2: add, edit, vdata2 xp+50 w30, %data2%
gui, 2: add, text, xs, Data3
gui, 2: add, edit, vdata3 xp+50 w30, %data3%
gui, 2: add, text, xs, Data4
gui, 2: add, edit, vdata4 xp+50 w30, %data4%
;data4 has either 2 or 3 characters always and instead of tabbing out
;and clicking run or hitting enter to run as I do now.
;I'd like for gsubroutine to run when I tab out of data4.
gui, 2: add, button, gsubroutine xs, Run
gui, 2: show, x350 y80


subroutine:
msgbox, %data1%  %data2%  %data3%  %data4%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2007, 5:22 am 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
Hey Jet,

jetpilot86 wrote:
Jeremy, can you post the section of code that worked exactly? It turns out my edit box takes 2 or 3 characters of input also. Hopefully yours runs when you tab out of the last box.

That's the beauty of the G-Label. AHK watches as I type and the moment the third character is entered, the routine takes action. No tabbing required.

Just to summarize what the code does... I need a series of static data to be populated from an .INI file (one section per worker ID#). I enter a worker ID (always 3 digits) in the first edit box. Once the third digit is entered, the G-Label section uses IniRead to get the data from the correct section and then uses ControlSetText to populate the other edit boxes. Makes sense?


Code:
CheckCaseOrg:
   ControlGetText, CaseOrgEntered, Edit1,   
   StringLen, CaseOrgLength, CaseOrgEntered
   If (CaseOrgLength = 3) ' ACTION TRIGGERED HERE
      {
      CaseOrg = %CaseOrgEntered%     
      IniRead, WorkerName, CaseOrgs.ini, %CaseOrg%, Name         
      IniRead, WorkerExtension, CaseOrgs.ini, %CaseOrg%, Extension
      IniRead, WorkerEmail, CaseOrgs.ini, %CaseOrg%, Email
           
      ControlSetText, Edit4, %WorkerName%
      ControlSetText, Edit5, %WorkerExtension%
      ControlSetText, Edit6, %WorkerEmail%
      }   
 Return


Hope that helps

Gary


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, engunneer, mc-lemons, tank, vsub and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group