Jump to content

For Loop


Recommended Posts

Hello All

i am newbie to the AutoIt and given a task to automate the SQLSERVER2000 Scripts. and just caught in a problem with FOR loop. the following is the script. with two functions.

the problem is that when i enter the no. of subscribers (e.g.- 2) then for the first time the below functions works. but for second time the first window comes but the 'submit' button does not work and it hangs. pls help..............

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Date.au3>
#include "Variable Declaration.au3"


SubscribersToPublisherWindow()


Func SubscribersToPublisherWindow()

Opt('MustDeclareVars', 0)
Local $SubscriberToPublisherWindowInput
Local $msg5, $SubmitButton

    GUICreate("Please Provide Input", 245, 130)
    GUICtrlCreateLabel("Please enter the number of Subscribers you", 20, 10)
    GUICtrlCreateLabel("want to add to the Publisher.", 55, 30)
    $SubscriberToPublisherWindowInput = GUICtrlCreateInput("", 85, 60, 80, 0, $ES_NUMBER)
    $SubmitButton = GUICtrlCreateButton("Submit", 96, 90, 60)
    GUISetState(@SW_SHOW) 

    While 1
        
        $msg5 = GUIGetMsg()
        
        Select 
            
            Case $msg5 = $SubmitButton
                 $SubscriberToPublisherWindowButton = GUICtrlRead($SubscriberToPublisherWindowInput)
                 
                 ExitLoop
            
            Case $msg5 = $GUI_EVENT_CLOSE
                Exitloop
        
        EndSelect
    
    WEnd

    GUIDelete()
    WinWaitClose("Please Provide Input")
    Opt("GUIOnEventMode",1)

EndFunc 
;-----------------------------------------------------------------------------------------------------

SubscriberNameWindow()

;-----------------------------------------------------------------------------------------------------


Func SubscriberNameWindow()

    Local $msg6
    Local $SubscriberNameWindow1, $SubscriberNameWindow2, $OkButton
    Local $TotalSubscribers, $SubscriberNameInput, $SubscriberName
    
Opt("GUIOnEventMode",0)
    
    Do                                                                                                      ;a loop condition which remains continue until the expression below is true.
        
        $TotalSubscribers = $TotalSubscribers + 1                                   
    Until $TotalSubscribers = $SubscriberToPublisherWindowButton

    For $TotalSubscribers = $SubscriberToPublisherWindowButton To 1 step -1 
        
            
            GUICreate("Please Provide Name", 245, 130)
            gUICtrlCreateLabel("Please enter the name of Subscriber", 20, 10)
            $SubscriberNameInput = GUICtrlCreateInput("", 85, 60, 80, 0)
            $OkButton = GUICtrlCreateButton("OK", 96, 90, 60)
            GUISetState() 
                
        While 1
                
            $msg6 = GUIGetMsg()
                
                Select 
                        
                    Case $msg6 = $OkButton
                        $SubscriberName1 = GUICtrlRead($SubscriberNameInput)
                        ExitLoop
                        
                    Case $msg6 = $GUI_EVENT_CLOSE
                        Exitloop
                    
                EndSelect
            
        WEnd

        GUIDelete()
        WinWaitClose("Please Provide Name")
        Opt("GUIOnEventMode",1)
        
