Sign in to follow this  
Followers 0
Scottswan

CD Autorun Selector

8 posts in this topic

#1 ·  Posted (edited)

Hi ya!

I found this script on this board somewhere (by searching) and decided to use it for my little project.

I have just about everything tweaked and working fine for my application except I can't figure out how to Exit the script after the last application has closed. Also, there is a huge delay between running the first install and the second if both are picked. By huge I mean about 10 - 15 seconds.

#include <GUIConstants.au3>
Opt("Trayicondebug",1)
Opt("RunErrorsFatal",0); so the script won't stop if one of the install progs is missing
GUICreate("WinShear32", 450, 200);450, 200, 310, 190 icon won't show with the 310 & 190 for some reason
GUISetIcon("WinShear32.ico")
GUICtrlCreateLabel("WinShear32 Install Options ", 130, 20)
Local $opt[8][2]
$opt[0][0]  = GUICtrlCreateCheckbox("Install WinShear32 version 1.0.5 (new users install this first)", 20, 50)
    $opt[0][1]  = "setup.exe"
    GUICtrlSetState(Default, $GUI_CHECKED)
$opt[1][0]  = GUICtrlCreateCheckbox("Install WinShear32 version 1.0.6 update (only if WinShear32 is already installed)", 20, 70)
    $opt[1][1]  = "WinShear32_SP6.exe"
    GUICtrlSetState(Default, $GUI_CHECKED)
    GUICtrlCreateLabel ("Note: There may be a delay between the 1.0.5 and 1.0.6 installers",  50, 120)

$exit = GUICtrlCreateButton("Exit", 150, 170, 60)
$option = GUICtrlCreateButton("Install", 250, 170, 60)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $exit  Then;Also need to Exit after the last process closes...
            Exit
        Elseif $msg = $option Then
          Install($opt)
      EndIf
      sleep(2)
WEnd

 Func Install($aOpt)
  GUISetState(@SW_MINIMIZE)
     For $x = 0 to UBound($aOpt,1)-1
        If GuiCtrlRead($aOpt[$x][0]) = 1 Then
           If $aOpt[$x][1] <> "" Then
                Run($aOpt[$x][1])
                ProcessWaitClose($aOpt[$x][1])
                Else
                MsgBox(0, "", "opt "&$x+1&" is checked",30);What is the condition to prompt this?
            EndIf
        EndIf
    Next
EndFunc

The Func at the bottom is way over my head, and I think that is why I can't figure out how to Exit.

I don't think the installs are what is causing the delay, but I may be wrong. The first one is a msi and the second is a light-weight Spoon Installer, both open quickly if run separately.

Any tips much appreciated!

-Scott

Edited by Scottswan

Share this post


Link to post
Share on other sites



Well this didn't work...

Func Install($aOpt)
  GUISetState(@SW_MINIMIZE)
     For $x = 0 to UBound($aOpt,1)-1
        If GuiCtrlRead($aOpt[$x][0]) = 1 Then
           If $aOpt[$x][1] <> "" Then
                Run($aOpt[$x][1])
                ProcessWaitClose($aOpt[$x][1])
               ;    If ProcessWaitClose($aOpt[0]) Then
                ;       Exit
            ;   EndIF
                Else
                MsgBox(0, "", "opt "&$x+1&" is checked",30)
            EndIf
        EndIf
    Next
EndFunc

I'm stumped. :)

Share this post


Link to post
Share on other sites

Elseif $msg = $option Then

Install($opt)

Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Elseif $msg = $option Then

Install($opt)

Exit

8)

The problem was that it was too easy, I'm better with the hard stuff. :)

While 1 
    $msg = GUIGetMsg()
    If $msg = $exit  Then
            Exit
        Elseif $msg = $option Then
          Install($opt)
          Sleep(20)
        Exit ;Exit after the last process starts
      EndIf
WEnd

Needed a little delay so the second install doesn't loose focus.

Thanks, that was killing me!

Edit: That msi is causing the delay, not the script. It has hang time while it's shutting down or something.

I'm moving everything over to NSIS soon anyway, this is just a bandaid so people aren't confused trying to find the patch.

Edited by Scottswan

Share this post


Link to post
Share on other sites

One more tiny thing that I'm stuck on. How can I hide a GUICtrlCreateLabel depending on which selection is made?

#include <GUIConstants.au3>

GUICreate("WinShear32", 450, 200)
GUISetIcon("WinShear32.ico")
GUISetFont(14,600)
GUICtrlCreateLabel("WinShear32 Install Options ", 100, 10)
GUISetFont(9,400)
Local $opt[2][2]
$opt[0][0]  = GUICtrlCreateRadio("Install WinShear32 and the latest update  ", 20, 50)
    $opt[0][1]  = "setup.exe"
    GUICtrlSetState(Default, $GUI_CHECKED)
