Jump to content

Popup Menu UDF


Mat
 Share

Recommended Posts

Again, nice updates. I think I might handle the new OnShow option a little differently, so that it supports both global and menu specific OnShow functions.

change the __PopUpMenuStart() function:

Func __PopupMenuStart()
    Local $x = __PopUpMenuGetIndexFromHotkey(@HotKeyPressed)
    If $x = -1 Then Return SetError(1, 0, 0)
    Local $temp, $sTemp
    ; global OnShow function
    If $POPUP_MENU_ONSHOW[0] <> "" Then
        If Not StringInStr($POPUP_MENU_ONSHOW[0], $POPUP_MENU_DATASEPERATOR) Then
            Call($POPUP_MENU_ONSHOW[0])
        Else
            $temp = StringSplit($POPUP_MENU_ONSHOW[0], $POPUP_MENU_DATASEPERATOR)
            $sTemp = $temp[1]
            $temp = __ArrayDelete($temp, 1)
            $temp[0] = "CallArgArray"
            Call($sTemp, $temp)
        EndIf
    EndIf
    ; menu specific OnShow function
    If $POPUP_MENU_ONSHOW[$x] <> "" Then
        If Not StringInStr($POPUP_MENU_ONSHOW[$x], $POPUP_MENU_DATASEPERATOR) Then
            Call($POPUP_MENU_ONSHOW[0])
        Else
            $temp = StringSplit($POPUP_MENU_ONSHOW[$x], $POPUP_MENU_DATASEPERATOR)
            $sTemp = $temp[1]
            $temp = __ArrayDelete($temp, 1)
            $temp[0] = "CallArgArray"
            Call($sTemp, $temp)
        EndIf
    EndIf
    DllCall("user32.dll", "int", "SetForegroundWindow", "hwnd", $POPUP_MENU_INFO[0][1])
    DllCall("user32.dll", "ptr", "SendMessage", _
            "hwnd", ControlGetHandle($POPUP_MENU_INFO[0][1], _
            "", $POPUP_MENU_INFO[$x][1]), _
            "int", 0x007B, _
            "int", $POPUP_MENU_INFO[$x][1], _
            "int", 0)
EndFunc   ;==>__PopupMenuStart

Gives the user more flexibility.

Edited by wraithdu
Link to comment
Share on other sites

If You run example 2 and click Alt-4, what happens? It should bring up a context menu at the mouse position. If you click something it will bring up a msgbox. If the menu is not appearing then I don't have a clue how to solve it, as its probably a problem with the message i'm sending to trigger the menu... But thats got to be right... doesn't it?

Mat

edit: AH!! I was going to run both global and menu onshows, but it seems the keyboard is twisting my input and putting an ElseIf in there! :D It shall be done! Thanks Wraithdu!

Edited by Mat
Link to comment
Share on other sites

:D I was thinking that before I put on the second update, but decided against it for some obscure reason (probably too much work to edit one line every time I do an update :D )

I have almost finished the second example, which is actually a very useful script for setting windows on top status through a small menu. It uses the OnShow option to update the menu, and is a good example of using OnEvent mode with a parameter.

Mat

Link to comment
Share on other sites

Grrr... Try running this script, it might show where the problem is...

#include "PopUpMenu.au3"

_PopUpMenuSetOption ("OnEventMode", 1)

$hMenu2 = _PopUpMenuCreate ("!5")
$hExit2 = _PopUpMenuCreateMenuItem ("Exit", $hMenu2)
_PopUpMenuItemSetOnEvent (-1, "MyFunc", "You Sent|Exit. Goodbye!")

_Custom_Starter_Test ()

While 1
   Sleep (5000)
WEnd

Func MyFunc ($sArg, $sParam)
   MsgBox (0, $sArg, $sParam)
   If $sParam = "Exit. Goodbye!" Then Exit
EndFunc ; ==> MyFunc