;------------------------------------------------------------------------------------------------

        Local $FindTMATRIX, $FindScript, $UsedScripts, $RepScripts
        Local $FindTMATRIX1, $FindScript1, $UsedScripts1, $RepScripts1
        Local $RetValue = True
        Local $LocalOutput

        AutoItSetOption("sendkeydelay", 100)

            Run("notepad.exe")
                IF @error <> 0 Then
                    MsgBox(1, "Error", "An Error has occured while opening 'Notepad'")
                    Return $RetValue = False
                EndIf
            
            WinWait("Untitled - Notepad")
            Send("^o")
            sleep(500)
            Send ("!t")
            Send ("a")
            Send ("{Enter}")
            Send ("!i")
            Send ("{down}")
            sleep(1000)
            Send ("{Up 15}")
            Send ("{down 4}")
            Send ("{Enter}")
            
            $FindTMATRIX = ControlListView("Open", "", 1, "FindItem", "T-MATRIX")
                If $FindTMATRIX = -1 Then
                    MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            $LocalOutput = ControlListView("Open", "", 1, "Select", $FindTMATRIX)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            Send ("{Enter}")
            
            $RepScripts = ControlListView("Open", "", 1, "FindItem", "replication scripts")
                If $RepScripts = -1 Then
                    MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in path C:\T-MATRIX")
                    $RetValue = False
                EndIf
            
            $LocalOutput = ControlListView("Open", "", 1, "Select", $RepScripts)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in path C:\T-MATRIX")
                    $RetValue = False
                EndIf
            
            Send ("{Enter}")
            
            $FindScript = ControlListView ("Open", "", 1, "FindItem", "Add Subscriber to Publisher.sql")
                If $FindScript = -1 Then
                    MsgBox(0, "Error", "Not able to find 'Add Subscriber to Publisher.sql' in path 'C:\T-MATRIX\replication scripts'")
                    $RetValue = False
                EndIf
                
            sleep(1000)
            
            ControlListView ("Open", "", 1, "Select", $FindScript)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            Send("{Enter}")
            WinWait("Add Subscriber to Publisher.sql - Notepad")
            Send("^h")
            WinWait("Replace")
            Send("!n")
            Send("SUBSCRIBERNAME")
            Send("!p")
            Send($SubscriberName1)
            Send("!a")
            
            WinClose ("Replace")
            sleep(1000)
            
            WinWait("Add Subscriber to Publisher.sql - Notepad")
        
            
            Send("!F")
            Send("{DOWN 2}")
            Send("{Enter}")
            
            WinClose("Add Subscriber to Publisher.sql")
            
            Run ('osql -S ' & $SubscriberName1 & ' -E -i "C:\T-MATRIX\Used Scripts\Add Subscribers to Publisher.sql"')
                IF @error <> 0 Then
                    MsgBox(1, "Error", "An Error has occured while running the script - 'Add Subscriber to Publisher.sql'")
                    Return $RetValue = False
                EndIf
                
            sleep (5000)

;------------------------------------------------------------------------

            Run("notepad.exe")
                IF @error <> 0 Then
                    MsgBox(1, "Error", "An Error has occured while opening 'Notepad'")
                    Return $RetValue = False
                EndIf
            
            WinWait("Untitled - Notepad")
            Send("^o")
            sleep(500)
            Send ("!t")
            Send ("a")
            Send ("{Enter}")
            Send ("!i")
            Send ("{down}")
            sleep(1000)
            Send ("{Up 15}")
            Send ("{down 4}")
            Send ("{Enter}")
            
            $FindTMATRIX = ControlListView("Open", "", 1, "FindItem", "T-MATRIX")
                If $FindTMATRIX = -1 Then
                    MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            $LocalOutput = ControlListView("Open", "", 1, "Select", $FindTMATRIX)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            Send ("{Enter}")
            
            $RepScripts = ControlListView("Open", "", 1, "FindItem", "replication scripts")
                If $RepScripts = -1 Then
                    MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in path C:\T-MATRIX")
                    $RetValue = False
                EndIf
            
            $LocalOutput = ControlListView("Open", "", 1, "Select", $RepScripts)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in path C:\T-MATRIX")
                    $RetValue = False
                EndIf
            
            Send ("{Enter}")
            
            $FindScript = ControlListView ("Open", "", 1, "FindItem", "Add Subscriber to Publisher.sql")
                If $FindScript = -1 Then
                    MsgBox(0, "Error", "Not able to find 'Add Subscriber to Publisher.sql' in path 'C:\T-MATRIX\replication scripts'")
                    $RetValue = False
                EndIf
                
            sleep(1000)
            
            ControlListView ("Open", "", 1, "Select", $FindScript)
                If @error = 1 Then
                    MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")
                    $RetValue = False
                EndIf
                
            Send("{Enter}")
            WinWait("Add Subscriber to Publisher.sql - Notepad")
            Send("^h")
            WinWait("Replace")
            Send("!n")
            Send($SubscriberName1)
            Send("!p")
            Send("SUBSCRIBERNAME")
            Send("!a")
            
            WinClose ("Replace")
            sleep(1000)
            
            WinWait("Add Subscriber to Publisher.sql - Notepad")
        
            
            Send("!F")
            Send("{DOWN 2}")
            Send("{Enter}")
            
            WinClose("Add Subscriber to Publisher.sql")
            
                
                
                
                

        Sleep(5000)
        
    Next    

    
