Jump to content

Create button/input in this case ?


zxzxzx
 Share

Recommended Posts

I have this code

; Declaration of includes
#include <GUIConstantsEx.au3> ; Since 02-04-2008 I use the GUIConstantsEx.au3 instead of GUIConstants.au3 due to the announcement that in the next version (above 3.2.10.0) the GUIConstants.au3 will be replaced.

#include <Array.au3> ; For array operations like swapping of two arrayitems.

#include <StaticConstants.au3> ; For the constants in the label(s). ($SS_CENTER in this case)
#include <EditConstants.au3> ; For the constants in the Edit control. (For example $ES_$ES_AUTOHSCROLL and $ES_READONLY)

; Set resize mode so that controls won't be auto-shaped
; Set traymenumode so that I can create my own traymenu
Opt("GUIResizeMode", 802)
Opt("TrayMenuMode", 1)
AutoItSetOption("GUICloseOnESC", 0) ; Don't close AutoIt when the escape key is pressed

; Set $max variable. This var contains the maximum number of ping entries
Global $max = 10

; Declare a lot of variables. (I hope I didn't leave one out :) )
Global $active[$max]
Dim $pongfrm, $pinggroup[$max], $pinglbl[$max], $pingbtn[$max], $rembtn[$max], $addbtn, $trayoptions, $traysettings, $noms, $hsgui, $otgui, $exitgui, $fpingoption, $seticmp, $settimeout, $descriptbtn, $descrgroup[$max], $descrlbl[$max], $startallbtn, $resetfastset
Dim $time, $pingip, $roundtrip, $currentnumber, $ontop, $frmstate, $error, $nomsstate, $fastping, $iniloc, $icmpsize, $timeout, $descript
Dim $msg, $traymsg, $i, $j

; Set all array variables to 0 or 9999
; Those set to 99999 aren't set to 0 cause this can cause problems when using these vars and controlID's. My code needs this :)




; Create the GUI and set the background color of it
$pongfrm = GUICreate("Pong", 174, 40, 400, 100)
GUISetBkColor(0x20A0FF)

$inibtn = GUICtrlCreateButton("s", 142, 5, 15, 15) ; Create the ini-file button for saving to an ini-file
GUICtrlSetTip($inibtn, "Save destinations to ini file")
$descriptbtn = GUICtrlCreateButton(">", 157, 5, 15, 15)
GUICtrlSetTip($descriptbtn, "Expands the GUI for the discription fields")
$startallbtn = GUICtrlCreateButton("a", 142, 20, 15, 15)
GUICtrlSetTip($startallbtn, "Start/Stops all pings at once")
$addbtn = GUICtrlCreateButton("+", 157, 20, 15, 15) ; Create the add button before the rest for tabbing purposes.
GUICtrlSetTip($addbtn, "Add ping entry") ; Set the tooltip for the add button. I use the full variable instead of -1 cause  I think this is more precise.

$i = 0
do
extra() ; Go into the routine that generates the ping entries
expandgui()
$i = $i + 1
Until $i = 10

GUISetState() ; Creates/Shows the GUI



$time = TimerInit() ; Set the var to hold the current time

While 1 ; Main loop
    $msg = GUIGetMsg() ; Get GUI events
    Switch $msg ; Switch .. Case for events
        Case $GUI_EVENT_CLOSE
            Exit
        Case $addbtn
            expandgui()
            extra()
        Case $inibtn
            
        Case $descriptbtn
            transformright()
            If $descript = 0 Then
                $descript = 1
                GUICtrlSetData($descriptbtn, "<") ; Set the descript button's face to < (=contractable)
            ElseIf $descript = 1 Then
                $descript = 0
                GUICtrlSetData($descriptbtn, ">") ; Set the descript button's face to > (=expandable)
            EndIf
    EndSwitch

    
    For $i = 0 To $currentnumber - 1 Step 1 ; Check all ping buttons to see if there is a ping activated or deactivated and act accourdingly
        If $msg = $pingbtn[$i] Or $msg = $startallbtn Then ; If the $startallbtn is pressed all $i's are 'pressed'
            
                $a = GUICreate($i+1, 300, 200)
                GUISetState()
                $q = GUICtrlCreateInput('Some Questions ...', 20, 20, 260,130)
                $A = GUICtrlCreateButton('A', 20, 150, 25,25)
                $B = GUICtrlCreateButton('B', 50, 150, 25,25)
                $C = GUICtrlCreateButton('C', 80, 150, 25,25)
                $D = GUICtrlCreateButton('D', 110, 150, 25,25)
                
                
                
            
            
        EndIf
    Next
    
WEnd

Exit ; I all ways exit with this even if there's an infinite loop above it. Just to be certain



