JamesNL Posted May 7, 2006 Share Posted May 7, 2006 (edited) Hi, I'm currently writing a program for an unattended installation, but I want to be able to specify some parameters before the installer starts. I've created a timer using Adlib (also using Adlib for some other functions), but I want to stop the timer when an input-field is focussed (GUICtrlCreateInput). I tried this, but it doesn't work as expected, even better: nothing happens! If GUICtrlGetState($elm) = $GUI_FOCUSThen AutoStartClear() EndIf Any suggestions on how I can invoke that function when a control is focussed? P.S. I've also created a serial number box using some functions, it automatically adds dashes and removes odd characters like $^#&, i've attached the script. If somebody has got a better solution for a serial-number-box, I'd like to hear it (A masked edit-control would be very nice )serial2.au3 Edited May 7, 2006 by JamesNL Link to comment Share on other sites More sharing options...
Valuater Posted May 7, 2006 Share Posted May 7, 2006 aybe.. ; Serialcode formatteren ; (c) Alex van Herwijnen #Include <GUIConstants.au3> ;AdlibEnable("FormatSerial") ;~ #NoTrayIcon $myGui = GUICreate("", 350, 50, -1, -1, $WS_POPUP) GUISetBkColor(0x4E6FD6) _GuiRoundCorners($myGui, 0, 0, 50, 50) $input1 = GUICtrlCreateInput("", 25,15,280, -1, $ES_UPPERCASE) GUICtrlSetLimit(-1, 29); GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console") $GO = GUICtrlCreateButton("Go", 305,15,30, 20, $ES_UPPERCASE) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $GO AdlibEnable("FormatSerial") ; or just FormatSerial() EndSelect Sleep(1) WEnd 8) Link to comment Share on other sites More sharing options...
JamesNL Posted May 7, 2006 Author Share Posted May 7, 2006 That's nice, Valuater, but not exactly what I meant, I really want it to happen when a key is pressed... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 7, 2006 Moderators Share Posted May 7, 2006 Where is $elm in your script, what is $elm? If you know what the ClassNameNN of the Control you want to do something if it has focus then you could do: If ControlFocus($Main) = 'Edit1' Then Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JamesNL Posted May 7, 2006 Author Share Posted May 7, 2006 (edited) $elm is an earlier created input field, using GUICtrlCreateInput. SmOke_N: that's it! Only I use ControlGetFocus in stead of ControlFocus, but it works like a charm Edited May 7, 2006 by JamesNL Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 7, 2006 Moderators Share Posted May 7, 2006 (edited) Can you tell us what you actually want to accomplish with the script you provided, it seems you have a question about one thing, and provided a script on another? It's hard to give an example of what we would do with at least a recreation script of the current problem if you know what I mean. In the StripTags($invoer) function, are you wanting only to allow regular letters / numbers? I ask this because of the $denyString. Edit: Just read your edit: Ok, good, now disregard the 1st 2 lines there, on to the serial number question. Edit2: ControlGetFocus forces focus on a control, I thought you only wanted to do something "If" a control had focus? Edited May 7, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JamesNL Posted May 7, 2006 Author Share Posted May 7, 2006 Can you tell us what you actually want to accomplish with the script you provided, it seems you have a question about one thing, and provided a script on another?It's hard to give an example of what we would do with at least a recreation script of the current problem if you know what I mean.I know what you mean, the attached script is a part of a larger script I'm working on, and I only want to check for the serial number when the field is focussed.In the StripTags($invoer) function, are you wanting only to allow regular letters / numbers? I ask this because of the $denyString.Indeed, that's what I wantEdit:Just read your edit:Ok, good, now disregard the 1st 2 lines there, on to the serial number question.Edit2:ControlGetFocus forces focus on a control, I thought you only wanted to do something "If" a control had focus?Now you're confused, ControlFocus focusses a control, ControlGetFocus returns the focussed control Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 7, 2006 Moderators Share Posted May 7, 2006 (edited) Indeed, that's what I wantTry this:MsgBox(0, 'Test', StripTags("`I~!@#$%^&*()a_+=m[]}{\T';:e|/s.,?t>i<áàänâgëéèêîïí1ìöôó2òúùûü3ÿý")) Func StripTags($invoer) Local $storeinfo = '' $invoer = StringSplit($invoer, '', 1) For $i = 1 To UBound($invoer) - 1 If StringIsASCII($invoer[$i]) And StringIsAlNum($invoer[$i]) Then _ $storeinfo = $storeinfo & $invoer[$i] Next Return $storeinfo EndFuncI'll look at the rest later this evening, going to be getting ready for my sons bday party in a few minutes and can't concentrate with all the kids in the house at the moment.Now you're confused, ControlFocus focusses a control, ControlGetFocus returns the focussed control I'll chalk that up to the hangover, but yep!! Edit: The more I thought about the above function in the 2 minutes of quiet in my home, the more I realized you just needed StringRegExpReplace:MsgBox(0, 'Test', StripTags("`I~!@#$%^&*()a_+=m[]}{\T';:e|/s.,?t>i<áàänâgëéèêîïí1ìöôó2òúùûü3ÿý")) Func StripTags($invoer) Return StringRegExpReplace($invoer, '[^a-zA-Z0-9]', '') EndFunc Edited May 7, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JamesNL Posted May 7, 2006 Author Share Posted May 7, 2006 Try this:MsgBox(0, 'Test', StripTags("`I~!@#$%^&*()a_+=m[]}{\T';:e|/s.,?t>i<áàänâgëéèêîïí1ìöôó2òúùûü3ÿý")) Func StripTags($invoer) Local $storeinfo = '' $invoer = StringSplit($invoer, '', 1) For $i = 1 To UBound($invoer) - 1 If StringIsASCII($invoer[$i]) And StringIsAlNum($invoer[$i]) Then _ $storeinfo = $storeinfo & $invoer[$i] Next Return $storeinfo EndFuncI'll look at the rest later this evening, going to be getting ready for my sons bday party in a few minutes and can't concentrate with all the kids in the house at the moment.I'll chalk that up to the hangover, but yep!! Edit: The more I thought about the above function in the 2 minutes of quiet in my home, the more I realized you just needed StringRegExpReplace:MsgBox(0, 'Test', StripTags("`I~!@#$%^&*()a_+=m[]}{\T';:e|/s.,?t>i<áàänâgëéèêîïí1ìöôó2òúùûü3ÿý")) Func StripTags($invoer) Return StringRegExpReplace($invoer, '[^a-zA-Z0-9]', '') EndFuncThanks for your effort, Smoke_N, but the dashed should remain too, do you know how I can keep them with this RegExp? By the way, congrats with your son Link to comment Share on other sites More sharing options...
Valuater Posted May 7, 2006 Share Posted May 7, 2006 getting ready for my sons bday partycongrats here too!8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 7, 2006 Moderators Share Posted May 7, 2006 Thanks for your effort, Smoke_N, but the dashed should remain too, do you know how I can keep them with this RegExp? By the way, congrats with your son Thanks JamesNL and Valuater, it was a huge success (They successfully gave me a splitting headache ) By "dash" do you mean "hyphen"?MsgBox(0, 'Test', StripTags("`I~!@#$%^&*()-a_+=m-[]}{\T';:e|/s.,?t>i<áàänâgëéèêîïí-1ìöôó-2òúùûü-3ÿý")) Func StripTags($invoer) Return StringRegExpReplace($invoer, '[^a-zA-Z0-9-]', '') EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now