Sign in to follow this  
Followers 0
Tasmania

User Formatted GUI Text Boxes

26 posts in this topic

#1 ·  Posted (edited)

For instance, I want my text box to always have a $ in the front, and .00 at the end. Yes, I suppose I can append it after, however I want to make it static... so it is displayed, and by default, when you are tabbed into the input box, it selects the primary (dollar) amount. For instance, $0.00 should be default in the text box, and when it has focus, the first 0 (between $ and .) should be highlighted to be overwritten. If the default dollar value isn't there (i.e. they hit delete and deleted all of the primary value), it should reappear with a 0. They should be able to change the "cents" part of it, but the delimiter should always be two decimal points in.

Gah, that was difficult to explain... anyone know how?

Edited by Tasmania

Share this post


Link to post
Share on other sites

Don't really worry about the cents part, it's not really important. As long as I can understand the first half of the code, I'll be able to program the cents myself.

Share this post


Link to post
Share on other sites

A white label with a "$" on it. An input box for the dollars, a white label with the "." and then an input box for the cents.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

A white label with a "$" on it. An input box for the dollars, a white label with the "." and then an input box for the cents.

Yeah, I was thinking the same thing. I did something similar with a login script I did. The format of login was HELLO USERNAME.DOMAIN and when I started sharing the code, I made it so that other user can input their own username but in the variables I have something like this;

$username = "HELLO " & GUICtrlRead($i_user) & ".DOMAIN"

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Is this the only way?

Share this post


Link to post
Share on other sites

I can't find another way and having a white label in front of the inputbox is not a very good idea because it will be difficult to align them - if you use the same y coord then the text on the label will appear higher than the text in inputbox.

What you can do is to set the content of that inputbox as "$" when you create it and when its content it is modified to check if it still has the $ in front - if not, add it and refresh the content.

Like this:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 71, 193, 155)
$Input1 = GUICtrlCreateInput("$", 64, 16, 153, 21)
$Input2 = GUICtrlCreateInput("", 64, 40, 153, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Input1
            If StringLeft(GUICtrlRead($Input1),1) <> "$" Then GUICtrlSetData($Input1, "$"&GUICtrlRead($Input1))
    EndSwitch
WEnd

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

As a rule to align the Label with InputBox, I use this;

$y = "" ; Label's y-position
$i_y= $y-2 ; Input's y-position

Then if I choose to move the label, the Input seems to staticly align itself with it. I use the same method on the x-position. If you keep the Label:Input pair relative to eachother, you can't go wrong.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

As a rule to align the Label with InputBox, I use this;

$y = "" ; Label's y-position
$i_y= $y-2 ; Input's y-position

Then if I choose to move the label, the Input seems to staticly align itself with it. I use the same method on the x-position. If you keep the Label:Input pair relative to eachother, you can't go wrong.

I know what you mean and I always set the label 2 points down but when you're using a different colored background for label that will show that the controls aren't aligned properly - it will look "ugly"; try it yourself and see the results.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I know what you mean and I always set the label 2 points down but when you're using a different colored background for label that will show that the controls aren't aligned properly - it will look "ugly"; try it yourself and see the results.

lol, yeah I know what you mean, that's why I don't use colors in my GUIs. Sometimes, I place the Label above the Input since I find it easier to align them this way.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Thanks for the help, both of you. I will try this out and see the results... I think it may be close enough to what I'm looking for. The only reason I ask at all is because I saw in one of the IP applications around here that the person had static decimals and upon the enter of three numbers it "tabbed" over to the next point in decimals. That is similar to what I'm looking for, however I can't find the application.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Ok so I have this so far.. it's not going to be coded like this in the end if I figure out how to do what I want to do, but how do I select a certain point in the text? Like, $0.12 should have 0 selected only.

This is the code I have... I had to modify your code a little for it to work:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\USPJEFE\Desktop\Projects\frmCostInfo.kxf
$frmCostInfo = GUICreate("Cost Information", 226, 346, 193, 115)
$Tab1 = GUICtrlCreateTab(0, 0, 225, 305)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tsConcept = GUICtrlCreateTabItem("&Concept")
$lbl2pcbk = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$txt2pcbk = GUICtrlCreateInput("$0.00", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$txt2pcfrn = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$txt2pcfrnt = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblbfold = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$txtbfold = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblClam = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$txtClam = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblFseal = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$txtFseal = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblIns = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$txtIns = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblLid = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$txtLid = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblMclam = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$txtMclam = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblPFS = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$txtPFS = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblTclam = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$txtTclam = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$lblTray = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$txtTray = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsRconcpt = GUICtrlCreateTabItem("&Re-Concept")
$Label1 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input1 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label2 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input2 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label3 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input3 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label4 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input4 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label5 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input5 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label6 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input6 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label7 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input7 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label8 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input8 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label9 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input9 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label10 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input10 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label11 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input11 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsSample = GUICtrlCreateTabItem("&HDPE Mold")
$Label12 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input12 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label13 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input13 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label14 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input14 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label15 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input15 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label16 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input16 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label17 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input17 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label18 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input18 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label19 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input19 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label20 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input20 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label21 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input21 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label22 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input22 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsRsample = GUICtrlCreateTabItem("HDPE Re-Mold")
$Label23 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input23 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label24 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input24 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label25 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input25 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label26 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input26 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label27 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input27 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label28 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input28 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label29 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input29 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label30 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input30 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label31 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input31 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label32 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input32 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label33 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input33 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsAlum = GUICtrlCreateTabItem("&Alum Mold")
$Label34 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input34 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label35 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input35 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label36 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input36 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label37 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input37 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label38 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input38 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label39 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input39 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label40 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input40 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label41 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input41 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label42 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input42 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label43 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input43 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label44 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input44 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsAlumRmold = GUICtrlCreateTabItem("Alum Re-mold")
$Label45 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input45 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label46 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input46 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label47 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input47 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label48 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input48 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label49 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input49 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label50 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input50 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label51 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input51 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label52 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input52 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label53 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input53 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label54 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input54 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label55 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input55 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateTabItem("")
$btnComplete = GUICtrlCreateButton("C&omplete", 144, 312, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case Not $btnComplete
            If StringLeft(GUICtrlRead($txt2pcbk),1) <> "$" Then GUICtrlSetData($txt2pcbk, "$"&GUICtrlRead($txt2pcbk))
            If StringRight(GUICtrlRead($txt2pcbk),3) <> ".00" Then GUICtrlSetData($txt2pcbk, GUICtrlRead($txt2pcbk)&".00")
    EndSwitch
WEnd
Edited by Tasmania

Share this post


Link to post
Share on other sites

$var = "1234567890"

$result = StringLeft($var, 1) ; 1
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 2), 1) ;2
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 3), 1) ;3
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 4), 1) ;4
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 5), 1) ;5
MsgBox(0,"", $result)
$result = StringLeft($var, 1) & StringRight(StringLeft($var, 4), 1) & StringRight(StringLeft($var, 3), 1);143
MsgBox(0,"", $result)


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

