Jump to content

Autoit-gui


Recommended Posts

Hi I been trying to find way around this but just can't get it. I want the the terminal ID box to have a limit of 8 charactors and i want the prog to say error if it doesn't but only once the apply button is pressed. But every time the combo changes then the message appears. However i still want the combo box to infulance what is displayed on the screen. help!!

Example:

GUICreate("names")

$T_COMBO = GUISetControl("combo", "Pos", -1,10,80)

GUISetControlNotify ( $T_COMBO,2)

GUISetControlData(-1,"Back Office|Till|Combined")

$TillNo = GUISetControl("Combo","1",90,10,40)

GUISetControlData(-1,"1|2|3|4|5|6|7|8|9")

GUISetControlEx ( $TillNo, 32)

$lbl_TID = GUISetControl("Label", "Terminal ID", 20,50,80)

GUISetControlEx ($lbl_TID, 32)

$Inpt_TID = GUISetControl("Input", "", 90,50,55)

GUISetControlEx ( $Inpt_TID, 32)

$Apply = GUISetControl("Button", "Apply", 220,260,50)

GUISetControlNotify ()

GUISetControl("button", "Exit", 290,260,50)

While GUImsg()

$COMBO = GuiRead($T_COMBO)

If $COMBO = "Back Office" Then

GUISetControlEx ( $TillNo, 32)

GUISetControlEx ( $lbl_TID, 16)

GUISetControlEx ( $Inpt_TID, 16)

ElseIf $COMBO = "Till" Then

GUISetControlEx ( $TillNo, 16)

GUISetControlEx ( $lbl_TID, 32)

GUISetControlEx ( $Inpt_TID, 32)

ElseIf $COMBO = "Combined" Then

GUISetControlEx ( $TillNo, 32)

GUISetControlEx ( $lbl_TID, 16)

GUISetControlEx ( $Inpt_TID, 16)

EndIf

IF $lenght <>8 THEN

MsgBox(64, " ", "Incorrect Terminal ID")

Endif

Wend

Isn't it possible to say something like don't do something until a button is clicked. I have been thinking something like this

IF $lenght <>8 AND $Apply =(Clicked) THEN

MsgBox(64, " ", "Incorrect Terminal ID")

Endif

My would be easier if on the next update of autoit3 you clever people wrote in min and max value states for text boxes :D

Link to comment
Share on other sites

@vickerps: I have sent 'jpm' a question about adding the internal message "EM_LIMITTEXT" to "GUISetControlEX" in autoit3-gui for edit- and input-controls.

I integrated that in a test source-code and it works...hmmm...

The Autoit3-code at the moment for me looks like:

...
$input1 = GUISetControl("input","",10,10,150,20)
GUISetControlEx(-1,-1,-1,"",8)
...
$edit1 = GUISetControl("edit","",10,50,150,50)
GUISetControlEx(-1,-1,-1,"",25)
...

The '8' and '25' means then the text-limitation.

Wee will see...

Regards Holger

P.S.: don't know if this is what you want/need but you can try it with this:

GUICreate("names")

$T_COMBO = GUISetControl("combo", "Pos", -1,10,80)
GUISetControlNotify ( $T_COMBO,2)
GUISetControlData(-1,"Back Office|Till|Combined")

$TillNo = GUISetControl("Combo","1",90,10,40)
GUISetControlData(-1,"1|2|3|4|5|6|7|8|9")
GUISetControlEx ( $TillNo, 32)

$lbl_TID = GUISetControl("Label", "Terminal ID", 20,50,80)
GUISetControlEx ($lbl_TID, 32)
$Inpt_TID = GUISetControl("Input", "", 90,50,55)
GUISetControlEx ( $Inpt_TID, 32)

$Apply = GUISetControl("Button", "Apply", 220,260,50)
GUISetControlNotify ()

GUISetControl("button", "Exit", 290,260,50)

While 1

$n = GUImsg() 
$COMBO = GuiRead($T_COMBO)

If $COMBO = "Back Office" Then
GUISetControlEx ( $TillNo, 32)
GUISetControlEx ( $lbl_TID, 16)
GUISetControlEx ( $Inpt_TID, 16)

ElseIf $COMBO = "Till" Then
GUISetControlEx ( $TillNo, 16)
GUISetControlEx ( $lbl_TID, 32)
GUISetControlEx ( $Inpt_TID, 32)

ElseIf $COMBO = "Combined" Then
GUISetControlEx ( $TillNo, 32)
GUISetControlEx ( $lbl_TID, 16)
GUISetControlEx ( $Inpt_TID, 16)

EndIf

If StringLen(GUIRead($Inpt_TID)) <> 8 And $n = $Apply Then
    MsgBox(64, " ", "Incorrect Terminal ID")
EndIf

If $n <= 0 Then ExitLoop

Wend
Edited by Holger
Link to comment
Share on other sites

Thanks Holger for your reponse and i like your code to make the input boxes have a text limit (I feel that xmas has come early).

Thanks for your code hadn't had a chance to study it yet to see what you have done cause going out soon on the beer. :D

Just had a quick run of the code and it seems to do what i want thanks. what i have noticed thou is when you click on apply it come up with the message 'incorrect terminal id' which would be great but i had till selected in the combo so they wouldn't enter one. I there any way to say only query it if the input is visible / enabled.

And seeing that being cheeky and calling this wonderful program is working for me. Could i suggest that if a inputbox,button, combo box, etc is disabled / invisable that the value is set to a specific number.

