Jump to content

Script run in a loop


turbochugz
 Share

Recommended Posts

I have written a script with 3 buttons on it...  1 to call internet explorer and open up yahoo mail, 2nd button to open up word 3 to open up the my pictures folder. 

if the drive doesn't exits, the script seems to run in an endless loop?  any thoughts?

[snippet]

while 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
   Case $button1
   but1()
   case $button2
   but2()
   Case $button3
   but3()
 EndSwitch
WEnd

 

Link to comment
Share on other sites

ok I got ya.. I was thinking something was wrong on the gui part of because it launches all my functions without my clicking on any of the buttons.

 I cleaned it up and went down this route... but sometimes when the program launches without drive r: being present, (I assume) all the functions launch...

[snippet]

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 539, 309, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 96, 48, 337, 185)
$Button1 = GUICtrlCreateButton("Button1", 136, 80, 105, 33)
$Button2 = GUICtrlCreateButton("Button2", 136, 128, 105, 33)
$Button3 = GUICtrlCreateButton("Button3", 136, 176, 105, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
Dim $vbut1 = "C:Program Files (x86)AdobeAcrobat 9.0Acrobatacrobat.exe"
Dim $vbut2 = "C:\Program Files\Internet Explorer\iexplore.exe espn.com"
Dim $vbut3 = "explorer.exe /e, w:, C:\Windows\System32\"
#EndRegion ### END Koda GUI section ###

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
   Case $button1
   but1()
   case $button2
   but2()
   Case $button3
   but3()
 EndSwitch
WEnd

func but1()
run ($vbut1)

EndFunc

func but2()
RunWait($vbut2)  

EndFunc

func but3()
if FileExists("r:") Then
run ("explorer.exe /e, w:", "C:\Windows\System32\")
Else
   MsgBox(0, "Error","Directory not found.")
   endif
EndFunc

[end snippet]

I guess maybe there is a rule of thumb I am missing.

Link to comment
Share on other sites

turbochugz,

Please use code tags when posting code.

As Geir1983 pointed out your gui code is fine (see below).  If you are having a problem it is likely within one of your functions.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 539, 309, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 96, 48, 337, 185)
$Button1 = GUICtrlCreateButton("Button1", 136, 80, 105, 33)
$Button2 = GUICtrlCreateButton("Button2", 136, 128, 105, 33)
$Button3 = GUICtrlCreateButton("Button3", 136, 176, 105, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
Dim $vbut1 = "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\acrobat.exe"
Dim $vbut2 = "c:\Program Files\Internet Explorer\iexplore.exe espn.com"
Dim $vbut3 = "explorer.exe /e, w:, c:\windows\system32"
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            but1()
        Case $Button2
            but2()
        Case $Button3
            but3()
    EndSwitch
WEnd

Func but1()
    ConsoleWrite('Button 1 actioned' & @LF)
    ;Run($vbut1)
EndFunc   ;==>but1

Func but2()
    ConsoleWrite('Button 2 actioned' & @LF)
    ;RunWait($vbut2)
EndFunc   ;==>but2

Func but3()
    ConsoleWrite('Button 3 actioned' & @LF)
    ;~  If FileExists("r:") Then
    ;~      Run("explorer.exe /e, w:", "c:\windows\system32")
    ;~  Else
    ;~      MsgBox(0, "Error", "Directory not found.")
    ;~  EndIf
EndFunc   ;==>but3

but sometimes when the program launches without drive r: being present, (I assume) all the functions launch...

 

The functions cannot launch themselves.  If you are having a problem then we need more data (console log, reproducer, etc.)

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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