argumentum Posted Monday at 02:40 AM Posted Monday at 02:40 AM #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=U:\Code-au3\tempCode\Form1.kxf $Form1 = GUICreate("Form1", 405, 148) $Label1 = GUICtrlCreateLabel("Enter a number higher than zero", 10, 10, 200, 17) $Input1 = GUICtrlCreateInput("0", 10, 40, 50, 21) $Button1 = GUICtrlCreateButton("Run / Go / action", 70, 40, 200, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 If Number(GUICtrlRead($Input1)) > 0 Then MsgBox(0, '', 'class ok, bye', 0, $Form1) ExitLoop Else MsgBox(0, 'ERROR', "Class number must be one number.", 0, $Form1) EndIf EndSwitch WEnd ..subscribe, like and comment Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Solution argumentum Posted Monday at 03:38 AM Solution Posted Monday at 03:38 AM (edited) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ConsoleWrite("+ classNumber() returned: " & classNumber() & " - @error = " & @error & " - @extended = " & @extended & @CRLF) Func classNumber() Local $iReturn, $Form1 = GUICreate("Form1", 405, 148) Local $Label1 = GUICtrlCreateLabel("Enter a number higher than zero", 10, 10, 200, 17) Local $Input1 = GUICtrlCreateInput("0", 10, 40, 50, 21) Local $Button1 = GUICtrlCreateButton("Run / Go / action", 70, 40, 200, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE $iReturn = Number(GUICtrlRead($Input1)) GUIDelete($Form1) Return SetError(1, $iReturn, 0) Case $Button1 $iReturn = Number(GUICtrlRead($Input1)) If $iReturn > 0 Then MsgBox(0, '', 'class ok, bye', 0, $Form1) GUIDelete($Form1) Return SetError(0, $iReturn, $iReturn) Else MsgBox(0, 'ERROR', "Class number must be one number.", 0, $Form1) EndIf EndSwitch WEnd EndFunc ;==>classNumber ..this would make more sense because I doubt that this is the application you are after, so, running the function returns the value that you'll use elsewhere to do something with it. In any case, post if this is all you needed to solve, or if is not what you wanted. Edited Monday at 03:42 AM by argumentum better Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kralamour Posted Monday at 03:46 AM Author Posted Monday at 03:46 AM Thank you. I have found my problem with your code. I don't check when i click on submit button, im always in while. Problem Solved argumentum 1
Kralamour Posted Monday at 03:50 AM Author Posted Monday at 03:50 AM Can you please say me why i need to click 10 time for valid. $Load = GUICtrlCreatePic(@ScriptDir & "\IMG\GUI\submit.jpg", 357, 180, 128, 36, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER)) GUICtrlSetCursor (-1, 0) GUICtrlCreateGroup("", -99, -99, 1, 1)
argumentum Posted Monday at 04:14 AM Posted Monday at 04:14 AM 16 minutes ago, Kralamour said: why i need to click 10 time for valid #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ConsoleWrite("+ classNumber() returned: " & classNumber() & " - @error = " & @error & " - @extended = " & @extended & @CRLF) Func classNumber() Local $iReturn, $Form1 = GUICreate("Form1", 405, 148) Local $Label1 = GUICtrlCreateLabel("Enter a number higher than zero", 10, 10, 200, 17) Local $Input1 = GUICtrlCreateInput("0", 10, 40, 50, 21) Local $Button1 = GUICtrlCreateButton("Run / Go / action", 70, 40, 200, 25, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 22) GUICtrlSetCursor (-1, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE $iReturn = Number(GUICtrlRead($Input1)) GUIDelete($Form1) Return SetError(1, $iReturn, 0) Case $Button1 $iReturn = Number(GUICtrlRead($Input1)) If $iReturn > 0 Then MsgBox(0, '', 'class ok, bye', 0, $Form1) GUIDelete($Form1) Return SetError(0, $iReturn, $iReturn) Else MsgBox(0, 'ERROR', "Class number must be one number.", 0, $Form1) EndIf EndSwitch WEnd EndFunc ;==>classNumber GUICtrlCreatePic() will act in press down, GUICtrlCreateButton() will act on the way up. I rather use a button as it has the expected behavior. Why you need to click repeatedly to make it work, is outside the code you shared. Since the question you had was answered and a future "answer seekers" may find the answer to their question on this thread, is advised to open another thread with running code ( not just an unrelated snippet ) so that it can be looked at without confusion for the reader. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kralamour Posted Monday at 04:17 AM Author Posted Monday at 04:17 AM OK sorry, i make new topic. It's not a same code like this. PROBLEM SOLVED argumentum 1
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