Jump to content

GUI - Number limite [help]


MirTexFR
 Share

Recommended Posts

Hi ! I'm new with the Autoit software ! I want to create a number limite for many test or other but i don't know why it's not work !..

The script :

#AutoIt3Wrapper_UseX64=n
#include <FontConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>

Global $Init_Dir = "C:\"

#pragma compile(FileDescription, Number testing MirTex)
#pragma compile(ProductName, MilliTikS)
#pragma compile(ProductVersion, 1.0)
#pragma compile(FileVersion, 1.0)
#pragma compile(LegalCopyright, © MilliTikS Project)

$GUI = GUICreate("Interface", 500, 650, -1, -1)
    GUICtrlCreateTab(10, 110, 480, 400)
    GUISetFont(9, 300)
$menu1 = GUICtrlCreateMenu ("Option", -1, -1)
$menu2 = GUICtrlCreateMenu ("License", -1, -1)
$Bouton1 = GUICtrlCreateButton("Yes", 35, 599, 100, 25)
$Bouton2 = GUICtrlCreateButton("Exit", 375, 599, 100, 25)
GUICtrlCreatePic (@ScriptDir & "\Icons\banner.jpg", 0, 0, 500, 100)

If Not FileExists(@ScriptDir & "\License.txt") Then
    $license = InetGet("http://www.gnu.org/licenses/gpl-3.0.txt", @ScriptDir & "\License.txt")
    InetClose($license)
EndIf

GUISetState(@SW_SHOW)

Menu()
Func Menu()
    Local $idInfoItem = GUICtrlCreateMenuItem("Info", $menu1)
 EndFunc

Tab()
Func Tab()
    GUICtrlCreateTabItem("          Log          ")

    GUICtrlCreateTabItem("       Start Counter       ")
    GUICtrlCreateLabel("Number :", 20, 153, 100, 20)
    $number = GUICtrlCreateInput("Max 1 000 000", 85, 150, 150, 20)
    $Bouton3 =  GUICtrlCreateButton("Save", 240, 147, 50)
         $nMsg = GUIGetMsg()
            Switch $nMsg
               Case $Bouton3
                     if $number > 1000000 then
                        MsgBox(64, 'Error', 'The number cannot be high 1 000 000')
                     endif
            EndSwitch
EndFunc



While 3
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Bouton2
                        Exit
                Case $Bouton1
                        MsgBox(64 + 8192, 'Message', 'Vous avez cliqué sur le bouton OK')
        EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Moderators

MirtexFR,

Welcome to the AutoIt forums.

I have amended the script a little to make it rather more structured:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $cNumber, $cBouton3, $idInfoItem ; needed as you create them inside functions

If Not FileExists(@ScriptDir & "\License.txt") Then
    $hLicence = InetGet("http://www.gnu.org/licenses/gpl-3.0.txt", @ScriptDir & "\License.txt")
    InetClose($hLicence)
EndIf



$hGUI = GUICreate("Interface", 500, 650, -1, -1)

Menu()

GUICtrlCreateTab(10, 110, 480, 400)
GUISetFont(9, 300)
Tab()

$cBouton1 = GUICtrlCreateButton("Yes", 35, 599, 100, 25)
$cBouton2 = GUICtrlCreateButton("Exit", 375, 599, 100, 25)

GUISetState(@SW_SHOW)

While 1 ; Just use the one loop to look for events
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cBouton2
            Exit
        Case $cBouton1
            MsgBox(64 + 8192, 'Message', 'Vous avez cliqué sur le bouton OK')
        Case $cBouton3
            ; Read the value
            $iNumber = Number(GUICtrlRead($cNumber))
            ; Check it
            If $iNumber > 1000000 Then
                MsgBox(64, 'Error', 'The number cannot be high 1 000 000')
                ; Focus the input for easy editing
                GUICtrlSetState($cNumber, $GUI_FOCUS)
            EndIf

    EndSwitch

WEnd



Func Menu()
    $menu1 = GUICtrlCreateMenu("Option", -1, -1)
    $menu2 = GUICtrlCreateMenu("License", -1, -1)
    $idInfoItem = GUICtrlCreateMenuItem("Info", $menu1)
EndFunc   ;==>Menu

Func Tab()
    GUICtrlCreateTabItem("          Log          ")
    GUICtrlCreateTabItem("       Start Counter       ")
    GUICtrlCreateLabel("Number :", 20, 153, 100, 20)
    $cNumber = GUICtrlCreateInput("Max 1 000 000", 85, 150, 150, 20)
    $cBouton3 = GUICtrlCreateButton("Save", 240, 147, 50)
    GUICtrlCreateTabItem("") ; You MUST close the tab creation sequence
EndFunc   ;==>Tab

Please ask if you do not understand what I have done or why I have done it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

MirTexFR,

Glad I could help.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...