Borje Posted April 5, 2009 Share Posted April 5, 2009 (edited) Hello all autoit scripters I want to ask to have this input to work with only numbers and when a number typed in the little inputbox then automatic execute is that possible? If so that ok button can be removed. The numbers to use is 1 to 9 .. Another question is if I want this input window to be in center of screen in differents resolution what I must do then whats commands to use? All help is welcome !! Code: #include <GUIConstants.au3> $GUI = GUICreate(" Test Input" , 400,170, @DesktopWidth/2-200, @DesktopHeight/2-110, -1 ) GUISetBkColor (0x00E0FFFF) GUICtrlCreateLabel("-----------------------------------------------------------", 13, 110, 400) GUICtrlCreateLabel("-----------------------------------------------------------", 206, 110, 400) $val = GUICtrlCreateInput ("", 190, 107, 15, 20," M1") $ok = GUICtrlCreateButton ("Ok", 110, 133, 80, 25) $av = GUICtrlCreateButton ("Cancel", 205, 133, 80, 25) ; GUISetState(@SW_SHOW, $GUI) GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit ExitLoop Case $msg = $av Exit ; close Case $msg = $ok ExitLoop EndSelect Wend MsgBox (4096, "You pressed ok button", GUICtrlRead($ok)) Edited April 5, 2009 by Borje Link to comment Share on other sites More sharing options...
rajeshontheweb Posted April 5, 2009 Share Posted April 5, 2009 1) pls enclose your code with [ AutoIT ] & [ / AutoIT ] braces which makes it more readable.2) pls try this http://quadryders.com/phpcc/snippet.php?sid=13 Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
Borje Posted April 5, 2009 Author Share Posted April 5, 2009 Thank you Rajeshontheweb I have lock at the snippet in your example 2 but i cant find out to insert this in my example to have that to work. Yes i dont know that with braces to have the code more readable can you give a exaple with braces.. Link to comment Share on other sites More sharing options...
rajeshontheweb Posted April 5, 2009 Share Posted April 5, 2009 (edited) just add "" to the beginning of your code and "" to the end of the code #include <GUIConstants.au3> $GUI = GUICreate("Test Input" , 150 ,120, @DesktopWidth/2-200, @DesktopHeight/2-110, -1 ) GUISetBkColor (0x00E0FFFF) $val = GUICtrlCreateInput ("Type here",25, 10, 100 ,50," M1") $moveWin = GUICtrlCreateButton("CentreWindow",25,85,100,25) GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $val Msgbox(4096,"","You typed" & @CRLF & GUICtrlRead($val)) Exit Case $msg = $moveWin _CentreWindow($GUI,"Test Input") EndSelect Wend Func _CentreWindow($win, $txt) $size = WinGetClientSize($win, $txt) Local $y = (@DesktopHeight / 2) - ($size[1] / 2) Local $x = (@DesktopWidth / 2) - ($size[0] / 2) Return WinMove($win, $txt, $x, $y) EndFunc ;==>_Middle Edited April 5, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
Borje Posted April 5, 2009 Author Share Posted April 5, 2009 Thank you again Rajeshontheweb for the great example and thats works perfect. Link to comment Share on other sites More sharing options...
Borje Posted April 5, 2009 Author Share Posted April 5, 2009 Now there is only one problem with the input what to do to have this input to work with only numbers and when a number typed in the little inputbox then automatic execute is that possible? If so that ok button can be removed. The numbers to use is 1 to 9 .. Link to comment Share on other sites More sharing options...
Malkey Posted April 5, 2009 Share Posted April 5, 2009 Now there is only one problem with the input what to do to have this input to work with only numbers and when a number typed in the little inputbox then automatic execute is that possible? If so that ok button can be removed. The numbers to use is 1 to 9 ..Try this. #include <GUIConstants.au3> #include <String.au3> $GUI = GUICreate(" Test Input", 400, 170, (@DesktopWidth - 400) / 2, (@DesktopHeight - 170) / 2) GUISetBkColor(0x00E0FFFF) GUICtrlCreateLabel(_StringRepeat("-", 58), 13, 110, 176, 20) GUICtrlCreateLabel(_StringRepeat("-", 58), 206, 110, 4194, 20) $val = GUICtrlCreateInput("", 190, 107, 15, 20) $av = GUICtrlCreateButton("Cancel", 160, 133, 80, 25) GUISetState() While 1 If GUICtrlRead($val) <> "" Then $sChr = GUICtrlRead($val) If StringRegExp($sChr, "[1-9]") Then ExitLoop Else GUICtrlSetData($val, "") EndIf EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $av Exit; close EndSwitch WEnd MsgBox(4096, "A digit between 1 - 9 was entered", $sChr) Link to comment Share on other sites More sharing options...
Borje Posted April 5, 2009 Author Share Posted April 5, 2009 Thank you Malkey Now all works thanks again... Link to comment Share on other sites More sharing options...
KaFu Posted April 5, 2009 Share Posted April 5, 2009 (edited) or try this #include <GUIConstants.au3> #include <EditConstants.au3> $GUI = GUICreate(" Test Input", 400, 170, (@DesktopWidth - 400) / 2, (@DesktopHeight - 170) / 2) GUISetBkColor(0x00E0FFFF) $val = GUICtrlCreateInput("", 190, 107, 15, 20,$ES_NUMBER) $av = GUICtrlCreateButton("Cancel", 160, 133, 80, 25) GUISetState() While 1 if GUICtrlRead($val) = 0 then GUICtrlSetData($val,"") ElseIf GUICtrlRead($val) <> "" Then ExitLoop EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $av Exit; close EndSwitch WEnd MsgBox(4096, "A digit between 1 - 9 was entered", GUICtrlRead($val)) Edited April 5, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Borje Posted April 5, 2009 Author Share Posted April 5, 2009 Thank you KaFu your example works perfect too, thanks to all other for the help... 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