EndFunc

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

After the while loop in the second function you define Opt("GUIOnEventMode", 1), either don't do it (can't see why you do it :D ), or add Opt("GUIOnEventMode", 0) directly after the For statement.

Link to comment
Share on other sites

  • Moderators

randeep,

Remove all the Opt("GUIOnEventMode",1) and Opt("GUIOnEventMode",0) lines. You want MessageLoop mode in your functions and you get stuck in OnEvent mode after 1 loop through your second function.

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

@Melba23

thanx 4 replying. i removed as u said but now the second window demanding for 'Name' comes but it hangs and do not go forward.

randeep,

Remove all the Opt("GUIOnEventMode",1) and Opt("GUIOnEventMode",0) lines. You want MessageLoop mode in your functions and you get stuck in OnEvent mode after 1 loop through your second function.

M23

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

@KaFu'

hello i did it as u said. but its not working.

After the while loop in the second function you define Opt("GUIOnEventMode", 1), either don't do it (can't see why you do it :D ), or add Opt("GUIOnEventMode", 0) directly after the For statement.

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

This works fine for me. There has to be an error somewhere within the winwaits I guess. Add some consolewrite("Step 1" & @crlf) and so on to the code to see where i hangs.

CODE

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <EditConstants.au3>

#include <Date.au3>

#include "Variable Declaration.au3"

Global $SubscriberToPublisherWindowButton

SubscribersToPublisherWindow()

Func SubscribersToPublisherWindow()

Opt('MustDeclareVars', 0)

Local $SubscriberToPublisherWindowInput

Local $msg5, $SubmitButton

GUICreate("Please Provide Input", 245, 130)

GUICtrlCreateLabel("Please enter the number of Subscribers you", 20, 10)

GUICtrlCreateLabel("want to add to the Publisher.", 55, 30)

$SubscriberToPublisherWindowInput = GUICtrlCreateInput("", 85, 60, 80, 0, $ES_NUMBER)

$SubmitButton = GUICtrlCreateButton("Submit", 96, 90, 60)

GUISetState(@SW_SHOW)

While 1

$msg5 = GUIGetMsg()

Select

Case $msg5 = $SubmitButton

$SubscriberToPublisherWindowButton = GUICtrlRead($SubscriberToPublisherWindowInput)

ExitLoop

Case $msg5 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete()

WinWaitClose("Please Provide Input")

EndFunc ;==>SubscribersToPublisherWindow

;-----------------------------------------------------------------------------------------------------

SubscriberNameWindow()

;-----------------------------------------------------------------------------------------------------

Func SubscriberNameWindow()

Local $msg6

Local $SubscriberNameWindow1, $SubscriberNameWindow2, $OkButton

Local $TotalSubscribers, $SubscriberNameInput, $SubscriberName

Do ;a loop condition which remains continue until the expression below is true.

$TotalSubscribers = $TotalSubscribers + 1

Until $TotalSubscribers = $SubscriberToPublisherWindowButton

For $TotalSubscribers = $SubscriberToPublisherWindowButton To 1 Step -1

GUICreate("Please Provide Name", 245, 130)

GUICtrlCreateLabel("Please enter the name of Subscriber", 20, 10)

$SubscriberNameInput = GUICtrlCreateInput("", 85, 60, 80, 0)

$OkButton = GUICtrlCreateButton("OK", 96, 90, 60)

GUISetState()

While 1

