Jump to content

Autoit Menu


Recommended Posts

Hi all

I am pretty new to AI and really like the utility. I have the following script which works but is in a pretty tight loop. I have gone through the help but could not find a way to create a AI script menu. Is this possible? Please advise.

Regards

Bhavbhuti

;Get the Project Code
If $CmdLine[0] = 1 then
    $ProjCode = $CmdLine[1]
Else
    While 1
  $ProjCode = InputBox ( 'AutoIt Menu', 'Please enter the project code (C04)' )
    
  If @error Then
    Exit
  EndIf
    
  
  $ProjCode = StringUpper( $ProjCode )
    
  
  If $ProjCode = '' Then
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartVFP.au3 ' & $ProjCode )
  Else
    ExitLoop
  EndIf
    WEnd
EndIf



While 1
;Get the Project Code
    $MenuOption = InputBox ( 'AutoIt Menu', 'Select an option for ' & $ProjCode & CHR(13) & CHR(13) &_
  '1: Start Project' & CHR(13) & _
  '2: Start Marathon' & CHR(13) & _
  '3: Compress Project' & CHR(13) & _
  '4: UnCompress Project' & CHR(13) & _
  '5: Create Marathon Script' & CHR(13) & _
  '6: Create Marathon Database' & CHR(13) & _
  '7: Open Report Manager' & CHR(13) & _
  '8: Open InnoSetup Tool' & CHR(13) & _
  '9: Open FDB DBComparer' & CHR(13) & _
  '10: Update FDB DBComparer' & CHR(13) _
    , "1", "", -1, 300)
    
    If @error Then
  ExitLoop
    EndIf

  
    Select
  Case $MenuOption = '1'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartProject.au3 ' & $ProjCode )
    
  Case $MenuOption = '2'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartMarathon.au3 ' & $ProjCode )
    
  Case $MenuOption = '3'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CompressProject.au3 ' & $ProjCode )
    
  Case $MenuOption = '4'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\UnCompressProject.au3 ' & $ProjCode )
    
  Case $MenuOption = '5'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CreateScriptMarathon.au3 ' & $ProjCode )
    
  Case $MenuOption = '6'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CreateDatabaseMarathon.au3 ' & $ProjCode )
    
  Case $MenuOption = '7'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartRM.au3 ' & $ProjCode )
    
  Case $MenuOption = '8'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartISTool.au3 ' & $ProjCode )
    
  Case $MenuOption = '9'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartDBComparer.au3 ' & $ProjCode )
    
  Case $MenuOption = '10'
    Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\UpdateFDBDBComparer.au3 ' & $ProjCode )
    EndSelect
WEnd
Edited by venussoftop

RegardsBhavbhuti

Link to comment
Share on other sites

I notice two things:

If $ProjCode = '' Then
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartVFP.au3 ' & $ProjCode )
 Else
  ExitLoop

I think you mean to call the Run(...) if $ProjCode <> '' so here's one way to rewrite it

If $ProjCode = '' Then Exit
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartVFP.au3 ' & $ProjCode

* The last While loop will never exit. One idea:

$MenuOption = 0
While Number($MenuOption) < 1 or Number($MenuOption) > 10
   $MenuOption = InputBox(......)
   If @error Then ExitLoop
WEnd

Adjust this psuedocode as needed. (You could also put ExitLoop after each Run in the Select-Case block. OR You could put an Else case that calls the ContinueLoop statement and put an ExitLoop between the EndSelect and WEnd.)

EDIT: let me give examples of those last two suggestions:

Select
Case $MenuOption = '1'
   Run(...)
   ExitLoop

Case $MenuOption = '2'
   Run(...)
   ExitLoop
...
 
Case $MenuOption = '10'
   Run(...)
   ExitLoop
EndSelect

the other one:

While 1
    Select
    Case $MenuOption = '1'
       Run(...)
       ExitLoop
   ...

    Case $MenuOption = '10'
       Run(...)
       ExitLoop
       
    Case Else
       ContinueLOop
    EndSelect
    
    ExitLoop
WEnd

Hope that helps

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Hi

Thanks a lot for such a quick reply.

Point 1. I want to call StartVFP.au3 if no project code is specified, but if a project code is supplied I want to move onto the menu.

Point 2. You have rightly noted that the 2nd loop never exits, that was the main reason to put in the post (though the task manager does not show any CPU hog when the InputBox() is executing)

Actually I have something of this pseudocode in mind but have not been able to convert it to actual script

InputBox()

Select
   Case...
...
EndSelect

GoTo InputBox

I always want the inputbox (loop 2) so I can switch to it and request another menu option while the first script is already running.

So in essence I select an option, the script for the option is put into motion, InputBox() reappears so I can select another option, which in turn is also put into motion, so on. I could not find a GoTo statement like in the old BASIC language or as in DOS batch files.

I know this seems to be a tall order from a utility though general purpose was not maybe meant for such a use.

Please advise.

RegardsBhavbhuti

Link to comment
Share on other sites

