Jump to content

Autoit Script runs SLOW to the point of halting between commands


Recommended Posts

I have this script that I have written for work.  I have basically copied this exact same code 2 tome for two other GUI's and they don't have the problem that this one does.  When this is run, it slows down the machine its run on.  I have no idea why, I can't see anything in the code, and the other two scripts which are 99% identical vs some different variables act fine.

I also found out that when trying to paste data into the text input boxes that 0's show up instead of what you pasted which I have never seen before and can't explain either.

code below.  Any help would be appreciated.

;This is the rough draft of the C4 script.

;5/9/13 v0.1
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>

Global $I = 0
Global $EmailEdit, $EmailForm, $CopyButton


$C4ProjectTypeFrm = GUICreate("Maintenance Email Notification", 930, 617, 153, 125)
$C4CoxLabel = GUICtrlCreateLabel("Maintenance Email Notification ", 143, 8, 780, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")

$C4TypeofProjectLabel = GUICtrlCreateLabel("Choose The Type Of Project This Is", 24, 72, 249, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUIStartGroup()
$RDCProjectTypeRadio = GUICtrlCreateRadio("RDC Interconnect", 40, 104, 105, 17)
$C4CoreProjectTypeRadio = GUICtrlCreateRadio("C4 Core Link", 40, 128, 105, 17)
$SystemProjectTypeRadio = GUICtrlCreateRadio("System Connection", 40, 152, 113, 17)
GUIStartGroup()

$ProjectNameLabel = GUICtrlCreateLabel("Input Your Project Name", 24, 192, 185, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$ProjectNameInputBox = GUICtrlCreateInput("", 48, 216, 193, 21,$ES_UPPERCASE)

$ProjectSiteLabel = GUICtrlCreateLabel("Choose Your Project Site Location", 24, 256, 241, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$ProjectSiteCombo = GUICtrlCreateCombo("", 48, 288, 193, 25, BitOR($CBS_DROPDOWN,$CBS_SORT))

$C4NumberOfProjectsLabel = GUICtrlCreateLabel("Input The Number Of Projects You Have Of This Kind", 24, 320, 349, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$NumberOfProjectsInput = GUICtrlCreateInput("", 48, 344, 193, 21)


$C4ProjectSideLabel = GUICtrlCreateLabel("Choose Your Site Router", 25, 378, 234, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$RouterNameCombo = GUICtrlCreateCombo("", 48, 402, 193, 25)
GUICtrlSetState(-1, $GUI_HIDE)

$C4RouterSideLabel = GUICtrlCreateLabel(" Choose Other Site Router", 24, 432, 223, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$C4OtherSiteRouter = GUICtrlCreateCombo("", 48, 456, 193, 25)
GUICtrlSetState(-1, $GUI_HIDE)


$C4RouterInterfacePortLabel = GUICtrlCreateLabel("Choose Interface Type and Input Port Number", 24, 496, 328, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$InterfaceTypeCombo = GUICtrlCreateCombo("", 48, 520, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetState(-1, $GUI_HIDE)
$RouterInterfacePortInput = GUICtrlCreateInput("", 120, 520, 89, 21)
GUICtrlSetState(-1, $GUI_HIDE)

$C4InfineraLabel = GUICtrlCreateLabel("Input Infinera Location", 24, 559, 175, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$C4InfineraLocationInput = GUICtrlCreateInput("", 48, 583, 193, 21)
GUICtrlSetState(-1, $GUI_HIDE)

$C4InstallHardwareLabel = GUICtrlCreateLabel("Choose If You Need To Install An FPC", 480, 72, 221, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUIStartGroup()
$C4YesInstallFPCRadio = GUICtrlCreateRadio("Yes", 520, 104, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
$C4NoInstallFPCRadio = GUICtrlCreateRadio("No", 584, 104, 41, 17)
GUICtrlSetState($C4NoInstallFPCRadio,$GUI_CHECKED)
GUICtrlSetState(-1, $GUI_HIDE)
GUIStartGroup()
$C4FPCLabel = GUICtrlCreateLabel("Input Which Slot You Need The FPC Installed", 456, 136, 264, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$C4FPCInstallInput = GUICtrlCreateInput("", 496, 168, 193, 21)
GUICtrlSetState(-1, $GUI_HIDE)


$C4InstallPICLabel = GUICtrlCreateLabel("Choose If You Need To Install A PIC", 480, 208, 211, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUIStartGroup()
$C4YesInstallPicRadio = GUICtrlCreateRadio("Yes", 520, 240, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
$C4NoInstallPICRadio = GUICtrlCreateRadio("No", 584, 240, 41, 17)
GUICtrlSetState($C4NoInstallPICRadio,$GUI_CHECKED)
GUICtrlSetState(-1, $GUI_HIDE)
GUIStartGroup()
$C4PICLabel = GUICtrlCreateLabel("Input Which Slot You Need The PIC Installed", 456, 272, 261, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$C4PicInput = GUICtrlCreateInput("", 496, 304, 193, 21)
GUICtrlSetState(-1, $GUI_HIDE)


$C4InstallOpticLabel = GUICtrlCreateLabel("Choose If You Need To Install An Optic", 480, 344, 228, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUIStartGroup()
$C4YesInstallOpticRadio = GUICtrlCreateRadio("Yes", 520, 376, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
$C4NoInstallOpticRadio = GUICtrlCreateRadio("No", 584, 376, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetState($C4NoInstallOpticRadio,$GUI_CHECKED)
GUIStartGroup()
$C4OpticsLabel = GUICtrlCreateLabel("Input Which Port You Need The Optics Installed", 456, 408, 278, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$C4OpticsInstallInput = GUICtrlCreateInput("", 496, 440, 193, 21)
GUICtrlSetState(-1, $GUI_HIDE)


$C4TamKitInstallLabel = GUICtrlCreateLabel("Choose If You Need To Install A TAM/TIM", 480, 484, 245, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUIStartGroup()
$C4YesInstallTamKitRadio = GUICtrlCreateRadio("Yes", 520, 516, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
$C4NoInstallTamKitRadio = GUICtrlCreateRadio("No", 584, 516, 41, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetState($C4NoInstallTamKitRadio,$GUI_CHECKED)
GUIStartGroup()

$C4ClearButton = GUICtrlCreateButton("Clear", 488, 560, 89, 33)
GUICtrlSetState(-1, $GUI_HIDE)
$C4SubmitButton = GUICtrlCreateButton("Submit", 616, 560, 89, 33)
GUICtrlSetState(-1, $GUI_HIDE)

GUICtrlSetData($InterfaceTypeCombo, "et|ge|xe", "Choose Interface Type")

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $C4CoreProjectTypeRadio
            guictrlsetstate($C4NumberOfProjectsLabel, $GUI_SHOW)
guictrlsetstate($NumberOfProjectsInput, $GUI_SHOW)
guictrlsetstate($C4ProjectSideLabel, $GUI_SHOW)
guictrlsetstate($C4OtherSiteRouter, $GUI_SHOW)

guictrlsetstate($C4RouterSideLabel, $GUI_SHOW)
guictrlsetstate($RouterNameCombo, $GUI_SHOW)
guictrlsetstate($C4RouterInterfacePortLabel, $GUI_SHOW)
guictrlsetstate($InterfaceTypeCombo, $GUI_SHOW)
guictrlsetstate($RouterInterfacePortInput, $GUI_SHOW)
guictrlsetstate($C4InfineraLabel, $GUI_SHOW)
guictrlsetstate($C4InfineraLocationInput, $GUI_SHOW)
guictrlsetstate($C4InstallHardwareLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallFPCRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallFPCRadio, $GUI_SHOW)
guictrlsetstate($C4InstallPICLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallPicRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallPICRadio, $GUI_SHOW)
guictrlsetstate($C4YesInstallOpticRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallOpticRadio, $GUI_SHOW)
guictrlsetstate($C4TamKitInstallLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallTamKitRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallTamKitRadio, $GUI_SHOW)
guictrlsetstate($C4InstallOpticLabel, $GUI_SHOW)
        Case $C4ClearButton;;;;;;;;THIS WILL CLEAR OUT ALL OF INPUT BOXES AND SET THE RADIO BOXES BACK TO NO WHICH WILL HIDE THOSE LABELS AND INPUT BOXES AS WELL.
            _ClearAll()
        Case $C4YesInstallFPCRadio
            guictrlsetstate($C4FPCLabel, $GUI_SHOW)
            guictrlsetstate($C4FPCInstallInput, $GUI_SHOW)
        Case $C4NoInstallFPCRadio
            guictrlsetstate($C4FPCLabel, $GUI_HIDE)
            guictrlsetstate($C4FPCInstallInput, $GUI_HIDE)
            GUICtrlSetData($C4FPCInstallInput,"")
        Case $C4YesInstallPicRadio
            guictrlsetstate($C4PicLabel, $GUI_SHOW)
            guictrlsetstate($C4PicInput, $GUI_SHOW)
        Case $C4NoInstallPicRadio
            guictrlsetstate($C4PicInput, $GUI_HIDE)
            guictrlsetstate($C4PicLabel, $GUI_HIDE)
            GUICtrlSetData($C4PicInput,"")
        Case $C4YesInstallOpticRadio
            guictrlsetstate($C4OpticsLabel, $GUI_SHOW)
            guictrlsetstate($C4OpticsInstallInput, $GUI_SHOW)
        Case $C4NoInstallPicRadio
            guictrlsetstate($C4OpticsLabel, $GUI_HIDE)
            guictrlsetstate($C4OpticsInstallInput, $GUI_HIDE)
            GUICtrlSetData($C4OpticsInstallInput,"")


        Case $NumberOfProjectsInput

If  guictrlread ($NumberOfProjectsInput) > 1 Then;;;;;;;;;;;;;;;;;;;;   IF THE NUMBER OF PROJECTS IS MORE THAN 1 THEN WE ARE CHANGING THE VALUE OF THE SUBMIT BUTTON TO "NEXT PROJECT"
        GUICtrlSetData ($C4SubmitButton, "Next Project")
        GUICtrlSetState($C4SubmitButton, $GUI_SHOW)
        GUICtrlSetState($C4ClearButton, $GUI_SHOW)
    EndIf
If  guictrlread ($NumberOfProjectsInput) = 1 Then;;;;;;;;;;;;;;;;;;;;   IF THE NUMBER OF PROJECTS IS 1 THEN WE ARE CHANGING THE VALUE OF THE SUBMIT BUTTON TO "DONE"
        GUICtrlSetData ($C4SubmitButton, "Done")
        GUICtrlSetState($C4SubmitButton, $GUI_SHOW)
        GUICtrlSetState($C4ClearButton, $GUI_SHOW)

    EndIf


        Case $C4SubmitButton
        IF (guictrlread ($NumberOfProjectsInput) = 1 AND ($I) = 0) Then;;;;THIS WILL CHECK TO SEE THE NUMBER OF PROJECTS IS MORE THAN 1 BUT THAT $1 IS ZERO SO THAT WE CAN GRAB THE FIRST PART OF THE EMAIL.
;MsgBox(0,"Variable Checker", "The number of $I is " & $I)

$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,GUICtrlRead ($ProjectSiteCombo))
FileWrite($c4file, ",")
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file,"We recently have launched the below C4 projects for your system. We need on site assistance to perform the maintenance. let us know who the Point of Contact for this activity will be so we can ship the hardware and plan the maintenance. " & @CRLF & @CRLF & @CRLF & @CRLF & "Details for Capacity Projects:")
FileWrite($c4file,@CRLF & @CRLF& @CRLF)
FileWrite($c4file,"Project:")
FileWrite($c4file,GUICtrlRead ($ProjectNameInputBox))
FileWrite($c4file,@CRLF & @CRLF& @CRLF)
FileWrite($c4file,"These projects are to add an additional ")
FileWrite($c4file, GUICtrlRead ($NumberOfProjectsInput) * 10)
FileWrite($c4file, "GB of capacity between ")
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, " and ")
FileWrite($c4file, GUICtrlRead ($C4OtherSiteRouter))
FileWrite($c4file, ".")
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, ": Connect fiber into ")
FileWrite($c4file, GUICtrlRead ($InterfaceTypeCombo))
FileWrite($c4file, "-")
FileWrite($c4file, GUICtrlRead ($RouterInterfacePortInput))
FileWrite($c4file, @CRLF)

FileClose($c4file)
If not  GUICtrlRead ($C4FPCInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install FPC into slot ")
FileWrite($c4file, GUICtrlRead ($C4FPCInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4PicInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install PIC into slot ")
FileWrite($c4file, GUICtrlRead ($C4PicInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4OpticsInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install optic into slot ")
FileWrite($c4file,GUICtrlRead ($C4OpticsInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
If guictrlread($ProjectNameInputBox) = '' then
                MsgBox(0,"Error",'Project name required')
                guictrlsetstate($ProjectNameInputBox,$gui_focus)
                continueloop
            endif
if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Project site required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($NumberOfProjectsInput) = '' then
                MsgBox(0,"Error", 'Number of projects required')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif


If not stringisdigit(guictrlread($NumberOfProjectsInput)) then
                MsgBox(0,"Error",'Number of projects must be numeric')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif

if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Your site router required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($InterfaceTypeCombo) = '' then
                MsgBox(0,"Error",'Router interface type required')
                guictrlsetstate($InterfaceTypeCombo,$gui_focus)
                continueloop
            endif

If guictrlread($RouterInterfacePortInput) = '' then
                MsgBox(0,"Error",'Router interface port required')
                guictrlsetstate($RouterInterfacePortInput,$gui_focus)
                continueloop
                endif

If guictrlread($C4OtherSiteRouter) = '' then
                MsgBox(0,"Error",'Other site router required')
                guictrlsetstate($C4OtherSiteRouter,$gui_focus)
                continueloop
            endif

_ClearAll()

;MSGBOX(0,"Finished", "You have entered all the information needed.  Your email is being generated to be viewed before sending.");;;MSGBOX TO LET USER KNOW THEY ARE DONE AND THE EMAIL IS BEING GENERATED.
ClipPut($c4file = FileOpen("c4.txt",1))
GUISetState(@SW_HIDe)
$EmailForm = GUICreate("Maintenance Email Notification", 831, 518, -1435, 222)
$CoxLabel = GUICtrlCreateLabel("Maintenance Email Notification ", 25, 22, 780, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$EmailEdit = GUICtrlCreateEdit("", 32, 72, 761, 401,BitOr($ES_MULTILINE, $WS_VSCROLL))
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, "")
$CopyButton = GUICtrlCreateButton("Copy To Clipboard", 680, 480, 99, 25)
local $test= Fileread("c4.txt")
ClipPut($test)
FileClose($c4file)
FileDelete("c4.txt")
GUICtrlSetData($EmailEdit, ClipGet())
ClipPut("")
GUICtrlSetState($EmailEdit, $GUI_SHOW)
GUICtrlSetState($EmailEdit, $gui_focus)
;GUICtrlSetState($EmailEdit, $gui_disable)
;GUICtrlSetState($EmailEdit, $gui_enable)
GUISetState()
EndIf
;$I= ($I + 1)


IF (guictrlread ($NumberOfProjectsInput) > 1 AND ($I) >= 0) Then;;;;THIS WILL CHECK TO SEE THE NUMBER OF PROJECTS IS MORE THAN 1 BUT THAT $1 IS ZERO SO THAT WE CAN GRAB THE FIRST PART OF THE EMAIL.
IF (guictrlread ($NumberOfProjectsInput) > 1 AND ($I) = 0) Then;;;;THIS WILL CHECK TO SEE THE NUMBER OF PROJECTS IS MORE THAN 1 BUT THAT $1 IS ZERO SO THAT WE CAN GRAB THE FIRST PART OF THE EMAIL.
;MsgBox(0,"Variable Checker", "The number of $I is " & $I)

$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,GUICtrlRead ($ProjectSiteCombo))
FileWrite($c4file, ",")
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file,"We recently have launched the below C4 projects for your system. We need on site assistance to perform the maintenance. let us know who the Point of Contact for this activity will be so we can ship the hardware and plan the maintenance. " & @CRLF & @CRLF & @CRLF & @CRLF & "Details for Capacity Projects:")
FileWrite($c4file,@CRLF & @CRLF& @CRLF)
FileWrite($c4file, @CRLF)
FileWrite($c4file,"Project:")
FileWrite($c4file,GUICtrlRead ($ProjectNameInputBox))
FileWrite($c4file,@CRLF & @CRLF& @CRLF)
FileWrite($c4file,"These projects are to add an additional ")
FileWrite($c4file, GUICtrlRead ($NumberOfProjectsInput) * 10)
FileWrite($c4file, "GB of capacity between ")
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, " and ")
FileWrite($c4file, GUICtrlRead ($C4OtherSiteRouter))
FileWrite($c4file, ".")
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, ": Connect fiber into ")
FileWrite($c4file, GUICtrlRead ($InterfaceTypeCombo))
FileWrite($c4file, "-")
FileWrite($c4file, GUICtrlRead ($RouterInterfacePortInput))
FileWrite($c4file, @CRLF)

FileClose($c4file)
If not  GUICtrlRead ($C4FPCInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install FPC into slot ")
FileWrite($c4file, GUICtrlRead ($C4FPCInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4PicInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install PIC into slot ")
FileWrite($c4file, GUICtrlRead ($C4PicInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4OpticsInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install optic into slot ")
FileWrite($c4file,GUICtrlRead ($C4OpticsInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
If guictrlread($ProjectNameInputBox) = '' then
                MsgBox(0,"Error",'Project name required')
                guictrlsetstate($ProjectNameInputBox,$gui_focus)
                continueloop
            endif
if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Project site required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($NumberOfProjectsInput) = '' then
                MsgBox(0,"Error", 'Number of projects required')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif


If not stringisdigit(guictrlread($NumberOfProjectsInput)) then
                MsgBox(0,"Error",'Number of projects must be numeric')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif

if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Your site router required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($InterfaceTypeCombo) = '' then
                MsgBox(0,"Error",'Router interface type required')
                guictrlsetstate($InterfaceTypeCombo,$gui_focus)
                continueloop
            endif

If guictrlread($RouterInterfacePortInput) = '' then
                MsgBox(0,"Error",'Router interface port required')
                guictrlsetstate($RouterInterfacePortInput,$gui_focus)
                continueloop
                endif

If guictrlread($C4OtherSiteRouter) = '' then
                MsgBox(0,"Error",'Other site router required')
                guictrlsetstate($C4OtherSiteRouter,$gui_focus)
                continueloop
            endif



NextProject()
            local $aprojincr = stringregexp(guictrlread($ProjectNameInputBox),"(?<=-\d{2})([A-Z])(?=-Q)",3)
                local $incr_char = chr(asc($aprojincr[0])+1)
                guictrlsetdata($ProjectNameInputBox,StringRegExpReplace(guictrlread($ProjectNameInputBox), _
                "(?<=-\d{2})([A-Z])(?=-Q)", $incr_char))
$I= ($I + 1)
EndIf
IF (guictrlread ($NumberOfProjectsInput) > 1 AND ($I) >= 1) Then


$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file,"Project:")
FileWrite($c4file,GUICtrlRead ($ProjectNameInputBox))
FileWrite($c4file,@CRLF & @CRLF& @CRLF)
FileWrite($c4file,"These projects are to add an additional ")
FileWrite($c4file, GUICtrlRead ($NumberOfProjectsInput) * 10)
FileWrite($c4file, "GB of capacity between ")
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, " and ")
FileWrite($c4file, GUICtrlRead ($C4OtherSiteRouter))
FileWrite($c4file, ".")
FileWrite($c4file,@CRLF & @CRLF)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file, ": Connect fiber into ")
FileWrite($c4file, GUICtrlRead ($InterfaceTypeCombo))
FileWrite($c4file, "-")
FileWrite($c4file, GUICtrlRead ($RouterInterfacePortInput))
FileWrite($c4file, @CRLF)

FileClose($c4file)
If not  GUICtrlRead ($C4FPCInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file,GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install FPC into slot ")
FileWrite($c4file, GUICtrlRead ($C4FPCInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4PicInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install PIC into slot ")
FileWrite($c4file, GUICtrlRead ($C4PicInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
if not guictrlread ($C4OpticsInstallInput) = "" Then
$c4file = FileOpen("c4.txt",1)
FileWrite($c4file, GUICtrlRead ($RouterNameCombo))
FileWrite($c4file,": Install optic into slot ")
FileWrite($c4file,GUICtrlRead ($C4OpticsInstallInput))
FileWrite($c4file, @CRLF)
FileClose($c4file)
EndIf
If guictrlread($ProjectNameInputBox) = '' then
                MsgBox(0,"Error",'Project name required')
                guictrlsetstate($ProjectNameInputBox,$gui_focus)
                continueloop
            endif
if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Project site required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($NumberOfProjectsInput) = '' then
                MsgBox(0,"Error", 'Number of projects required')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif


If not stringisdigit(guictrlread($NumberOfProjectsInput)) then
                MsgBox(0,"Error",'Number of projects must be numeric')
                guictrlsetstate($NumberOfProjectsInput,$gui_focus)
                continueloop
            endif

if guictrlread($ProjectSiteCombo) = '' Then
                MsgBox(0,"Error",'Your site router required')
                guictrlsetstate($ProjectSiteCombo,$gui_focus)
                continueloop
            endif

If guictrlread($InterfaceTypeCombo) = '' then
                MsgBox(0,"Error",'Router interface type required')
                guictrlsetstate($InterfaceTypeCombo,$gui_focus)
                continueloop
            endif

If guictrlread($RouterInterfacePortInput) = '' then
                MsgBox(0,"Error",'Router interface port required')
                guictrlsetstate($RouterInterfacePortInput,$gui_focus)
                continueloop
                endif

If guictrlread($C4OtherSiteRouter) = '' then
                MsgBox(0,"Error",'Other site router required')
                guictrlsetstate($C4OtherSiteRouter,$gui_focus)
                continueloop
            endif

NextProject()
local $aprojincr = stringregexp(guictrlread($ProjectNameInputBox),"(?<=-\d{2})([A-Z])(?=-Q)",3)
                local $incr_char = chr(asc($aprojincr[0])+1)
                guictrlsetdata($ProjectNameInputBox,StringRegExpReplace(guictrlread($ProjectNameInputBox), _
                "(?<=-\d{2})([A-Z])(?=-Q)", $incr_char))

$I= ($I + 1)
IF $I = (guictrlread ($NumberOfProjectsInput))  Then
;MSGBOX(0,"Finished", "You have entered all the information needed.  Your email is being generated to be viewed before sending.");;;MSGBOX TO LET USER KNOW THEY ARE DONE AND THE EMAIL IS BEING GENERATED.
ClipPut($c4file = FileOpen("c4.txt",1))
GUISetState(@SW_HIDe)
$EmailForm = GUICreate("Maintenance Email Notification", 831, 518, -1435, 222)
$CoxLabel = GUICtrlCreateLabel("Maintenance Email Notification ", 25, 22, 780, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$EmailEdit = GUICtrlCreateEdit("", 32, 72, 761, 401,BitOr($ES_MULTILINE, $WS_VSCROLL))
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, "")
$CopyButton = GUICtrlCreateButton("Copy To Clipboard", 680, 480, 99, 25)
local $test= Fileread("c4.txt")
ClipPut($test)
FileClose($c4file)
FileDelete("c4.txt")
GUICtrlSetData($EmailEdit, ClipGet())
ClipPut("")
GUICtrlSetState($EmailEdit, $GUI_SHOW)
GUICtrlSetState($EmailEdit, $gui_focus)
GUISetState()
EndIf
EndIf
EndIf

        Case $CopyButton
    CopyButton()
        EndSwitch
        wEnd
Func NextProject()
            guictrlsetstate($C4FPCLabel, $GUI_HIDE)
            GUICtrlSetData($C4FPCInstallInput, "")
            GUICtrlSetState($C4FPCInstallInput, $GUI_HIDE)
            guictrlsetstate($C4PicLabel, $GUI_HIDE)
            GUICtrlSetData($C4PicInput, "")
            GUICtrlSetState($C4PicInput, $GUI_HIDE)
            guictrlsetstate($C4PicLabel, $GUI_HIDE)
            GUICtrlSetData($C4OpticsInstallInput, "")
            guictrlsetstate($C4OpticsLabel, $GUI_HIDE)
            GUICtrlSetState($C4OpticsInstallInput,$GUI_HIDE)
            GUICtrlSetData($C4OpticsInstallInput,"")
            GUICtrlSetData($RouterInterfacePortInput,"")
            GUICtrlSetData($C4InfineraLocationInput,"")
            GUICtrlSetState($C4NoInstallTamKitRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallFPCRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallPICRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallOpticRadio,$GUI_CHECKED)
            ;GUICtrlSetData($ProjectNameInputBox, "")
            ;GUICtrlSetData($NumberOfProjectsInput, "")
            _GUICtrlComboBox_SetCurSel($C4OtherSiteRouter, -1)
            ;_GUICtrlComboBox_ResetContent($RouterNameCombo)
            ;_GUICtrlComboBox_SetCurSel($RouterNameCombo, -1)
            ;_GUICtrlComboBox_SetCurSel($ProjectSiteCombo, -1)
            _GUICtrlComboBox_SetCurSel($InterfaceTypeCombo, -1)
EndFunc
Func CopyButton()
    ClipPut(GUICtrlRead($EmailEdit))
EndFunc
Func _ClearAll()
guictrlsetstate($C4FPCLabel, $GUI_HIDE)
            GUICtrlSetData($C4FPCInstallInput, "")
            GUICtrlSetState($C4FPCInstallInput, $GUI_HIDE)
            guictrlsetstate($C4PicLabel, $GUI_HIDE)
            GUICtrlSetData($C4PicInput, "")
            GUICtrlSetState($C4PicInput, $GUI_HIDE)
            guictrlsetstate($C4PicLabel, $GUI_HIDE)
            GUICtrlSetData($C4OpticsInstallInput, "")
            guictrlsetstate($C4OpticsLabel, $GUI_HIDE)
            GUICtrlSetState($C4OpticsInstallInput,$GUI_HIDE)
            GUICtrlSetData($C4OpticsInstallInput,"")
            GUICtrlSetData($RouterInterfacePortInput,"")
            GUICtrlSetData($C4InfineraLocationInput,"")
            GUICtrlSetState($C4NoInstallTamKitRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallFPCRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallPICRadio,$GUI_CHECKED)
            GUICtrlSetState($C4NoInstallOpticRadio,$GUI_CHECKED)
            _GUICtrlComboBox_SetCurSel($C4OtherSiteRouter, -1)
            _GUICtrlComboBox_ResetContent($RouterNameCombo)
            _GUICtrlComboBox_SetCurSel($RouterNameCombo, -1)
            _GUICtrlComboBox_SetCurSel($ProjectSiteCombo, -1)
            _GUICtrlComboBox_SetCurSel($InterfaceTypeCombo, -1)
EndFunc
Func _C4()
guictrlsetstate($C4NumberOfProjectsLabel, $GUI_SHOW)
guictrlsetstate($NumberOfProjectsInput, $GUI_SHOW)
guictrlsetstate($C4ProjectSideLabel, $GUI_SHOW)
guictrlsetstate($C4OtherSiteRouter, $GUI_SHOW)

guictrlsetstate($C4RouterSideLabel, $GUI_SHOW)
guictrlsetstate($RouterNameCombo, $GUI_SHOW)
guictrlsetstate($C4RouterInterfacePortLabel, $GUI_SHOW)
guictrlsetstate($InterfaceTypeCombo, $GUI_SHOW)
guictrlsetstate($RouterInterfacePortInput, $GUI_SHOW)
guictrlsetstate($C4InfineraLabel, $GUI_SHOW)
guictrlsetstate($C4InfineraLocationInput, $GUI_SHOW)
guictrlsetstate($C4InstallHardwareLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallFPCRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallFPCRadio, $GUI_SHOW)
guictrlsetstate($C4InstallPICLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallPicRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallPICRadio, $GUI_SHOW)
guictrlsetstate($C4YesInstallOpticRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallOpticRadio, $GUI_SHOW)
guictrlsetstate($C4TamKitInstallLabel, $GUI_SHOW)
guictrlsetstate($C4YesInstallTamKitRadio, $GUI_SHOW)
guictrlsetstate($C4NoInstallTamKitRadio, $GUI_SHOW)
guictrlsetstate($C4InstallOpticLabel, $GUI_SHOW)
EndFunc
Edited by atnextc
Link to comment
Share on other sites

You have coded everything line-by-line.

Try using For-Next loops

The return of creating any control is a ControlID (an integer) use it wisely to reduce your code

For example 

if you create a label ($label) and just after that two radio($radio_yes and $radio_no) then

$radio_yes = $label + 1 and $radio_no = $label + 2 

The sequence is important under such logic

Simultaneously rather than creating every control, try to find out a definite pattern by which your controls go towards y/x axis and keep adding them in the creation process.

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

An Example

#include <GUIConstants.au3>

GUICreate("", 500, 700)

$Label_1 = GUICtrlCreateLabel("1", 10, 10)  ;store the first value
For $i = 2 To 15
    GUICtrlCreateLabel($i, 10, 10 + ($i - 2) * 15)
Next
$Label_last = GUICtrlCreateLabel(16, 10, 10 + (16 - 2) * 15)    ;store the last value

GUISetState()

;the following is how to receive events
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit

        Case $Label_1 To $Label_last
            MsgBox(64, GUICtrlRead($nMsg), "Label" & $nMsg - $Label_1 + 1)

    EndSwitch
WEnd

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

It's expected. That's why it's best to use the help file and examples. Learn to walk before you can run, that's my advice.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

thanks for the reply guinness, I've read the help files and looked at tons of examples...I just don't understand alot of it. I'm not a programmer, so I'm working with what I know :)  trying to simplify code that I have written so its easier to maintain and update if needed at a later date.

Link to comment
Share on other sites

  • Moderators

And PhoenixXL has provided you with that. I suggest you go through the code he offered you line by line, and look up the different functions in the help file to understand what they're doing. It's okay if you don't understand everything, but you need to make the effort to learn.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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