$msg6 = GUIGetMsg()

Select

Case $msg6 = $OkButton

$SubscriberName1 = GUICtrlRead($SubscriberNameInput)

ExitLoop

Case $msg6 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete()

WinWaitClose("Please Provide Name")

;------------------------------------------------------------------------------------------------

Local $FindTMATRIX, $FindScript, $UsedScripts, $RepScripts

Local $FindTMATRIX1, $FindScript1, $UsedScripts1, $RepScripts1

Local $RetValue = True

Local $LocalOutput

AutoItSetOption("sendkeydelay", 100)

#cs

Run("notepad.exe")

IF @error <> 0 Then

MsgBox(1, "Error", "An Error has occured while opening 'Notepad'")

Return $RetValue = False

EndIf

WinWait("Untitled - Notepad")

Send("^o")

sleep(500)

Send ("!t")

Send ("a")

Send ("{Enter}")

Send ("!i")

Send ("{down}")

sleep(1000)

Send ("{Up 15}")

Send ("{down 4}")

Send ("{Enter}")

$FindTMATRIX = ControlListView("Open", "", 1, "FindItem", "T-MATRIX")

If $FindTMATRIX = -1 Then

MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

$LocalOutput = ControlListView("Open", "", 1, "Select", $FindTMATRIX)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

Send ("{Enter}")

$RepScripts = ControlListView("Open", "", 1, "FindItem", "replication scripts")

If $RepScripts = -1 Then

MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in path C:\T-MATRIX")

$RetValue = False

EndIf

$LocalOutput = ControlListView("Open", "", 1, "Select", $RepScripts)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in path C:\T-MATRIX")

$RetValue = False

EndIf

Send ("{Enter}")

$FindScript = ControlListView ("Open", "", 1, "FindItem", "Add Subscriber to Publisher.sql")

If $FindScript = -1 Then

MsgBox(0, "Error", "Not able to find 'Add Subscriber to Publisher.sql' in path 'C:\T-MATRIX\replication scripts'")

$RetValue = False

EndIf

sleep(1000)

ControlListView ("Open", "", 1, "Select", $FindScript)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

Send("{Enter}")

WinWait("Add Subscriber to Publisher.sql - Notepad")

Send("^h")

WinWait("Replace")

Send("!n")

Send("SUBSCRIBERNAME")

Send("!p")

Send($SubscriberName1)

Send("!a")

WinClose ("Replace")

sleep(1000)

WinWait("Add Subscriber to Publisher.sql - Notepad")

Send("!F")

Send("{DOWN 2}")

Send("{Enter}")

WinClose("Add Subscriber to Publisher.sql")

Run ('osql -S ' & $SubscriberName1 & ' -E -i "C:\T-MATRIX\Used Scripts\Add Subscribers to Publisher.sql"')

IF @error <> 0 Then

MsgBox(1, "Error", "An Error has occured while running the script - 'Add Subscriber to Publisher.sql'")

Return $RetValue = False

EndIf

sleep (5000)

;------------------------------------------------------------------------

Run("notepad.exe")

IF @error <> 0 Then

MsgBox(1, "Error", "An Error has occured while opening 'Notepad'")

Return $RetValue = False

EndIf

WinWait("Untitled - Notepad")

Send("^o")

sleep(500)

Send ("!t")

Send ("a")

Send ("{Enter}")

Send ("!i")

Send ("{down}")

sleep(1000)

Send ("{Up 15}")

Send ("{down 4}")

Send ("{Enter}")

$FindTMATRIX = ControlListView("Open", "", 1, "FindItem", "T-MATRIX")

If $FindTMATRIX = -1 Then

MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

$LocalOutput = ControlListView("Open", "", 1, "Select", $FindTMATRIX)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

Send ("{Enter}")

$RepScripts = ControlListView("Open", "", 1, "FindItem", "replication scripts")

If $RepScripts = -1 Then

MsgBox(0, "Error", "Not able to find 'T-MATRIX' folder in path C:\T-MATRIX")

$RetValue = False

EndIf