I meant have it selected inside of the text box, show with the blue background to overwrite... my fault for not being more specific, sorry!

Share this post


Link to post
Share on other sites
$var = "1234567890"

$result = StringLeft($var, 1) ; 1
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 2), 1) ;2
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 3), 1) ;3
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 4), 1) ;4
MsgBox(0,"", $result)
$result = StringRight(StringLeft($var, 5), 1) ;5
MsgBox(0,"", $result)
$result = StringLeft($var, 1) & StringRight(StringLeft($var, 4), 1) & StringRight(StringLeft($var, 3), 1);143
MsgBox(0,"", $result)oÝ÷ Ûú®¢×¡§¢jeÈm+"Ø^±©y÷Þrܨ¹Ê.×h¶¬jëh×6$var = "1234567890"

$result = StringMid($var, 1, 1) ; 1
MsgBox(0,"", $result)
$result = StringMid($var, 2, 1) ;2
MsgBox(0,"", $result)
$result = StringMid($var, 3, 1) ;3
MsgBox(0,"", $result)
$result = StringMid($var, 4, 1) ;4
MsgBox(0,"", $result)
$result = StringMid($var, 5, 1) ;5
MsgBox(0,"", $result)
$result = StringMid($var, 1, 1) & StringMid($var, 4, 1) & StringMid($var, 3, 1);143
MsgBox(0,"", $result)

Share this post


Link to post
Share on other sites

lol of course :)

I never used StringMid() before so I didn't even know it exist. Nevetheless, you already know how to select a certain point in a text so I'm kinda confuse. Do you mean you want it selected as if your left-click and dragged over that text?


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

lol of course :)

I never used StringMid() before so I didn't even know it exist. Nevetheless, you already know how to select a certain point in a text so I'm kinda confuse. Do you mean you want it selected as if your left-click and dragged over that text?

Exactly! Sorry, this is a difficult thing to explain.

Inside of a text box, you see the following displayed: $0.12. When you click on it, by default it doesn't have anything selected. If you press tab, it selects the entire value in the next text box according to tab order. I would like to select only a certain portion for overwrite inside of a text box, and that portion autoselected should be the 0. That way, if a user has put in $45.00 as a value inside of the text box, and tabs (or clicks) back into that text box in the future, it should select only 45 to be overwritten by typing.

Edited by Tasmania

Share this post


Link to post
Share on other sites

Ok just so I understand you correctly. You want "$" and ".00" to stay constant while the "0" on the left side of the decimal point is the only one you can edit either by clicking the box or tabbing into it?

I did something like this in PHP, but I'm not familiar if AutoIt can do it, but if you look at the UDF _GUICtrlTabHighlightItem() there might be something there you might find useful.

Just a suggestion, you can do something like in Excel that when the cell loses focus, the value you put in it are formatted.

Example: If I put 20071008 in a Date cell, when it loses focus it gets reformatted to 10/08/2007

