Sign in to follow this  
Followers 0
GreenHouse

GUI won't close after calling a function or allow same function to be re-called...

7 posts in this topic

#include <GUIConstants.au3>
#include "CopyDirWithProgress.au3"
;#include "SP_Install.au3"
#include "WINXP.au3"
#include "WIN2003.au3"
#include "WIN2000.au3"
;#include "VISTA.au3"

Opt("GUIOnEventMode", 1)

Global $Form1 = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 522, 434, 235, 153)
GUISetIcon("C:\Documents and Settings\pwolters\Desktop\100.ico")
GUISetFont(8, 400, 0, "Arial")
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWindow")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MinimizeWindow")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MaximizeWindow")
GUISetOnEvent($GUI_EVENT_RESTORE, "RestoreWindow")
Global $Group1 = GUICtrlCreateGroup(" SQL Backup ", 0, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label1 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart database:", 16, 24, 232, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel1Click")
Global $Button1 = GUICtrlCreateButton("Start", 88, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup(" TouchChart Backup ", 0, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label2 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart folder:", 16, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel2Click")
Global $Button2 = GUICtrlCreateButton("Start", 88, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup(" Download Service Pack ", 264, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label3 = GUICtrlCreateLabel("Click start to download the service pack upgrade:", 280, 24, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel3Click")
Global $Button3 = GUICtrlCreateButton("Start", 352, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton3Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup(" Run Service Pack Upgrade ", 264, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label4 = GUICtrlCreateLabel("Click start to run the service pack upgrade (No user input required):", 280, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel4Click")
Global $Button4 = GUICtrlCreateButton("Start", 352, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton4Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$CloseDialog = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 350,80 )
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWindow")
    GUISetIcon("Allscripts.ico")
    GUISetFont(8, 400, 0, "Arial")
    $OkButton1 = GUICtrlCreateButton("OK", 133, 40, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "OkButton1")
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    $EndText1 = GUICtrlCreateLabel("Service pack has already been downloaded.", 82, 10, 232, 36)
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUISwitch($Form1)
GUISetState(@SW_SHOW)


While 1
        Sleep(1000)
WEnd

Func AButton1Click()

EndFunc

                
Func AButton2Click()

EndFunc

                
Func AButton3Click()

;find out the O/S Version and act accordingly

$OSVersion = @OSVersion
ClipPut($OSVersion)


If $OSVersion = "WIN_VISTA" Then
MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program")
Exit
;   _VISTA ()
EndIf



If $OSVersion = "WIN_2000" Then
    _WIN2000 ()
EndIf



If $OSVersion = "WIN_XP" Then
    _WINXP ()
EndIf



If $OSVersion = "WIN_2003" Then
    WIN2003 ()
EndIf

EndFunc

                
Func AButton4Click()

EndFunc

                
Func CloseWindow()
  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
  ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $Form1 Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    GUIDelete($CloseDialog)
Else 
    Exit
  EndIf 
EndFunc

                
Func MinimizeWindow()

EndFunc

                
Func MaximizeWindow()

EndFunc

                
Func RestoreWindow()

EndFunc

                
Func ALabel1Click()

EndFunc

                
Func ALabel2Click()

EndFunc

                
Func ALabel3Click()

EndFunc

                
Func ALabel4Click()

EndFunc

Func OkButton1()
    
EndFunc

Func WIN2003()
    
    ;Create a GUI with Allscripts icon to signal download has already been completed:
If FileExists("ImpactMD 3.31 Service Pack 38 Install.exe") Then
    GUISwitch($CloseDialog)
    GUISetState(@SW_SHOW)
    
    While 1
        Sleep(1000)
    WEnd
    
    If @GUI_WINHANDLE = $CloseDialog Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    GUIDelete($CloseDialog)
    EndIf
EndIf
EndFunc

The problem I am having with this is that after I call the function Start3Button() which in turn calls _WIN2003() my $mainwindow GUI does not close! also it doesn't allow me to call the function Start3Button() again (Nothing happens when I click on the button or try to close the GUI).

I am using OnEventMode.

What am I doing wrong?

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include "CopyDirWithProgress.au3"
;#include "SP_Install.au3"
#include "WINXP.au3"
#include "WIN2003.au3"
#include "WIN2000.au3"
;#include "VISTA.au3"

Opt("GUIOnEventMode", 1)

Global $Form1 = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 522, 434, 235, 153)
GUISetIcon("C:\Documents and Settings\pwolters\Desktop\100.ico")
GUISetFont(8, 400, 0, "Arial")
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWindow")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MinimizeWindow")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MaximizeWindow")
GUISetOnEvent($GUI_EVENT_RESTORE, "RestoreWindow")
Global $Group1 = GUICtrlCreateGroup(" SQL Backup ", 0, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label1 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart database:", 16, 24, 232, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel1Click")
Global $Button1 = GUICtrlCreateButton("Start", 88, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup(" TouchChart Backup ", 0, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label2 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart folder:", 16, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel2Click")
Global $Button2 = GUICtrlCreateButton("Start", 88, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup(" Download Service Pack ", 264, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label3 = GUICtrlCreateLabel("Click start to download the service pack upgrade:", 280, 24, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel3Click")
Global $Button3 = GUICtrlCreateButton("Start", 352, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton3Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup(" Run Service Pack Upgrade ", 264, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label4 = GUICtrlCreateLabel("Click start to run the service pack upgrade (No user input required):", 280, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "ALabel4Click")
Global $Button4 = GUICtrlCreateButton("Start", 352, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "AButton4Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$CloseDialog = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 350,80 )
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWindow")
    GUISetIcon("Allscripts.ico")
    GUISetFont(8, 400, 0, "Arial")
    $OkButton1 = GUICtrlCreateButton("OK", 133, 40, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "OkButton1")
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    $EndText1 = GUICtrlCreateLabel("Service pack has already been downloaded.", 82, 10, 232, 36)
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUISwitch($Form1)
GUISetState(@SW_SHOW)
While 1
        Sleep(1000)
WEnd

Func AButton1Click()

EndFunc

                
Func AButton2Click()

EndFunc

                
Func AButton3Click()

;find out the O/S Version and act accordingly

$OSVersion = @OSVersion
ClipPut($OSVersion)
If $OSVersion = "WIN_VISTA" Then
MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program")
Exit
;   _VISTA ()
EndIf
If $OSVersion = "WIN_2000" Then
    _WIN2000 ()
EndIf
If $OSVersion = "WIN_XP" Then
    _WINXP ()
EndIf
If $OSVersion = "WIN_2003" Then
    WIN2003 ()
EndIf

EndFunc

                
Func AButton4Click()

EndFunc

                
Func CloseWindow()
  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
  ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $Form1 Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    GUIDelete($CloseDialog)
Else 
    Exit
  EndIf 
EndFunc

                
Func MinimizeWindow()

EndFunc

                
Func MaximizeWindow()

EndFunc

                
Func RestoreWindow()

EndFunc

                
Func ALabel1Click()

EndFunc

                
Func ALabel2Click()

EndFunc

                
Func ALabel3Click()

EndFunc

                
Func ALabel4Click()

EndFunc

Func OkButton1()
    
EndFunc

Func WIN2003()
    
    ;Create a GUI with Allscripts icon to signal download has already been completed:
If FileExists("ImpactMD 3.31 Service Pack 38 Install.exe") Then
    GUISwitch($CloseDialog)
    GUISetState(@SW_SHOW)
    
    While 1
        Sleep(1000)
    WEnd
    
    If @GUI_WINHANDLE = $CloseDialog Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    GUIDelete($CloseDialog)
    EndIf
EndIf
EndFunc

The problem I am having with this is that after I call the function Start3Button() which in turn calls _WIN2003() my $mainwindow GUI does not close! also it doesn't allow me to call the function Start3Button() again (Nothing happens when I click on the button or try to close the GUI).

I am using OnEventMode.

What am I doing wrong?

I think you need to add GuiSwitch($Form1) after deleting $CloseDialog.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include "WINXP.au3"
#include "WIN2003.au3"
#include "WIN2000.au3"

Opt("GUIOnEventMode", 1)

Global $mainwindow = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 522, 434, 235, 153)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetIcon("Allscripts.ico")
GUISetFont(8, 400, 0, "Arial")
Global $Group1 = GUICtrlCreateGroup(" SQL Backup ", 0, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label1 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart database:", 16, 24, 232, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel1Click")
Global $Button1 = GUICtrlCreateButton("Start", 88, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup(" TouchChart Backup ", 0, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label2 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart folder:", 16, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel2Click")
Global $Button2 = GUICtrlCreateButton("Start", 88, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup(" Download Service Pack ", 264, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label3 = GUICtrlCreateLabel("Click start to download the service pack upgrade:", 280, 24, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel3Click")
Global $Button3 = GUICtrlCreateButton("Start", 352, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "Start3Button")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup(" Run Service Pack Upgrade ", 264, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label4 = GUICtrlCreateLabel("Click start to run the service pack upgrade (No user input required):", 280, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel4Click")
Global $Button4 = GUICtrlCreateButton("Start", 352, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton4Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$CloseDialog = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 350,80 )
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetIcon("Allscripts.ico")
GUISetFont(8, 400, 0, "Arial")
$OkButton = GUICtrlCreateButton("OK", 133, 40, 75, 25, 0)
GUICtrlSetOnEvent(-1, "CDOkButton")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$EndTextCD = GUICtrlCreateLabel("Service pack has already been downloaded.", 82, 10, 232, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)


While 1
  Sleep(1000)  ; Idle around
WEnd

Func Start3Button()
  ;Note: at this point @GUI_CTRLID would equal $okbutton
  If FileExists("ImpactMD 3.31 Service Pack 38 Install.exe") Then
  GUISwitch($CloseDialog)
  GUISetState(@SW_SHOW)
Else
;find out the O/S Version and act accordingly

$OSVersion = @OSVersion
ClipPut($OSVersion)


If $OSVersion = "WIN_VISTA" Then
MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program")
Exit
;   _VISTA ()
EndIf



If $OSVersion = "WIN_2000" Then
    _WIN2000 ()
EndIf



If $OSVersion = "WIN_XP" Then
    _WINXP ()
EndIf



If $OSVersion = "WIN_2003" Then
    _WIN2003 ()
EndIf

EndIf
EndFunc

Func SpecialEvents()
    
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit
            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
            
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
            
    EndSelect
    
EndFunc

func CDOkButton()
     If @GUI_WINHANDLE = $CloseDialog Then 
    GUIDelete($CloseDialog)
    GUISwitch($mainwindow)
    Else 
    Exit
  EndIf 
Endfunc

I think you need to add GuiSwitch($Form1) after deleting $CloseDialog.

I'm sorry I posted the wrong code...

Share this post


Link to post
Share on other sites

Hi,

Since your using Opt("GUIOnEventMode", 1) and your setting a unique function to each control regardless of which window is active I can't really see why your using GUISwitch.

If you notice in the Help file example for GUISwith that it's using do loops with $msg=GUIGetMsg() to catch what messages that are sent by a control from the related gui.

In your code your not using or needing $msg=GUIGetMsg() as each control when clicked will fire the correct unique function no matter which window is showing.

I also notice your not using GuiSetState() on your first $mainwindow gui.

For each GUICreate() there should be a closing GuiSetState() to set the state of a gui

So instead of trying to use GUISwitch to show the correct gui, use GuiSetState().

Also it's hard to tell what your script is hanging from when we don't have the #include "WINXP.au3", #include "WIN2003.au3" or #include "WIN2000.au3" or at least where to get them from.

Here's the changes to rectify your gui show N hide issues applied below:

#include <GUIConstants.au3>
#include "WINXP.au3"
#include "WIN2003.au3"
#include "WIN2000.au3"

Opt("GUIOnEventMode", 1)

Global $mainwindow = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 522, 434, 235, 153)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetIcon("Allscripts.ico")
GUISetFont(8, 400, 0, "Arial")
Global $Group1 = GUICtrlCreateGroup(" SQL Backup ", 0, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label1 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart database:", 16, 24, 232, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel1Click")
Global $Button1 = GUICtrlCreateButton("Start", 88, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton1Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup(" TouchChart Backup ", 0, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label2 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart folder:", 16, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel2Click")
Global $Button2 = GUICtrlCreateButton("Start", 88, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup(" Download Service Pack ", 264, 0, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label3 = GUICtrlCreateLabel("Click start to download the service pack upgrade:", 280, 24, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel3Click")
Global $Button3 = GUICtrlCreateButton("Start", 352, 144, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "Start3Button")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup(" Run Service Pack Upgrade ", 264, 216, 257, 217)
GUICtrlSetFont(-1, 8, 800, 2, "Arial")
Global $Label4 = GUICtrlCreateLabel("Click start to run the service pack upgrade (No user input required):", 280, 240, 224, 36)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "ALabel4Click")
Global $Button4 = GUICtrlCreateButton("Start", 352, 360, 75, 25, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
;GUICtrlSetOnEvent(-1, "AButton4Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $mainwindow)

$CloseDialog = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 350,80, -1, -1, $WS_CAPTION)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetIcon("Allscripts.ico")
GUISetFont(8, 400, 0, "Arial")
$OkButton = GUICtrlCreateButton("OK", 133, 40, 75, 25, 0)
GUICtrlSetOnEvent(-1, "CDOkButton")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$EndTextCD = GUICtrlCreateLabel("Service pack has already been downloaded.", 82, 10, 232, 20)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUISetState(@SW_HIDE, $CloseDialog)


While 1
  Sleep(1000)  ; Idle around
WEnd

Func Start3Button()
  ;Note: at this point @GUI_CTRLID would equal $okbutton
    If FileExists("ImpactMD 3.31 Service Pack 38 Install.exe") = 0 Then
        GUISetState(@SW_SHOW, $CloseDialog)
        GUISetState(@SW_HIDE, $mainwindow)
    Else
        ;find out the O/S Version and act accordingly

        $OSVersion = @OSVersion
        ClipPut($OSVersion)

        If $OSVersion = "WIN_VISTA" Then
            MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program")
            Exit
        ;   _VISTA ()
        EndIf

        If $OSVersion = "WIN_2000" Then
            _WIN2000 ()
        EndIf

        If $OSVersion = "WIN_XP" Then
            _WINXP ()
        EndIf

        If $OSVersion = "WIN_2003" Then
            _WIN2003 ()
        EndIf

    EndIf
EndFunc

Func SpecialEvents()
   
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit
           
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
           
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
           
    EndSelect
   
EndFunc

func CDOkButton()
    GuiSetState(@SW_HIDE, $CloseDialog)
    GuiSetState(@SW_SHOW, $mainwindow)
Endfunc

Cheers

Share this post


Link to post
Share on other sites

Hi,

Since your using Opt("GUIOnEventMode", 1) and your setting a unique function to each control regardless of which window is active I can't really see why your using GUISwitch.

If you notice in the Help file example for GUISwith that it's using do loops with $msg=GUIGetMsg() to catch what messages that are sent by a control from the related gui.

In your code your not using or needing $msg=GUIGetMsg() as each control when clicked will fire the correct unique function no matter which window is showing.

I also notice your not using GuiSetState() on your first $mainwindow gui.

For each GUICreate() there should be a closing GuiSetState() to set the state of a gui

So instead of trying to use GUISwitch to show the correct gui, use GuiSetState().

Also it's hard to tell what your script is hanging from when we don't have the #include "WINXP.au3", #include "WIN2003.au3" or #include "WIN2000.au3" or at least where to get them from.

That works great smashly thanks a bunch I understand the difference between on event and thight looping a tiny little bit better now. I am including the code for WIN2003.au3 this is almost the same for WINXP.au3 and WIN200.au3. I had to remove the ftp site user and pass because it is a company website. But the thing is that after you push the Start button for sownloading the service pack, the only thing you can do to the original GUI is minimize. Close wont work and hitting the Start button again will not start the function again. It just sits there.

Thanks for your help, I know these newbie questions are boring to the advanced scripter... :)

Func _WIN2003 ()

; Run Explorer:
ShellExecute("iexplore.exe", "ftp:// REMOVED THIS SENSITIVE COMPANY INFO")

;Select Save File from the Security Warning Prompt:
WinWaitActive("File Download")
Send("{ALTDOWN}s{ALTUP}")
WinWait("Save As", "Save as &type:")

;Save to destop and minimize window:
WinWaitActive("Save As", "Save &in:")
ControlSend("Save As", "Save &in:", "Combobox1", @DesktopDir)
Send("{ALTDOWN}s{ALTUP}")

WinWaitActive("ImpactMD", "Download to:")
WinSetState("ImpactMD", "Download to:", @SW_ENABLE)
WinSetState("ImpactMD", "Download to:", @SW_MINIMIZE)

;Pauses script until the download window is closed:
WinWaitClose("ImpactMD", "Download to:")

EndFunc

Share this post


Link to post
Share on other sites

Hi,

Maybe you should look at InetGet() function to get your file from the ftp..

This way your not waiting on dialog boxes to show and disappear.

I'm not definite but I think your _WIN2003() function needs some sort of timeout and error checking.

To me it seems like if there is a window/dialog not being active then your stuck in that function till the window is active..

If the window never shows then you never leave the function.

Hence the main Gui not responding.

InetGet() function offers to do background download of a file (only 1 download can be active at a time) therefore letting you to return from the function so other things in your gui can be used while it's downloading.

Also your not waiting on windows dialog prompt boxes to show and send keys just to get the download started.

For more info on InetGet() function have a look in the AutoIt Help file under

Function Reference -> Network Functions -> InetGet

Cheers

Share this post


Link to post
Share on other sites

smashly, I just wanted to say thanks for taking the time to answer my questions and help educating me in the ways of the AutoItz... I really appreciate it greatly.

Keep up the good work mate!

:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0