$LocalOutput = ControlListView("Open", "", 1, "Select", $RepScripts)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in path C:\T-MATRIX")

$RetValue = False

EndIf

Send ("{Enter}")

$FindScript = ControlListView ("Open", "", 1, "FindItem", "Add Subscriber to Publisher.sql")

If $FindScript = -1 Then

MsgBox(0, "Error", "Not able to find 'Add Subscriber to Publisher.sql' in path 'C:\T-MATRIX\replication scripts'")

$RetValue = False

EndIf

sleep(1000)

ControlListView ("Open", "", 1, "Select", $FindScript)

If @error = 1 Then

MsgBox(0, "Error", "Not able to select 'T-MATRIX' folder in C:\ Drive")

$RetValue = False

EndIf

Send("{Enter}")

WinWait("Add Subscriber to Publisher.sql - Notepad")

Send("^h")

WinWait("Replace")

Send("!n")

Send($SubscriberName1)

Send("!p")

Send("SUBSCRIBERNAME")

Send("!a")

WinClose ("Replace")

sleep(1000)

WinWait("Add Subscriber to Publisher.sql - Notepad")

Send("!F")

Send("{DOWN 2}")

Send("{Enter}")

WinClose("Add Subscriber to Publisher.sql")

Sleep(5000)

#ce

Next

EndFunc ;==>SubscriberNameWindow

Link to comment
Share on other sites

  • Moderators

randeep,

With the Opt(OnEventMode) lines removed, your script works for me - although I made the following changes:

Commented out #include "Variable Declaration.au3"

Added Global $SubscriberToPublisherWindowButton - probably because of above

Removed all the Publisher specific code

Added a bit of positional error-checking

This is what I ended up with:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Date.au3>
;#include "Variable Declaration.au3"

Global $SubscriberToPublisherWindowButton

SubscribersToPublisherWindow()

Func SubscribersToPublisherWindow()

Opt('MustDeclareVars', 0)
Local $SubscriberToPublisherWindowInput
Local $msg5, $SubmitButton

    GUICreate("Please Provide Input", 245, 130)
    GUICtrlCreateLabel("Please enter the number of Subscribers you", 20, 10)
    GUICtrlCreateLabel("want to add to the Publisher.", 55, 30)
    $SubscriberToPublisherWindowInput = GUICtrlCreateInput("", 85, 60, 80, 0, $ES_NUMBER)
    $SubmitButton = GUICtrlCreateButton("Submit", 96, 90, 60)
    GUISetState(@SW_SHOW)

    While 1

        $msg5 = GUIGetMsg()

        Select

            Case $msg5 = $SubmitButton
                 $SubscriberToPublisherWindowButton = GUICtrlRead($SubscriberToPublisherWindowInput)

                 ExitLoop

            Case $msg5 = $GUI_EVENT_CLOSE
                Exitloop

        EndSelect

    WEnd

    GUIDelete()
    WinWaitClose("Please Provide Input")
   ;Opt("GUIOnEventMode",1)

EndFunc
;-----------------------------------------------------------------------------------------------------

ConsoleWrite("Here 1" & @CRLF)

SubscriberNameWindow()

;-----------------------------------------------------------------------------------------------------

Func SubscriberNameWindow()

    Local $msg6
    Local $SubscriberNameWindow1, $SubscriberNameWindow2, $OkButton
    Local $TotalSubscribers, $SubscriberNameInput, $SubscriberName

;Opt("GUIOnEventMode",0)

    Do                                                 ;a loop condition which remains continue until the expression below is true.

        $TotalSubscribers = $TotalSubscribers + 1
    Until $TotalSubscribers = $SubscriberToPublisherWindowButton

    For $TotalSubscribers = $SubscriberToPublisherWindowButton To 1 step -1

            GUICreate("Please Provide Name", 245, 130)
            gUICtrlCreateLabel("Please enter the name of Subscriber", 20, 10)
            $SubscriberNameInput = GUICtrlCreateInput("", 85, 60, 80, 0)
            $OkButton = GUICtrlCreateButton("OK", 96, 90, 60)
            GUISetState()

        While 1

            $msg6 = GUIGetMsg()

                Select

                    Case $msg6 = $OkButton
                        $SubscriberName1 = GUICtrlRead($SubscriberNameInput)
                        ExitLoop

                    Case $msg6 = $GUI_EVENT_CLOSE
                        Exitloop

                EndSelect

        WEnd

        GUIDelete()
        WinWaitClose("Please Provide Name")
       ;Opt("GUIOnEventMode",1)

    Next