By doing this you could write some sort of exclussion script.

Hope this make sense

Link to comment
Share on other sites

:D  Holger,

That's look as a good extension, I will put it in 102.17

JP, careful with this can of worms. Once people start seeing the messages that can be sent to controls, they'll start wanting them all. It might be best to work on wrapping SendMessage as Larry was working on. I don't think hard-coding every control notification in will be the best route. I think that method will get hard to maintain pretty quick.
Link to comment
Share on other sites

JP, careful with this can of worms.  Once people start seeing the messages that can be sent to controls, they'll start wanting them all.  It might be best to work on wrapping SendMessage as Larry was working on.  I don't think hard-coding every control notification in will be the best route.  I think that method will get hard to maintain pretty quick.

I agree with you. Do you think we should remove the Larry LBext? I think we could add this last one for input control

to be frank I don't know why as the lenght can be control in a GuiMsg loop.

For the Larry SendMessage I hope we can manage not to send message that wil screw up AutoIt3

Link to comment
Share on other sites

I wonder what the range is on some of the messages. It might be possible to write a SendMessage wrapper that denies sending some messages. Rather than hard-coding in what it can send, hard-code in what it can not send. I don't know how easy that would be to do, though, I don't know what range the WM_* messages use compared to all the other control notification messages.

Link to comment
Share on other sites

I wonder what the range is on some of the messages.  It might be possible to write a SendMessage wrapper that denies sending some messages.  Rather than hard-coding in what it can send, hard-code in what it can not send.  I don't know how easy that would be to do, though, I don't know what range the WM_* messages use compared to all the other control notification messages.

What do you think of

GuiWriteMsg(controlref,Msg,Wparam,Lparam)

and just ignored the msg forW/Lparam not being a value

That at least solving to which handle is going the messsage

Link to comment
Share on other sites

noooooooo :D

I new I was pushing my luck booo hard code the min max lenght thing into input boxes. make us Simpletons lives easier lol.

Ok JPM if you can't hard code that one what do you think of my last post

if a inputbox,button, combo box, etc is disabled / invisable that the value is set to a specific number.

By doing this you could write some sort of exclussion script.

This would help me with this prob

Just had a quick run of the code and it seems to do what i want thanks. what i have noticed thou is when you click on apply it come up with the message 'incorrect terminal id' which would be great but i had till selected in the combo so they wouldn't enter one. I there any way to say only query it if the input is visible / enabled.

Link to comment
Share on other sites

noooooooo :D

I new I was pushing my luck booo hard code the min max lenght thing into input boxes.  make us Simpletons lives easier lol.

Ok JPM if you can't hard code that one what do you think of my last post

This would help me with this prob

if you want to do specific action on input visible or not, you need to memorize the state you are setting and reuse the state.

It is for me the user responsability to construct the way he want retrieve info.

the script can be has follow.

I hope that clarify how to use the propose Gui functions. :huh2:

I agree with Valik I should not add parameters and parameters for specific function specialy if it is easy as this one to code.

GUICreate("names")

$T_COMBO = GUISetControl("combo", "Pos", -1,10,80)
GUISetControlNotify ( $T_COMBO,2)
GUISetControlData(-1,"Back Office|Till|Combined")

$TillNo = GUISetControl("Combo","1",90,10,40)
GUISetControlData(-1,"1|2|3|4|5|6|7|8|9")
GUISetControlEx ( $TillNo, 32)

$lbl_TID = GUISetControl("Label", "Terminal ID", 20,50,80)
GUISetControlEx ($lbl_TID, 32)
$Inpt_TID = GUISetControl("Input", "", 90,50,55)
$Inpt_TID_state=32
GUISetControlEx ( $Inpt_TID, $Inpt_TID_state)

$Apply = GUISetControl("Button", "Apply", 220,260,50)
GUISetControlNotify ()

GUISetControl("button", "Exit", 290,260,50)

While 1

$n = GUImsg() 
$COMBO = GuiRead($T_COMBO)

If $COMBO = "Back Office" Then
GUISetControlEx ( $TillNo, 32)
GUISetControlEx ( $lbl_TID, 16)
$Inpt_TID_state=16
GUISetControlEx ( $Inpt_TID, $Inpt_TID_state)

ElseIf $COMBO = "Till" Then
GUISetControlEx ( $TillNo, 16)
GUISetControlEx ( $lbl_TID, 32)
$Inpt_TID_state=32
GUISetControlEx ( $Inpt_TID, $Inpt_TID_state)

ElseIf $COMBO = "Combined" Then
GUISetControlEx ( $TillNo, 32)
GUISetControlEx ( $lbl_TID, 16)
$Inpt_TID_state=16
GUISetControlEx ( $Inpt_TID, $Inpt_TID_state)

EndIf

If StringLen(GUIRead($Inpt_TID)) <> 8 And $n = $Apply and $Inpt_TID_state= 16 Then
MsgBox(64, " ", "Incorrect Terminal ID")
EndIf

If $n <= 0 Then ExitLoop

Wend
Link to comment
Share on other sites

Thanks JPM

I see your point and don't get me wrong I accept that the user should do the programing but I just thought they would good useful additions to autoit to have hard coded.

Then again Holger's and your code has fixed my prob and it looks so simple.

Well with every post on this forum i am learing somthing new each time.

Thanks again for your time

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...