Hi, I use HTML AutoRun for menus. Here's the URL:

http://users.jabora.com/jaeden/software.aspx

You can use HTML to make a nice menu with graphics and even roll-over buttons. Point the links toward your AutoIt scripts or other exe files. Easy!

But maybe this solution is a bit too simple for what you are after? Anyway, hope it helps :-)

Michael

Michael
Link to comment
Share on other sites

Not sure if this is what you are looking for:

Do

Menu()

Until $return == 1

Func Menu()

$return = 1

$terminate = 0

$option=InputBox("Main Menu", "1) Menu item 1" & @CRLF & "_

2) Menu item 2" & @CRLF & "_

3) Menu item 3", "", "", 300, 275)

If @error = 1 then

Close()

$return = 0

elseif $option > 3 OR $option < 1 then

MsgBox(262144,"Error","You may only enter a number in the range of 1-3")

endif

Select

Case $option=1

Task 1()

Case $option=2

Task 2()

Case $option=3

Task 3()

EndSelect

If $return Then

Menu()

EndIf

EndFunc

Link to comment
Share on other sites

Hi, I use HTML AutoRun for menus. Here's the URL:

http://users.jabora.com/jaeden/software.aspx

You can use HTML to make a nice menu with graphics and even roll-over buttons. Point the links toward your AutoIt scripts or other exe files. Easy!

But maybe this solution is a bit too simple for what you are after? Anyway, hope it helps :-)

Michael

Hi Michael

Thanks for the link, in the same line here is another link that you might like and can do a lot more thing for CD autoruns.

http://installassistant.com/

Anyway I found out what I wanted, neede to rethink the logic, see post.

RegardsBhavbhuti

Link to comment
Share on other sites

Not sure if this is what you are looking for:

Do

          Menu()

Until $return == 1

Func Menu()

$return = 1

$terminate = 0

 

$option=InputBox("Main Menu", "1) Menu item 1" & @CRLF & "_

2) Menu item 2" & @CRLF & "_

3) Menu item 3", "", "", 300, 275)

If @error = 1 then

  Close()

  $return = 0

elseif $option > 3 OR $option < 1 then

  MsgBox(262144,"Error","You may only enter a number in the range of 1-3")

endif

Select

  Case $option=1

  Task 1()

  Case $option=2

  Task 2()

  Case $option=3

  Task 3()

EndSelect

If $return Then

  Menu()

EndIf

EndFunc

Hi

Thanks for the newer logic, but I wanted to avoid loop absolutely and the final result is as follows, it is simple but I was thinking complicated. Please note I have avoided all loops.

;Get the Project Code
If $CmdLine[0] = 1 then
    $ProjCode = $CmdLine[1]
Else
  $ProjCode = InputBox ( 'AutoIt Menu', 'Please enter the project code (C04)' )

  If @error Then
     Exit
  EndIf


  $ProjCode = StringUpper( $ProjCode )


  If $ProjCode = '' Then
     Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartVFP.au3 ' & $ProjCode )
     Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\AutoItMenu.au3' )

     Exit
  EndIf
EndIf



;Get the Project Code
$MenuOption = InputBox ( 'AutoIt Menu', 'Select an option for ' & $ProjCode & CHR(13) & CHR(13) &_
    '1: Start Project' & CHR(13) & _
    '2: Start Marathon' & CHR(13) & _
    '3: Compress Project' & CHR(13) & _
    '4: UnCompress Project' & CHR(13) & _
    '5: Create Marathon Script' & CHR(13) & _
    '6: Create Marathon Database' & CHR(13) & _
    '7: Open Report Manager' & CHR(13) & _
    '8: Open InnoSetup Tool' & CHR(13) & _
    '9: Open FDB DBComparer' & CHR(13) & _
    '10: Update FDB DBComparer' & CHR(13) _
, "1", "", -1, 300)

If @error Then
    Exit
EndIf


Select
    Case $MenuOption = '1'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartProject.au3 ' & $ProjCode )

    Case $MenuOption = '2'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartMarathon.au3 ' & $ProjCode )

    Case $MenuOption = '3'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CompressProject.au3 ' & $ProjCode )

    Case $MenuOption = '4'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\UnCompressProject.au3 ' & $ProjCode )

    Case $MenuOption = '5'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CreateScriptMarathon.au3 ' & $ProjCode )

    Case $MenuOption = '6'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\CreateDatabaseMarathon.au3 ' & $ProjCode )

    Case $MenuOption = '7'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartRM.au3 ' & $ProjCode )

    Case $MenuOption = '8'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartISTool.au3 ' & $ProjCode )

    Case $MenuOption = '9'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\StartDBComparer.au3 ' & $ProjCode )

    Case $MenuOption = '10'
  Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\UpdateFDBDBComparer.au3 ' & $ProjCode )
EndSelect


Run( 'C:\Program Files\AutoIt3\AutoIt3.exe C:\AutoIt\AutoItMenu.au3 ' & $ProjCode )

Exit

RegardsBhavbhuti

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