EndFunc

ConsoleWrite("Here 2" & @CRLF)

I can add as many names as I want and get to the final "Here 2"

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

@Melba23

i have no words to thank you. :D

i am facing this problem since morning.

thaaaaaaaaanxxxxxxxxxxxxxxx

you rock

randeep,

With the Opt(OnEventMode) lines removed, your script works for me - although I made the following changes:

Commented out #include "Variable Declaration.au3"

Added Global $SubscriberToPublisherWindowButton - probably because of above

Removed all the Publisher specific code

Added a bit of positional error-checking

This is what I ended up with:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Date.au3>
;#include "Variable Declaration.au3"

Global $SubscriberToPublisherWindowButton

SubscribersToPublisherWindow()

Func SubscribersToPublisherWindow()

Opt('MustDeclareVars', 0)
Local $SubscriberToPublisherWindowInput
Local $msg5, $SubmitButton

    GUICreate("Please Provide Input", 245, 130)
    GUICtrlCreateLabel("Please enter the number of Subscribers you", 20, 10)
    GUICtrlCreateLabel("want to add to the Publisher.", 55, 30)
    $SubscriberToPublisherWindowInput = GUICtrlCreateInput("", 85, 60, 80, 0, $ES_NUMBER)
    $SubmitButton = GUICtrlCreateButton("Submit", 96, 90, 60)
    GUISetState(@SW_SHOW)

    While 1

        $msg5 = GUIGetMsg()

        Select

            Case $msg5 = $SubmitButton
                 $SubscriberToPublisherWindowButton = GUICtrlRead($SubscriberToPublisherWindowInput)

                 ExitLoop

            Case $msg5 = $GUI_EVENT_CLOSE
                Exitloop

        EndSelect

    WEnd

    GUIDelete()
    WinWaitClose("Please Provide Input")
  ;Opt("GUIOnEventMode",1)

EndFunc
;-----------------------------------------------------------------------------------------------------

ConsoleWrite("Here 1" & @CRLF)

SubscriberNameWindow()

;-----------------------------------------------------------------------------------------------------

Func SubscriberNameWindow()

    Local $msg6
    Local $SubscriberNameWindow1, $SubscriberNameWindow2, $OkButton
    Local $TotalSubscribers, $SubscriberNameInput, $SubscriberName

;Opt("GUIOnEventMode",0)

    Do                                                ;a loop condition which remains continue until the expression below is true.

        $TotalSubscribers = $TotalSubscribers + 1
    Until $TotalSubscribers = $SubscriberToPublisherWindowButton

    For $TotalSubscribers = $SubscriberToPublisherWindowButton To 1 step -1

            GUICreate("Please Provide Name", 245, 130)
            gUICtrlCreateLabel("Please enter the name of Subscriber", 20, 10)
            $SubscriberNameInput = GUICtrlCreateInput("", 85, 60, 80, 0)
            $OkButton = GUICtrlCreateButton("OK", 96, 90, 60)
            GUISetState()

        While 1

            $msg6 = GUIGetMsg()

                Select

                    Case $msg6 = $OkButton
                        $SubscriberName1 = GUICtrlRead($SubscriberNameInput)
                        ExitLoop

                    Case $msg6 = $GUI_EVENT_CLOSE
                        Exitloop

                EndSelect

        WEnd

        GUIDelete()
        WinWaitClose("Please Provide Name")
      ;Opt("GUIOnEventMode",1)

    Next

EndFunc

ConsoleWrite("Here 2" & @CRLF)