Func extra() ; The variable $currentnumber holds the number of ping entries made in the GUI
    $pinggroup[$currentnumber] = GUICtrlCreateGroup("", 5, $currentnumber * 30, 135, 35) ; Create a group. This is visualised as a line/border/box
        $pinglbl[$currentnumber] = GUICtrlCreateInput("127.0.0.1", 10, $currentnumber * 30 + 12, 95, 17, BitOr($ES_AUTOHSCROLL, $SS_CENTER)) ; Create a input box with near unlimited space and centered text.
        GUICtrlSetTip($pinglbl[$currentnumber], "Ping destination: " & $currentnumber)
        $pingbtn[$currentnumber] = GUICtrlCreateButton(">", 106, $currentnumber * 30 + 12, 15, 15)
        GUICtrlSetTip($pingbtn[$currentnumber], "Start/Stop this ping")
        GUICtrlSetState($pingbtn[$currentnumber], $GUI_FOCUS) ; Set the focus to the start/stop button after the entry is made
        If $currentnumber > 0 Then ; If it is not the first entry then display a remove button
            $rembtn[$currentnumber] = GUICtrlCreateButton("-", 121, $currentnumber * 30 + 12, 15, 15)
            GUICtrlSetTip($rembtn[$currentnumber], "Remove entry")
        EndIf
    GUICtrlCreateGroup("",-99,-99,1,1) ; End group creation
    GUICtrlSetPos($addbtn, 157, $currentnumber * 30 + 20) ; Shift the add button one down
    extradescr()
    $currentnumber = $currentnumber + 1 ; Add one to the number of entries noted in this var
    If $currentnumber = $max Then GUICtrlSetState($addbtn, $GUI_DISABLE) ; If there are $max (standard set to 10) entries then disable the add button to deny the possibility to add more
EndFunc

Func extradescr() ; The variable $currentnumber holds the number of ping entries made in the GUI
    $descrgroup[$currentnumber] = GUICtrlCreateGroup("", 175, $currentnumber * 30, 135, 35) ; Create a group. This is visualised as a line/border/box
        $descrlbl[$currentnumber] = GUICtrlCreateInput("", 185, $currentnumber * 30 + 12, 115, 17, BitOr($ES_AUTOHSCROLL, $SS_CENTER)) ; Create a input box with near unlimited space and centered text.
        GUICtrlSetTip($descrlbl[$currentnumber], $currentnumber+1 & ": " & "Enter the description here")
    GUICtrlCreateGroup("",-99,-99,1,1) ; End group creation
EndFunc

Func expandgui()
    $guiposition = WinGetPos($pongfrm) ; Get the GUI coördinates
    WinMove($pongfrm, "", $guiposition[0], $guiposition[1], $guiposition[2], $guiposition[3] + 30) ; Expandes the window with 30 pixels downward
EndFunc

Func transformright()
    $guiposition = WinGetPos($pongfrm) ; Get the GUI coördinates
    If $descript = 0 Then
        WinMove($pongfrm, "", $guiposition[0], $guiposition[1], $guiposition[2] + 140, $guiposition[3]) ; Expandes the window with 140 pixels to the right
    ElseIf $descript = 1 Then
        WinMove($pongfrm, "", $guiposition[0], $guiposition[1], $guiposition[2] - 140, $guiposition[3]) ; Contracts the window with 140 pixels from the right
    EndIf
EndFunc

Please see this picture.

Posted Image

Posted Image

Link to comment
Share on other sites

Link to comment
Share on other sites

Can you edit that code help me

No.

The code you have already, did you write it? If so, please verbally describe how the current buttons are added, and I'm sure we can help you figure out how to change it yourself.

"I posted the code" isn't enough because I don't think you have any idea how it works. I suspect you got the code from someone else (I'll assume in an appropriate manner), have no idea how it works, and just want somebody to change it for you without you having to put any effort in it at all.

You have been around this forum long enough to know that's not what it's for. We are here to help YOU figure out how to use AutoIt. To answer your questions on how YOU can do this.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

No.

The code you have already, did you write it? If so, please verbally describe how the current buttons are added, and I'm sure we can help you figure out how to change it yourself.

"I posted the code" isn't enough because I don't think you have any idea how it works. I suspect you got the code from someone else (I'll assume in an appropriate manner), have no idea how it works, and just want somebody to change it for you without you having to put any effort in it at all.

You have been around this forum long enough to know that's not what it's for. We are here to help YOU figure out how to use AutoIt. To answer your questions on how YOU can do this.

:)

Please, pls pls pls ...

Only this time. I will never ask you same above

Link to comment
Share on other sites

Please, pls pls pls ...

Only this time. I will never ask you same above

That's what I thought... :)

You have seventy-something posts on the forums so far an they are almost all about doing things for you without any effort on your part.

No.

Put some effort into it. Learn it. You'll get help with that. But I hope nobody does the work for you on this forum.

>_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...