Func _Custom_starter_Test ()
    Local $x = 1
    DllCall("user32.dll", "int", "SetForegroundWindow", "hwnd", $POPUP_MENU_INFO[0][1])
    DllCall("user32.dll", "ptr", "SendMessage", _
            "hwnd", ControlGetHandle($POPUP_MENU_INFO[0][1], _
            "", $POPUP_MENU_INFO[$x][1]), _
            "int", 0x007B, _
            "int", $POPUP_MENU_INFO[$x][1], _
            "int", 0)
EndFunc ; ==> _Custom_Starter_Test

You should not need to do anything, the menu SHOULD popup straight away... All You'll see is a context menu saying "Exit".

Mat

Link to comment
Share on other sites

Few more sugesstions/remarks:

1) When you keep holding the hotkeys to call the menu, firstly it's not dissapeared on click in other place (only after selecting an item), and the menu is keep showing that much times as user holded the hotkey. The fix is simple:

Add this to __PopupMenuStart() (after «If $x = -1 Then» line):

HotKeySet(@HotKeyPressed)

and this to the end of that function:

HotKeySet(@HotKeyPressed, "__PopupMenuStart")

2) Can you please pack all the files together in one archive (including the example)? this will make it easy for other users to download and use this UDF.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Grrr... Try running this script, it might show where the problem is...

#include "PopUpMenu.au3"

_PopUpMenuSetOption ("OnEventMode", 1)

$hMenu2 = _PopUpMenuCreate ("!5")
$hExit2 = _PopUpMenuCreateMenuItem ("Exit", $hMenu2)
_PopUpMenuItemSetOnEvent (-1, "MyFunc", "You Sent|Exit. Goodbye!")

_Custom_Starter_Test ()

While 1
   Sleep (5000)
WEnd

Func MyFunc ($sArg, $sParam)
   MsgBox (0, $sArg, $sParam)
   If $sParam = "Exit. Goodbye!" Then Exit
EndFunc ; ==> MyFunc

Func _Custom_starter_Test ()
    Local $x = 1
    DllCall("user32.dll", "int", "SetForegroundWindow", "hwnd", $POPUP_MENU_INFO[0][1])
    DllCall("user32.dll", "ptr", "SendMessage", _
            "hwnd", ControlGetHandle($POPUP_MENU_INFO[0][1], _
            "", $POPUP_MENU_INFO[$x][1]), _
            "int", 0x007B, _
            "int", $POPUP_MENU_INFO[$x][1], _
            "int", 0)
EndFunc ; ==> _Custom_Starter_Test

You should not need to do anything, the menu SHOULD popup straight away... All You'll see is a context menu saying "Exit".

Mat

Okay, it works :D And then ?

Cheers, FireFox.

Link to comment
Share on other sites

Well... That proves that it works!! Now you are confusing me as I can see absolutely nothing that can possibly be wrong!! Can you please retry the examples? Make sure you press the right hotkey etc... Beyond that, I have absolutely no idea whats wrong.

MrCreator, I had not noticed that, and I hadn't tried! But I'll add that in to the next update! I will have a look at packing them up and how best to do that, unfortunately my current file hosting service is experiancing technical difficulties, and I am running out of memory space on the forums!!

Mat

Link to comment
Share on other sites

unfortunately my current file hosting service is experiancing technical difficulties, and I am running out of memory space on the forums!!

There is free service for autoit community: http://trashbin.nfshost.com

Or use the downloads.

P.S

About the space on the forum - don't post big files here, and always pack them.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The problem is... Most of that space is actually images, screenshots etc. not really big files, but quite a few of them!

Google code is a good piece of kit, and I kinda like it. I have never heard of that "trashbin" hosting, but that looks pretty cool!

When I'm not making 3 updates in a day I will put it in the downloads section.

Mat

Link to comment
Share on other sites

Most of that space is actually images

I put the images to ipicture.ru (it's russian service), but you can use http://www.tinypic.com/, or http://funkyimg.com/, or http://www.imageshack.us/ :D

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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