Jump to content

how to link the menu with another .au3 files


Go to solution Solved by MHz,

Recommended Posts

hiii...i hav created a menu form...on click of one menu(REGISTER) i want another .au3 file to open...how do i do that? also on click of another menu(HOME) i want sum labels to be displayed in the empty section below the menu bar.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

GUICreate("Menu", 500, 500)

$home = GUICtrlCreateMenu("&HOME")
$register = GUICtrlCreateMenu("&REGISTER")
$admission = GUICtrlCreateMenu("&ADMISSION")

 GUISetState()

While 1
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $home
                GUICtrlCreateLabel("hello", 100, 360)
                
        
           
        EndSelect
            
                
WEnd
Link to post
Share on other sites

ShellExecute?

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Link to post
Share on other sites

Hi Pomen,

The menu is not such a good button to use though it does support menu items which you can add. Just create a menu item and give it the handle from the menu so it is attached to it. Then you can use the handle from the menu item to trigger the event in the loop.

This will run a au3 script named test2.au3

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
 
GUICreate("Menu", 500, 500)
 
$home = GUICtrlCreateMenu("&HOME")

; create a menu item for the script to run
$run = GUICtrlCreateMenuItem("&Run a script", $home)

$register = GUICtrlCreateMenu("&REGISTER")
$admission = GUICtrlCreateMenu("&ADMISSION")
 
GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $run
            ; add the name of the script into a variable
            $script = 'test2.au3'
            
            ; run the script
            Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $script & '"')
            
    EndSelect
WEnd

:)

Link to post
Share on other sites

Hi Pomen,

The menu is not such a good button to use though it does support menu items which you can add. Just create a menu item and give it the handle from the menu so it is attached to it. Then you can use the handle from the menu item to trigger the event in the loop.

This will run a au3 script named test2.au3

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
 
GUICreate("Menu", 500, 500)
 
$home = GUICtrlCreateMenu("&HOME")

; create a menu item for the script to run
$run = GUICtrlCreateMenuItem("&Run a script", $home)

$register = GUICtrlCreateMenu("&REGISTER")
$admission = GUICtrlCreateMenu("&ADMISSION")
 
GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $run
            ; add the name of the script into a variable
            $script = 'test2.au3'
            
            ; run the script
            Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $script & '"')
            
    EndSelect
WEnd

:)

i got that...but what if i want labels to be displayed within the menu page i.e. below the menu bar. den how do i do it?

Link to post
Share on other sites
  • Solution

Labels below the menu bar. Labels are quite easy to add.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
 
GUICreate("Menu", 500, 500)

; 5 labels created here
GUICtrlCreateLabel('label 1', 5, 0, 100)
GUICtrlCreateLabel('label 2', 105, 0, 100)
GUICtrlCreateLabel('label 3', 205, 0, 100)
GUICtrlCreateLabel('label 4', 305, 0, 100)
GUICtrlCreateLabel('label 5', 405, 0, 100)

$home = GUICtrlCreateMenu("&HOME")

; create a menu item for the script to run
$run = GUICtrlCreateMenuItem("&Run a script", $home)

$register = GUICtrlCreateMenu("&REGISTER")
$now = GUICtrlCreateMenuItem("&Now", $register)

$admission = GUICtrlCreateMenu("&ADMISSION")
$accept = GUICtrlCreateMenuItem("&Accept", $admission)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $run
            ; add the name of the script into a variable
            $script = 'test2.au3'
            
            ; run the script
            Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $script & '"')
            If @error Then MsgBox(0x30, 'Run a script', 'test2.au3 did not run')
            
        Case $msg = $now
            MsgBox(0, 'Now', 'Time to register')
            
        Case $msg = $accept
            MsgBox(0, 'Accept', 'I can register it now')
            
    EndSelect
WEnd

5 labels for you. :)

Link to post
Share on other sites

Labels below the menu bar. Labels are quite easy to add.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
 
GUICreate("Menu", 500, 500)

; 5 labels created here
GUICtrlCreateLabel('label 1', 5, 0, 100)
GUICtrlCreateLabel('label 2', 105, 0, 100)
GUICtrlCreateLabel('label 3', 205, 0, 100)
GUICtrlCreateLabel('label 4', 305, 0, 100)
GUICtrlCreateLabel('label 5', 405, 0, 100)

$home = GUICtrlCreateMenu("&HOME")

; create a menu item for the script to run
$run = GUICtrlCreateMenuItem("&Run a script", $home)

$register = GUICtrlCreateMenu("&REGISTER")
$now = GUICtrlCreateMenuItem("&Now", $register)

$admission = GUICtrlCreateMenu("&ADMISSION")
$accept = GUICtrlCreateMenuItem("&Accept", $admission)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $run
            ; add the name of the script into a variable
            $script = 'test2.au3'
            
            ; run the script
            Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $script & '"')
            If @error Then MsgBox(0x30, 'Run a script', 'test2.au3 did not run')
            
        Case $msg = $now
            MsgBox(0, 'Now', 'Time to register')
            
        Case $msg = $accept
            MsgBox(0, 'Accept', 'I can register it now')
            
    EndSelect
WEnd

5 labels for you. :)

thank u...:)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...