I can add as many names as I want and get to the final "Here 2"

M23

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

HELLO all

pls help me. now i am calling above function from an another page. the name of this page is included in that page (#include "SubscriberToPublisherwindow.au3") but when script runs, it strucks at 'Enter the No. of subscribers window' (First Window).

for testing when i am calling these function from another page, they work perfectly and both the window appear according to the scripts. pls help.

Edited by randeep

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

not able to call the functions SubscribersToPublisherWindow(), SubscriberNameWindow() from the below function.

#include "SubscriberToPublisherwindow.au3"
#cs ----------------------------------------------------------------------------

 Function Name: RunPublicationScript()
 Author:         Randeep Singh

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------



Func RunPublicationScript()
Local $RetValue = True
local $LocalOutput
    Run ('osql -S ' & $PublisherHostName & ' -E -i "C:\T-MATRIX\replication scripts\Create Publisher1.sql"')
        IF @error <> 0 Then
            MsgBox(1, "Error", "An Error has occured while running the script - 'Create Publisher1.sql'")
            Return $RetValue = False
        EndIf

    Sleep(20000)
    
    $LocalOutput = MsgBox(4, "Attention", "Do you want to add Subscribers to the Publisher?")
        if $LocalOutput = 6 Then
            SubscribersToPublisherWindow()
            SubscriberNameWindow()
        endif
        
    sleep(15000)
    
    Run ('osql -S ' & $PublisherHostName & ' -E -i "C:\T-MATRIX\replication scripts\Create Publisher2.sql"')
        IF @error <> 0 Then
            MsgBox(1, "Error", "An Error has occured while running the script - 'Create Publisher2.sql'")
            Return $RetValue = False
        EndIf

    
;Return $RetValue

EndFunc
Edited by randeep

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

  • Moderators

randeep,

You have an individual way of laying out your code, mixing functions, declarations and main script. Although the way you have laid out your code is not "wrong", it does make it harder to follow and can lead to some problems. Could I suggest reordering your code like this:

All #includes
All Global declarations
Main script
Functions

This way you make sure all the various elements (and especially the include files) are available to your code when it runs.

Give that a try and see if it helps.

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

hello melba

thanks for replying. actually i am at begginners level. i am declaring all the 'Global' values on a different page (Variable Declaration.au3) and 'include' this page with all the other pages (actually i am writing different functions on different pages). this gives a warning on the main page (from where all the scripts run and all the pages are included) with i click SyntexCheck Prod Ctrl+F5 it shows warning that #include Variable Declarations is already exist (which is actually coming from another pages). 'But' if i remove 'Variable Declaration' from all pages except Main window (which includes all the pages and 'Variable Declaration'). it shows error 'Variable Used without being declared'. but scripts run from the main window. Pls check if i am wrong.

Randeep

randeep,

You have an individual way of laying out your code, mixing functions, declarations and main script. Although the way you have laid out your code is not "wrong", it does make it harder to follow and can lead to some problems. Could I suggest reordering your code like this:

All #includes
All Global declarations
Main script
Functions

This way you make sure all the various elements (and especially the include files) are available to your code when it runs.

Give that a try and see if it helps.

M23

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

  • Moderators

randeep,

I said you had a individual coding style, but I did not think it was that weird! Little wonder you are getting all these "undeclared" errors - I am pretty sure that you are getting things in the wrong order by using separate scripts for each function! I strongly suggest that you put your code into a single script, arranged as I suggested earlier.

All #includes
All Global declarations
Main script
Functions

At least then you stand a fighting chance of AutoIt finding what it wants when it needs it. :-)

If you are still having problems, put all your "pages" into a zip file and upload it so that I can have a a go at combining it for you.

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

hello melba

this is my script. if i write these scripts on a single page then it becomes tooo lengthy and i get puzzled smile.gif . pls check the functions SubscribersToPublisherWindow() & SubscriberNameWindow() which are called from 'Publisher.au3'. 'Site Utility.au3' is the main window from where all the functions works.

kindly see

thanx

randeep

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

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