Jump to content

Recommended Posts

Posted

Hello,

i tried to write a little gui with some menu-points.

I need no Submenus, cause, i've only 3 oder 4 menus (like Open, Update, Exit, Info)

So...

$MenuItem1 = GUICtrlCreateMenu("x")

$MenuItem4 = GUICtrlCreateMenu("y")

$MenuItem3 = GUICtrlCreateMenu("z")

$MenuItem2 = GUICtrlCreateMenu("a")

Now i want to call a function, if someone click on menu "x" - i tried to call the function with GuiCtrlSetOnEvent($MenuItem1, "FUNCTION"), but, nothing happens...

why ? :lmao:

Attention! English noob ^^

Posted (edited)

You probably need to enable "GUIOnEventMode"! (remember to post GUI ?s in the v3 GUI (Graphical User Interface) section of the forum)

Hello,

i tried to write a little gui with some menu-points.

I need no Submenus, cause, i've only 3 oder 4 menus (like Open, Update, Exit, Info)

So...

$MenuItem1 = GUICtrlCreateMenu("x")

$MenuItem4 = GUICtrlCreateMenu("y")

$MenuItem3 = GUICtrlCreateMenu("z")

$MenuItem2 = GUICtrlCreateMenu("a")

Now i want to call a function, if someone click on menu "x" - i tried to call the function with GuiCtrlSetOnEvent($MenuItem1, "FUNCTION"), but, nothing happens...

why ? :lmao:

Edited by Sunaj
Posted (edited)

Maybe, u doesnt understand what i try to getting work...

Here's my "little" Script, it should help my by scanning files for virus...

#include <GUIConstants.au3>
#include <file.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)

#Region
$Form1 = GUICreate("Auto-Scanner", 461, 288, 245, 165)
$Group1 = GUICtrlCreateGroup("Offene Scans", 5, 0, 141, 231)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 10, 15, 130, 218)
$Group2 = GUICtrlCreateGroup("Viren-Definitionen", 150, 0, 306, 146)
$Label1 = GUICtrlCreateLabel("", 155, 15, 300, 120)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Update", 155, 165, 61, 21, 0)
$Button2 = GUICtrlCreateButton("Copy2Clipboard", 230, 165, 86, 21, 0)
$Group3 = GUICtrlCreateGroup("", 150, 150, 176, 46)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Refresh", 10, 235, 50, 20, 0)
$Button4 = GUICtrlCreateButton("Scan", 60, 235, 50, 20, 0)
$MenuItem1 = GUICtrlCreateMenu("Datei")
$MenuItem4 = GUICtrlCreateMenu("Scannen")
$MenuItem3 = GUICtrlCreateMenu("Viren-Update")
$MenuItem2 = GUICtrlCreateMenu("Info")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
GUICtrlSetOnEvent($Button1, "GETDEF")
GUICtrlSetOnEvent($Button2, "COPY2CLIPBOARD")
GUICtrlSetOnEvent($Button3, "GETDIRS")

; >>> Doesnt work - why  ? <<<<
GUICtrlSetOnEvent($MenuItem2, "ABOUT")

While 1
    Sleep(100)
WEnd

Func ABOUT()
    msgbox(0, "Info...", "This script is written by Bastian Müller")
EndFunc

Func GETDIRS()
    $open_tasks = _FileListToArray(@ScriptDir&"\open_scans\", "*.*", 2)
    
    For $i = 1 to $open_tasks[0]
        GUICtrlSetData($List1, $open_tasks[$i])
    Next
    
EndFunc

[...]

Func CLOSE()
    Exit
EndFunc

I know, that i can call functions on setting up events (like click on a button), but this method doesnt work if i click on a Menuitem (Toplevel, NO submenus).

Is that possibel? To use online toplevel menus without submenus ?

Edited by neo van matix

Attention! English noob ^^

Posted

This works for me but you might not want use it since it now is a menuitem

#include <GUIConstants.au3>
#include <file.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)

#Region
$Form1 = GUICreate("Auto-Scanner", 461, 288, 245, 165)
$Group1 = GUICtrlCreateGroup("Offene Scans", 5, 0, 141, 231)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 10, 15, 130, 218)
$Group2 = GUICtrlCreateGroup("Viren-Definitionen", 150, 0, 306, 146)
$Label1 = GUICtrlCreateLabel("", 155, 15, 300, 120)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Update", 155, 165, 61, 21, 0)
$Button2 = GUICtrlCreateButton("Copy2Clipboard", 230, 165, 86, 21, 0)
$Group3 = GUICtrlCreateGroup("", 150, 150, 176, 46)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Refresh", 10, 235, 50, 20, 0)
$Button4 = GUICtrlCreateButton("Scan", 60, 235, 50, 20, 0)
$start=GUICtrlCreateMenu("Funcs")
$MenuItem1 = GUICtrlCreateMenuitem("Datei",$start)
$MenuItem4 = GUICtrlCreateMenuitem("Scannen",$start)
$MenuItem3 = GUICtrlCreateMenuitem("Viren-Update",$start)
$MenuItem2 = GUICtrlCreateMenuitem("Info",$start)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
GUICtrlSetOnEvent($Button1, "GETDEF")
GUICtrlSetOnEvent($Button2, "COPY2CLIPBOARD")
GUICtrlSetOnEvent($MenuItem1,"ABOUT")
GUICtrlSetOnEvent($Button3, "GETDIRS")

; >>> Doesnt work - why  ? <<<<
GUICtrlSetOnEvent($MenuItem2, "ABOUT")

While 1
    Sleep(100)
WEnd

Func ABOUT()
    msgbox(0, "Info...", "This script is written by Bastian Müller")
EndFunc

Func GETDIRS()
    $open_tasks = _FileListToArray(@ScriptDir&"\open_scans\", "*.*", 2)
   
    For $i = 1 to $open_tasks[0]
        GUICtrlSetData($List1, $open_tasks[$i])
    Next
   
EndFunc

;[...]

Func CLOSE()
    Exit
EndFunc
My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

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
×
×
  • Create New...