$opt[1][0]  = GUICtrlCreateRadio("Install WinShear32 version 1.0.6 update only (if WinShear32 is already installed)  ", 20, 70)
    $opt[1][1]  = "WinShear32_SP6.exe"
GUICtrlCreateLabel ("Note: There may be a delay between the WinShear32 and 1.0.6 update installers",  30, 120) ;This one should hide if $opt[1][0] is picked
If GuiCtrlRead($opt[1][0]) = 1 Then ;This doesn't work...
GUICtrlSetState(-1,$GUI_DISABLE)
EndIf

$exit = GUICtrlCreateButton("Exit", 130, 170, 60)
$option = GUICtrlCreateButton("Install", 250, 170, 60)
GUISetState(@SW_SHOW)

While 1 
    $msg = GUIGetMsg()
    If $msg = $exit  Then
            Exit
        Elseif $msg = $option Then
          Install($opt)
          Sleep(60)
        Exit ;Exit after the last process starts
      EndIf
WEnd

 Func Install($opt)
  GUISetState(@SW_MINIMIZE)
        If GuiCtrlRead($opt[0][0]) = 1 Then
                Run($opt[0][1])
                If ProcessWaitClose($opt[0][1]) Then 
                    Run($opt[1][1])
                EndIf
        Else
                Run($opt[1][1])
        EndIf
EndFunc

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstants.au3>

GUICreate("WinShear32", 450, 200)
GUISetIcon("WinShear32.ico")
GUISetFont(14, 600)
GUICtrlCreateLabel("WinShear32 Install Options ", 100, 10)
GUISetFont(9, 400)
Local $opt[2][2]
$opt[0][0] = GUICtrlCreateRadio("Install WinShear32 and the latest update  ", 20, 50)
$opt[0][1] = "setup.exe"
GUICtrlSetState(Default, $GUI_CHECKED)
$opt[1][0] = GUICtrlCreateRadio("Install WinShear32 version 1.0.6 update only (if WinShear32 is already installed)  ", 20, 70)
$opt[1][1] = "WinShear32_SP6.exe"
$Label_2 = GUICtrlCreateLabel("Note: There may be a delay between the WinShear32 and 1.0.6 update installers", 30, 120)
$exit = GUICtrlCreateButton("Exit", 130, 170, 60)
$option = GUICtrlCreateButton("Install", 250, 170, 60)
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    If ControlCommand("WinShear32", "", $opt[1][0], "IsChecked") Then
        GUICtrlSetState($Label_2, $GUI_HIDE)
    Else
        GUICtrlSetState($Label_2, $GUI_SHOW)
    EndIf
WEnd

:)


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

Share this post


Link to post
Share on other sites

Excellent, thanks!

Here's what I ended up with, I added a little delay to reduce the flickering of that label some...

Also made both the button and GUI X exit, thanks for pointing that out too!

$Note = GUICtrlCreateLabel ("Note: There may be a delay between the WinShear32 and 1.0.6 update installers",  30, 120)
oÝ÷ Ù«­¢+Ø)]¡¥±Ä(ÀÌØí5ÍôU%Ñ5Í ¤(%ÀÌØí5ÍôÀÌØí½ÁÑ¥½¸Q¡¸(%¹Íѱ° ÀÌØí½ÁФ($$M±À ØÀ¤($%á¥Ðíá¥ÐÑÈÑ¡±ÍÐÁɽÍÌÍÑÉÑÌ)¹%)%ÀÌØí5ÍôÀÌØíU%}Y9Q}
1=MQ¡¸(%á¥Ð(%±Í%ÀÌØí5ÍôÀÌØíá¥ÐQ¡¸(%á¥Ð)¹%)%
½¹Ñɽ±
½µµ¹ ÅÕ½Ðí]¥¹M¡ÈÌÈÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí½ÁÑlÅulÁt°ÅÕ½Ðí%Í
¡­ÅÕ½Ðì¤Q¡¸(U%
ÑɱMÑMÑÑ ÀÌØí9½Ñ°ÀÌØíU%}!%¤(±Í(U%
ÑɱMÑMÑÑ ÀÌØí9½Ñ°ÀÌØíU%}M!=¤($%M±À ØÀ¤)¹%)]¹(

Share this post


Link to post
Share on other sites

Excellent, thanks!

You're welcome.

Here's what I ended up with, I added a little delay to reduce the flickering of that label some...

Surest way to do that is use GuiOnEventMode. A little bit more pain to code, but much better performance.

:)


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

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