AutoHotkey Community

It is currently May 27th, 2012, 11:40 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Correct my code
PostPosted: April 24th, 2010, 2:00 pm 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
Code:
;Gui, Add, Text, x16 y20 w100 h30 , Name
;Gui, Add, Text, x16 y60 w100 h30 , Phone No
Gui, Add, Edit, x16 y100 w260 h120 ,
Gui, Add, Button, x96 y230 w100 h30 , Send
Gui, Add, ComboBox, x146 y30 w100 h20 vColorChoice, Red|Green|Blue|Black|White
Gui, Show, x131 y91 h276 w302, New GUI Window
Return

ButtonSend:
{
MsgBox,%vColorChoice%
return
}
GuiClose:
ExitApp



It should display the selected combo box item...

[/code]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 2:08 pm 
Offline

Joined: February 17th, 2008, 8:52 pm
Posts: 314
Think need to use Gui Submit along with nohide. Check it out in help docs.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 2:17 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
Code:
ButtonSend:
Gui, Submit, NoHide
MsgBox, %ColorChoice%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 3:31 pm 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
How to get the text in Edit control.
One more thing, Edit control shows VMsg while its running. It shouldnt display that one...


Code:

Gui, Add, Text, x16 y20 w100 h30 , Name
Gui, Add, Text, x16 y60 w100 h30 , Phone No
Gui, Add, Edit, x16 y100 w260 h120 ,VMsg,
Gui, Add, Button, x96 y230 w100 h30 , Send
Gui, Add, ComboBox, x146 y30 w100 h20 vColorChoice, Red|Blue



Gui, Show, x131 y91 h276 w302, New GUI Window
Return

ButtonSend:
{
Gui, Submit, NoHide

MsgBox, %Msg% %ColorChoice%

return
}
GuiClose:
ExitApp
[/code]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 5:07 pm 
Offline

Joined: April 25th, 2009, 9:02 pm
Posts: 123
Having spent today learning about edit boxes, it is destiny that I should look at this post!!! :P

What do you mean GET the text in edit control?

To get rid of vMsg (dunno if v can be capital, docs show it as not so I will blindly obey!)

Code:
Gui, Add, Edit, x16 y100 w260 h120 vMsg


What you were doing wrong is you had a comma between the dimensions and the variable name which you shouldn't (docs are horribly vague on this I know!)

To come back to what I said above... if you mean GET is set edit box input as a variable, well, the above fix does this (Damn those pesky commas) and then you can just call it with %Msg% I believe.

Hope this helps!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 5:20 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
chandru115 wrote:
Gui, Add, Edit, x16 y100 w260 h120 ,VMsg,

You can't assign the v-label because of the comma before it.. Too many comma.

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 7:37 pm 
Offline

Joined: February 13th, 2010, 3:52 pm
Posts: 175
chandru155 wrote:
How to get the text in Edit control.


I assume you mean you want the variable "ColorChoice" to appear in the edit control "vMsg". In this case, this is how to do that:

Code:
GuiControl,,Msg,%ColorChoice%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 2:37 am 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
Thanks to all who helped me....
Again one more thing.(I think i am asking more and more One more thing. I tried my best. But i could achieve what i wanted. Ok, now my final requirement(may not be) is,

Code:
1.The combo box should be initialized from a text file at run time.
2.The Text file should have two value pairs,(color name and color value). I have given the sample text file below.
3.When the use press Send button, it should display the color value of the selected color in MsgBox.
Thats all.


Sample Text File
Code:
Red
1
Blue
2
Yellow
3


If the use selects, Blue in combo box and presses Send button, it should display 3 in MsgBox.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 5:57 pm 
Offline

Joined: October 15th, 2007, 7:23 pm
Posts: 252
First, in your color information file (I used the name test.txt for testing), I would recommend putting the color name on the same line with the value separated by a comma like:
Quote:
Red,1
Blue,2
Yellow,3

Then I would just add a "loop, read" command and a "stringsplit" to get the color information from the file into dynamic variables and also generate a pipe delimited string to be used in the combo box:
Code:
;Get color information from file
Loop, Read, Test.txt
{
   if(A_LoopReadLine){
      StringSplit, ColorInfo, A_LoopReadLine, `,
      ;ColorInfo1 contains the name of the color
      ;ColorInfo2 contains the color value
      ColorName%A_Index%:=ColorInfo1
      ColorValue%A_Index%:=ColorInfo2
      ;build a pipe delimited string for use in combo box later
      if(ColorNamesDisplay)
         ColorNamesDisplay=%ColorNamesDisplay%|
      ColorNamesDisplay=%ColorNamesDisplay%%ColorInfo1%
   }
}

Gui, Add, Text, x16 y20 w100 h30 , Name
Gui, Add, Text, x16 y60 w100 h30 , Phone No
Gui, Add, Edit, x16 y100 w260 h120 VMsg,
Gui, Add, Button, x96 y230 w100 h30 , Send
Gui, Add, ComboBox, x146 y30 w100 vColorChoice altsubmit Choose1, %ColorNamesDisplay%

Gui, Show, x131 y91 h276 w302, New GUI Window
Return

ButtonSend:
{
Gui, Submit, NoHide

MsgBox, % Msg "`nColorValue=" ColorValue%ColorChoice% " `nColorName=" ColorName%ColorChoice%

return
}
GuiClose:
ExitApp

If you really need to have the color name and the color value on separate lines that could can be done also.

Hope this helps,

dmatch


Last edited by dmatch on May 2nd, 2010, 4:42 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2010, 3:59 pm 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
Thanks...
And What variable name should i use to get the select color name(eg, Red).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2010, 4:40 pm 
Offline

Joined: October 15th, 2007, 7:23 pm
Posts: 252
If I understand what you are asking, I think you want to access the actual name of the color that was chosen by referring to it as:
Code:
ColorName%ColorChoice%


For instance, you could set another variable to its value like:
Code:
ChosenColor:=ColorName%ColorChoice%


I updated the msgbox in my previous response to display the color name so you could see it in use.

dmatch


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 2:35 pm 
Offline

Joined: December 3rd, 2008, 5:37 am
Posts: 158
Location: chennai,india
thanks... I asked the same..
Then, how do i set the no of characters that can be typed in Edit box.
For example, it should allow 140characters alone. Is there any function like Edit.setChar(140) or anything like this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 2:56 pm 
Quote:
For example, it should allow 140characters alone. Is there any function like Edit.setChar(140) or anything like this?
Is there a chance that you read the AHK manual on your own? TBH, it shouldn't be to tough for you as English is your second language, right?
GUI > Add > Edit > Limit :?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bowen666, MSN [Bot] and 16 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