You can do the same thing if you want, so if you put 45 in that box, it gets reformatted to $45.00 when it loses focus.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

That selects a tab, if you open up the script from the help file. I've found something close, but it only works in edit fields, as far as I can tell. I may wind up just changing to edit fields on all of these.

Note: UDF Name: _GUICtrlEditSetSel

If anyone knows of an easier way to do this, please let me know... I don't like the idea of going to edit boxes.

Share this post


Link to post
Share on other sites

My gosh... it's not selecting my edit boxes now! What is this chaos!

#include <GUIConstants.au3>
#include <GuiEdit.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\USPJEFE\Desktop\Projects\frmCostInfo.kxf
$frmCostInfo = GUICreate("Cost Information", 226, 346, 250, 165)
$Tab1 = GUICtrlCreateTab(0, 0, 225, 305)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tsConcept = GUICtrlCreateTabItem("&Concept")
$concpt2pcfrnt = GUICtrlCreateInput("$250", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptbfold = GUICtrlCreateInput("$400", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptClam = GUICtrlCreateInput("$200", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptFseal = GUICtrlCreateInput("$100", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptIns = GUICtrlCreateInput("$200", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptLid = GUICtrlCreateInput("$200", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptMclam = GUICtrlCreateInput("$200", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptPFS = GUICtrlCreateInput("$300", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptTclam = GUICtrlCreateInput("$100", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$concptTray = GUICtrlCreateInput("$350", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label56 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Label57 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Label58 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Label59 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Label60 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Label61 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Label62 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Label63 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Label64 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Label65 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Label66 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$concpt2pcbk = GUICtrlCreateEdit("", 92, 33, 121, 17, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$ES_NUMBER))
GUICtrlSetData(-1, "$250")
$tsRconcpt = GUICtrlCreateTabItem("&Re-Concept")
$Label1 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input1 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label2 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input2 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label3 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input3 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label4 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input4 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label5 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input5 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label6 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input6 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label7 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input7 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label8 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input8 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label9 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input9 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label10 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input10 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label11 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input11 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsSample = GUICtrlCreateTabItem("&HDPE Mold")
$Label12 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input12 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label13 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input13 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label14 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input14 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label15 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input15 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label16 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input16 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label17 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input17 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label18 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input18 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label19 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input19 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label20 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input20 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label21 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input21 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label22 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input22 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsRsample = GUICtrlCreateTabItem("HDPE Re-Mold")
$Label23 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input23 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label24 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input24 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label25 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input25 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label26 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input26 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label27 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input27 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label28 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input28 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label29 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input29 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label30 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input30 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label31 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input31 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label32 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input32 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label33 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input33 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsAlum = GUICtrlCreateTabItem("&Alum Mold")
$Label34 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input34 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label35 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input35 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label36 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input36 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label37 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input37 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label38 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input38 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label39 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input39 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label40 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input40 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label41 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input41 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label42 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input42 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label43 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input43 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label44 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input44 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$tsAlumRmold = GUICtrlCreateTabItem("Alum Re-mold")
$Label45 = GUICtrlCreateLabel("2 PC BACK:", 12, 33, 61, 17)
$Input45 = GUICtrlCreateInput("", 92, 33, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label46 = GUICtrlCreateLabel("2 PC FRONT:", 12, 57, 70, 17)
$Input46 = GUICtrlCreateInput("", 92, 57, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label47 = GUICtrlCreateLabel("BI-FOLD:", 12, 81, 48, 17)
$Input47 = GUICtrlCreateInput("", 92, 81, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label48 = GUICtrlCreateLabel("CLAMSHELL:", 12, 105, 70, 17)
$Input48 = GUICtrlCreateInput("", 92, 105, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label49 = GUICtrlCreateLabel("FACE SEAL:", 12, 129, 64, 17)
$Input49 = GUICtrlCreateInput("", 92, 129, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label50 = GUICtrlCreateLabel("INSERT:", 12, 153, 47, 17)
$Input50 = GUICtrlCreateInput("", 92, 153, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label51 = GUICtrlCreateLabel("LID:", 12, 177, 24, 17)
$Input51 = GUICtrlCreateInput("", 92, 177, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label52 = GUICtrlCreateLabel("MOCK CLAM:", 12, 201, 70, 17)
$Input52 = GUICtrlCreateInput("", 92, 201, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label53 = GUICtrlCreateLabel("PLTFRM FS:", 12, 225, 66, 17)
$Input53 = GUICtrlCreateInput("", 92, 225, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label54 = GUICtrlCreateLabel("TENT CLAM:", 12, 249, 68, 17)
$Input54 = GUICtrlCreateInput("", 92, 249, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label55 = GUICtrlCreateLabel("TRAY:", 12, 273, 36, 17)
$Input55 = GUICtrlCreateInput("", 92, 273, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateTabItem("")
$btnComplete = GUICtrlCreateButton("C&omplete", 144, 312, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_GUICtrlEditSetSel ($concpt2pcbk, 0, 6)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0