Jump to content

Search the Community

Showing results for tags 'Menu'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

  1. ; #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Local $hGUI = GUICreate("Example", 200, 200) ; 2023.03.12 FontIcon! Local $sFont, $s ; define reusable vars $sFont = "Segoe UI Symbol" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- set font, Font Size does not affect Menus $s = ChrW(0xE160) ; hand $idFilemenu = GUICtrlCreateMenu($s & " &File Index ") $sFont = "Segoe UI Symbol" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- set font, Font Size does not affect Menus $s = ChrW(0xE203) ; OK Local $idFileItem = GUICtrlCreateMenuItem($s & " File Option", $idFilemenu) GUICtrlCreateMenuItem("", $idFilemenu) ; create a separator line $sFont = "Segoe UI Symbol" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- set font, Font Size does not affect Menus $s = ChrW(0x26DD) ; box with cross Local $idExit = GUICtrlCreateMenuItem($s & " Exit ", $idFilemenu) $sFont = "Segoe MDL2 Assets" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- make font size half of button dimensions $s = ChrW(0xE2F6) Local $iconPrint = GUICtrlCreateButton($s, 8, 28, 48, 48) ; <-- button containing fonticon $sFont = "Segoe UI Emoji" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- make font size half of button dimensions $s = ChrW(0x2668) Local $iconMedal = GUICtrlCreateButton($s, 60, 28, 48, 48) ; <-- button containing fonticon $sFont = "Segoe UI Symbol" ; <-- a default Windows font GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) ; <-- make font size half of button dimensions $s = ChrW(0xE129) Local $iconPennon = GUICtrlCreateButton($s, 112, 28, 48, 48) ; <-- button containing fonticon ; take care to reset to an easy read font $sFont = "Segoe" GUISetFont(12, 400, 0, $sFont) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idExit ExitLoop Case $iconPrint MsgBox(0, "FontIcon", "You have clicked a FontIcon!") Case $iconMedal MsgBox(0, "FontIcon Emoji", "Hotstuff!") Case $iconPennon MsgBox(0, "FontIcon Symbol", "Keep the Flag flying") Case $idFileItem MsgBox(0, "Menu Item!", "Do Something!") EndSwitch WEnd GUIDelete($hGUI) A picture paints a thousand words, and having access to icons often contributes to the aesthetics of a GUI. It's not always easy or convenient to make icon files, or compile these into a DLL for later use. Fortunately the onboard Windows Segoe font family provides access to a whole set of font icons. A font icon is a font character that does not paint a letter, but a picture, like an emoji. Using a FontIcon also allows placing images directly into menu items, which would otherwise require a lot of work
  2. I have several context menus that's been built using _GUICtrlMenu_CreatePopup() and _GUICtrlMenu_AddMenuItem(). When using _GUICtrlMenu_CreatePopup() it returns the identifier of the clicked item, sure. But it blocks the main loop while the menu is open. When using _GUICtrlMenu_CreatePopup($MNS_MODELESS) it returns immediately (of course), but I cannot figure out how/where to read the item that was clicked. Is there a Windows Message (WM) somewhere that is triggered? I've spend an entire day trying to figure out how to do this, but I'm not getting anywhere. My google fu is depleted (I must have tried like hundreds of script variations today), I'm about to smash my keyboard and just go to bed, and abandon the entire endeavor of making pretty menus and go back to using Koda and forget about using menu icons, colors, etc. Anyone wanna help me out with how to read the clicked item? Before I smash my keyboard, please... Example script here: #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") Global $idMenuItem = 10000, $counter = 0 Global $hGUI = GUICreate("Menu test", 400, 300) Global $hListview = GUICtrlCreateListView("", 2, 2, 396, 200) GUISetState(@SW_SHOW) ;~ Global $hMenuContext = _GUICtrlMenu_CreatePopup() Global $hMenuContext = _GUICtrlMenu_CreatePopup($MNS_MODELESS) _GUICtrlMenu_AddMenuItem($hMenuContext, "Menu item", $idMenuItem) Global $hTimer = TimerInit() Do If TimerDiff($hTimer)>200 Then $counter += 1 ConsoleWrite($counter & " " ) $hTimer = TimerInit() EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit Func _WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case GUICtrlGetHandle($hListview) ConsoleWrite( @CRLF & "_GUICtrlMenu_TrackPopupMenu = " & _GUICtrlMenu_TrackPopupMenu($hMenuContext, $wParam, -1, -1, 1, 1, 2) & @CRLF) EndSwitch EndFunc
  3. hi dears, i have a question please am now working for an audio player for the blind users and i added an option to open a file from the right click context menu. but here there is a small problem, i hope that you can help me to find a solution for it. the problem is as follow : when i added the problem into the context menu it work with successfuly if the user select just one file. but if the user selected more then one file, here the problem a multiple sections of the program will open. my question is : how i can detect the multiple selection from the context menu? i know that it so hard, but i know also that you are harder than it for that dears please try to give me an solution for that problem. thanks in advance
  4. I've used PowerPro for years and it had a feature that let you turn an array into a menu. It also let you know if it got a right click. I liked the right click feature because it doubled the menu item usage ie left/right on the same menu item. I tried recreate that usage with a context menu. With _ArrayToMenu you can pass menu items for 1 and 2 dimensional arrays. Note you can indicate sub-menu but using a -> at the end of the item. Use a - to make a separater. Optionally you can pass Tooltips by passing a second array. This array must have the same dimensions as the items array even if not all the elements contain tips. The UDF returns an array with this index of row (and if submenus column), the third element is 1 if right clicked otherwise 0 and the fourth element of the array is the label of the menu item. If the user escapes without choosing an item the the first element returns a -1. Same thing if the user clicks on another window. @error returns 1 if there was no array passed, 2 if the second array has different dimensions than the first. If you use the same label in two parts of your menu you will have to distinguish them. You can do that by additionally making sure that the selection matches the index number(s). Note that you'll have to match the index number plus label before you match just the label because Switch will use the first match it can find. In the example below I am using a check on which column the data is in. If it's not in the first column then it must be the other "Beef". Beef Fruit Col2 > Beef Bread $aR = _ArrayToMenu($aM) Switch $aR[3] Case "Beef" and $aR[2] = 0 Beef1() Case "Beef" Beef2() EndSwitch On a technical note I attached the context menu to the window itself not a dummy control and I didn't use _GUICtrlMenu_TrackPopupMenu. Instead I launched the context menu with "send shift-F10" and waited for GuiGetMsg() to give me the selection. Right click is picked up by GUIRegisterMsg WM_RBUTTONUP and Tooltips are done with GUIRegisterMsg WM_MENUSELECT. The whole thing is done with 3 functions. I won't tell you how long it took me to figure this out but I'll say that on one of my early attempts it had two windows running at once and one was just to recieve the right click an tell the other it got it. Suffice it to say I'm no wiz at Autoit but I really appreciate the support the community offers and I hope someone finds this useful. BTW I wrote a script to produce 1d and 2d auotit array code from excel in case you want to model your menu in excel. Here is the link. https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1412314 _ArrayToMenu() UDF ;ArrayToMenu with submenus, tooltips, rightclick and esc to close. ; #INDEX# ======================================================================================================================= ; Title .........: _ArrayToMenu ; AutoIt Version : 3.3.14.2 ; Description ...: Show an array as a popup menu optionally with tooltips and right click. ; Author(s) .....: Rick Sharp ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name..........: _ArrayToMenu($aArray_menu[,$aArray_tooltips]) ; Description...: Display an array as a menu and return the users choice, display tooltips(optional), return right click. ; Syntax........: _ArrayToMenu($aArray_menu[,$aArray_tooltips]) ; ; Parameters....: ; Required......: A 1d or 2d array of menu items ; Use a minus sign in the item to indicate a menu separator. ; Use -> at the end of an item to indicate a sub-menu. ; Optional......: A 1d or 2d array of tooltips. The array must use the same dimensions as the menu items array. ; ; Return values.: An Array ; $aArray[0] is index of the row (-1 if exited with no choice) ; $aArray[1] is index of the column ; $aArray[2] is 1 if right clicked ; $aArray[3] is the selected item (if any) ; Notes.........: If the user clicks on another window the ArrayToMenu returns as if esc were pressed. ; Sub-Menus are limited to 10 levels if you need more change $ahM[10] ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== ; Global $__g_iRT = 0, $__g_aTT1, $__g_ahi ; "$__g_iRT" for right click flag, "$__g_aTT1" for tips, "$__g_ahi" for index of id's in menu and tips ; =============================================================================================================================== ; #@error# ====================================================================================================================== ; 1 - First parameter is Not an array ; 2 - The Menu/Items array and the Tips array are not the same number of dimensions ; =============================================================================================================================== #include-once #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <array.au3> #include <misc.au3> Func _ArrayToMenu($aMenu, $att = "") If Not IsArray($aMenu) Then Return SetError(1, 0, -1) Global $__g_iRT = 0 Local $ahM[10], $iCcnt = UBound($aMenu, 2), $iRcnt = UBound($aMenu), $iRow, $iCol, $b_Esc If UBound($aMenu, 2) = 0 Then _ArrayColInsert($aMenu, 1) ;if 1d array make it 2d EndIf ;Prep Loop to make Menus and Sub-Menus $iRcnt = UBound($aMenu) ;Count of Rows/Items $iCcnt = UBound($aMenu, 2) ;Count of Cols/Menus GUIRegisterMsg($WM_RBUTTONUP, "WM_RBUTTONUP") ;handles Right Click If IsArray($att) Then If UBound($att, 2) = 0 Then _ArrayColInsert($att, 1) If UBound($att, 2) <> $iCcnt Or UBound($att) <> $iRcnt Then Return SetError(2, 0, -1) ;$amenu and $att not same dimensions Global $__g_aTT1 = $att ;added $__g_aTT1 because $att was not seen by WM_MenuSelect for tooltips GUIRegisterMsg($WM_MENUSELECT, "WM_MENUSELECT") ;handles tooltips EndIf Local $mPos = MouseGetPos() #Region ### START Koda GUI section ### Form= $hMenu = GUICreate("C_menu", 10, 10, $mPos[0], $mPos[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Build Menus Global $__g_ahi[$iRcnt + 1][$iCcnt + 1] ;array to hold Menu Item id's $iMcnt = 0 ;Menu count $ahM[$iMcnt] = GUICtrlCreateContextMenu() ;if the array element is null then it falls through and nothing happens For $j = 0 To $iCcnt - 1 ;for each Column/Menu For $i = 0 To $iRcnt - 1 ;for each Row/Item If StringRight($aMenu[$i][$j], 2) = "->" Then ;Sub-Menu $aMenu[$i][$j] = StringTrimRight($aMenu[$i][$j], 2) ;remove -> $iMcnt += 1 $ahM[$iMcnt] = GUICtrlCreateMenu($aMenu[$i][$j], $ahM[$j]) ; $__g_ahi[$i][$j] = $ahM[$iMcnt] ElseIf $aMenu[$i][$j] > "" Then ;Normal item If StringLeft($aMenu[$i][$j], 1) = "-" Then $aMenu[$i][$j] = "" $__g_ahi[$i][$j] = GUICtrlCreateMenuItem($aMenu[$i][$j], $ahM[$j]) EndIf Next Next Send("+{F10}") ;sends right click to open context menu While 1 $nMsg = GUIGetMsg() If $nMsg > 0 Then ;ConsoleWrite("nMsg= " & $nMsg & @CRLF) $iRow = _ArraySearch($__g_ahi, $nMsg) $iCol = _ArraySearch($__g_ahi, $nMsg, 0, 0, 0, 0, 0, $iRow, True) ExitLoop EndIf If _IsPressed("1B") = 1 Or WinActive("C_menu") = 0 Then $b_Esc = -1 ExitLoop EndIf WEnd ;*** Done *** GUIDelete($hMenu) Local $aAr1[4] $aAr1[0] = $iRow $aAr1[1] = $iCol $aAr1[2] = $__g_iRT If Not $b_Esc = -1 Then $aAr1[3] = $aMenu[$aAr1[0]][$aAr1[1]] Else $aAr1[0] = -1 EndIf Return $aAr1 EndFunc ;==>_ArrayToMenu ;Check for Right Click Func WM_RBUTTONUP($hMenu, $iMsg, $iwParam, $ilParam) $__g_iRT = 1 ;Mark as rclicked Send("{Enter}") ;choose the item EndFunc ;==>WM_RBUTTONUP ;Tooltips Func WM_MENUSELECT($hMenu, $iMsg, $iwParam, $ilParam) Local $idMenu = BitAND($iwParam, 0xFFFF) Local $iRow, $iCol If $idMenu > 0 Then $iRow = _ArraySearch($__g_ahi, $idMenu) If $iRow > -1 Then $iCol = _ArraySearch($__g_ahi, $idMenu, 0, 0, 0, 0, 0, $iRow, True) EndIf If $iCol > -1 And $iRow > -1 And $__g_aTT1[$iRow][$iCol] > " " Then ToolTip($__g_aTT1[$iRow][$iCol]) Else ToolTip("") EndIf EndIf EndFunc ;==>WM_MENUSELECT Example 1 Simple 1d array with tooltips, item separator and right click. #include "ArrayToMenu.au3" ;Simple 1d array with tooltips item separator and right click. $aM = StringSplit("Zero,One,-,Two/Two_R", ",", 3) ;make an array for the menu items $aT = StringSplit("Zero,One,-,", ",", 3) ;make an array for the menu Tooltips $aR = _ArrayToMenu($aM,$aT) if @error then ConsoleWrite(@error & @CRLF) EndIf ConsoleWrite("R: " & $aR[0] & " " & "C: " & $aR[1] & " " & "Rclick: " & $aR[2] & " " & "Item: " & $aR[3] & @CRLF) If $aR[0] = -1 Then ;either hit escape or clicked on another window ConsoleWrite("Esc" & @CRLF) Exit EndIf ;_ArrayDisplay($aR) Switch $aR[3] Case "Zero" Zero() Case "One" One() Case "Two/Two_R" And $aR[2] = 0 ;No Rclick Two() Case "Two/Two_R" And $aR[2] = 1 ;Rclick Two_R() EndSwitch Func Zero() ConsoleWrite("You chose: Zero" & @CRLF) EndFunc ;==>Zero Func One() ConsoleWrite("You chose: One" & @CRLF) EndFunc ;==>One Func Two() ConsoleWrite("You chose: Two" & @CRLF) EndFunc ;==>Two Func Two_R() ConsoleWrite("You chose: Two_R" & @CRLF) EndFunc ;==>Two_R Example 2 2d array with sub-menu #include "ArrayToMenu.au3" ;2d array with a sub-menu dim $aM[4][2] = [["Beef", "Orange"], ["Pork", "Apple"], ["Chicken", "Grape"], ["Fruit->", ""]] ;Note you don't need a tooltip for every item but you at least need a place holder in the array dim $aT[4][2] = [["Red Meat", "Fruit"], ["Other white meat", "Fruit"], ["White meat", "Fruit"], ["", ""]] $aR = _ArrayToMenu($aM,$aT) if @error Then ConsoleWrite(@error & @CRLF) Exit EndIf If $aR[0] = -1 Then ConsoleWrite("Esc" & @CRLF) Exit EndIf ConsoleWrite("R: " & $aR[0] & " " & "C: " & $aR[1] & " " & "Rclick: " & $aR[2] & " " & "Item: " & $aR[3] & @CRLF) Switch $aR[3] Case "Beef" Beef() Case "Pork" Pork() Case "Chicken" Chicken() Case "Orange" ConsoleWrite("Oranges are good for you!" & @CRLF) ConsoleWrite("Oranges" & " $aR[0] = " & $aR[0] & " $aR[1] = " & $aR[1] & @CRLF) Case "Apple" ConsoleWrite("Apples are good for you!" & @CRLF) Case "Grape" ConsoleWrite("Grapes are good for you!" & @CRLF) EndSwitch Func Beef() ConsoleWrite("Beef" & " $aR[0] = " & $aR[0] & " $aR[1] = " & $aR[1] & @CRLF) EndFunc ;==>Beef Func Pork() ConsoleWrite("Pork" & " $aR[0] = " & $aR[0] & " $aR[1] = " & $aR[1] & @CRLF) EndFunc ;==>Pork Func Chicken() ConsoleWrite("Chicken" & @CRLF) EndFunc ;==>Chicken
  5. Hello my friends Can we create a single context menu on more than one item? For example, a context menu includes standardized options on more than one control, such as buttons or check boxes to Create a context menu on one item am using this function GUICtrlCreateContextMenu ($ HWND) How to link it with more than one element please? or if we can't do that, please give me a solution so i tried to add an context menus to all the controls but the script will be long, for that if their are any solutions i hope to give it to me thanks in advanced
  6. Hello I have an inquiry please when i use the control get focus it don't detect the menu item there are any Method to do that? i'll use that to make a custom screen reader in my program please help me to do that I am waiting for your answers greetings to you Thank you in advance
  7. <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a> Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
  8. Hello all I have a question please this a question is about the context menu When i create a list box Or combo box if i create a context menu for this list When i press the application key or the shortcut shift + f10 the menu options is appear normally but When i create a List view if i create a context menu for this list When i press the application key or the shortcut shift + f10 the menu options isn't appear But the right mouse button works normally I need a solution please because I deal with the screen readers users Unfortunately They can not use the mouse to navigate So I have to find a solution to activate keyboard shortcuts am waiting for your help
  9. I have a working program currently driven largely through menu selections. I would like to add a toolbar where most of the tollbar button actions are basically the same as menu items, but quicker to access. I have been wading around in toolbar examples, MSDN pages etc, it's clearly going to be a bit of a slog to get everything right, including tooltips etc. I thought I would start with something simple to prove the principle. Using bits from the help file examples I have a small program that successfully displays a toolbar. However, what seemed like the most elegant way to deal with the button commands does not seem to work. My understanding was that a toolbar button fires a WM_COMMAND message, with the command Id set by the second parameter in the call to _GUICtrlToolbar_AddButton ( $hWnd, $iID, $iImage) so I though it would be a good idea to set this Id to the same value as my menu item Id; then it would run the same task which is what I wanted. This did not work. I am using message loop mode and would like to stick with this because some of my scripts run hardware at the same time as the gui; it is easier if I don't have to worry about code being interrupted with the hardware in an unknown state . So I added a handler for WM_COMMAND, with some cribbed display code to try and see why. The toolbar button defintely fired a WM_COMMAND message and the Id looked the same, so no explanation there. I guess the issue is with GUIGetMsg() which may be constructed to ignore all but a limited number of control handles, i.e. those made with the GuiCtrlCreate... commands; this is speculation. I would dearly love to find a tidy way to get around this. Having some controls handled in the message loop and some in a WM_COMMAND handler, performing the same task, feels ugly. I would be very grateful for further insight from someone experienced with handling a toolbar. Perhaps I should be trying to fire the menu item. I have attached a code snippet to try and illustrate the issue. ToolbarTrial.au3
  10. Hi, i searched some topics but cannot found a simple way to do that: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) ; I tried this but user reported that it work in 2006, not seems work actually $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) GuiCtrlSetImage($fileitem, "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Also tried: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) $filemenu = TrayCreateMenu("&File") $fileitem = TrayCreateItem("Open",$filemenu) ;GuiCtrlSetImage($fileitem, "shell32.dll", 4) ;GuiCtrlSetImage(TrayItemGetHandle($fileitem), "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Well.. thanks in advance! Ok. I found this working example from Yashied. If i cannot find a simple then i will go with it #Include <GUIConstantsEx.au3> #Include <GUIMenu.au3> #Include <Constants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hMenu, $hForm, $hFile = 1000, $idNew, $idExit $hForm = GUICreate('Menu', 400, 300) $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem ($hFile, 0, ' &Favorites', $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, '', 0) _GUICtrlMenu_InsertMenuItem($hFile, 2, ' E&xit', $idExit) $hMenu = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMenu, 0, '&File', 0, $hFile) _GUICtrlMenu_SetMenu($hForm, $hMenu) _GUICtrlMenu_SetItemBmp($hFile, 0, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 43, 16, 16)) _GUICtrlMenu_SetItemBmp($hFile, 2, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 27, 16, 16)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _CreateBitmapFromIcon($iBackground, $sIcon, $iIndex, $iWidth, $iHeight) Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap) $hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) If Not @error Then _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL) _WinAPI_DestroyIcon($hIcon) EndIf _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hBackDC) Return $hBitmap EndFunc ;==>_CreateBitmapFromIcon Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Ok, i noticed that is a pain create submenu with _GUICtrlMenu_CreatePopup to do like in Tray, and Tray better located, then i need images/icon with Tray functions, some workaround??
  11. hello guys how are youØŸ I hope to be fine. I have a question please how do I get the menu item that was pressed without that contains a variableØŸ For example I have a menu of Favorites and I want the script recognizes the existing path in the pressed item i'll repeat to tell the item does not contain a variable Is there any solution if you want to explain more I could write an example of what I want. Greetings to all, thanks in advance
  12. The following code is intended to illustrate a method of adding recent files to the File menu, once files have been opened or saved. This is not a UDF, nor a universal solution which fits all requirements. It is just the solution I made for myself and I thought it worth sharing. I haven't noticed much about this subject. The example only emulates opening and saving files: nothing is actually written to disk. I have not included any code for opening or saving files - only the File menu and Title bar are updated. The code is intended to illustrate the logic I used. Perhaps you can improve on it or get some ideas from this example. #include <GUIConstants.au3> #include <MsgBoxConstants.au3> Example() #Region ; core functions Func UpdateRecentFiles(ByRef $aRecentFiles, $ahMenu, $sNewPath, $iMenuInsertPos) Local $iMaxFiles = UBound($aRecentFiles) -1 For $i = 1 To $aRecentFiles[0][0] ; check to see if the path was accessed recently If $aRecentFiles[$i][0] = $sNewPath Then ; file is already in the list For $j = $i To 2 Step -1 $aRecentFiles[$j][0] = $aRecentFiles[$j -1][0] ; push items down the list Next $aRecentFiles[1][0] = $sNewPath For $j = 1 To $aRecentFiles[0][0] ; update all recent file menu items GUICtrlSetData($aRecentFiles[$j][1], $aRecentFiles[$j][0]) ; overwrite existing control data Next Return ; the list has simply been reordered EndIf Next ; if we are here, then the file was not found in the recent files list For $i = $iMaxFiles To 2 Step -1 $aRecentFiles[$i][0] = $aRecentFiles[$i -1][0] ; push all existing items down the list Next If $aRecentFiles[0][0] < $iMaxFiles Then $aRecentFiles[0][0] += 1 ; increment the number of recent files in the list $aRecentFiles[$aRecentFiles[0][0]][1] = GUICtrlCreateMenuItem($sNewPath, $ahMenu[0], $aRecentFiles[0][0] + $iMenuInsertPos) ; create a new control ; add a second spacer to the menu after the first recent item appears (one time action) If $aRecentFiles[0][0] = 1 Then $aRecentFiles[0][1] = GUICtrlCreateMenuItem('', $ahMenu[0], $aRecentFiles[0][0] + $iMenuInsertPos +1) ; add divider after adding the first recent item EndIf $aRecentFiles[1][0] = $sNewPath ; add the new path to the files list For $i = 1 To $aRecentFiles[0][0] ; update all recent file menu items GUICtrlSetData($aRecentFiles[$i][1], $aRecentFiles[$i][0]) ; overwrite existing control data Next EndFunc ;==> UpdateRecentFiles Func ClearRecentFiles(ByRef $aRecentFiles, $idDummyInactive) For $i = 0 To $aRecentFiles[0][0] GUICtrlDelete($aRecentFiles[$i][1]) ; delete menu items $aRecentFiles[$i][1] = $idDummyInactive ; render all control IDs inactivate Next $aRecentFiles[0][0] = 0 ; there are now zero files in the list EndFunc ;==> ClearRecentFiles Func DeleteRecentItem(ByRef $aRecentFiles, $iItem, $idDummyInactive) For $i = $iItem To $aRecentFiles[0][0] -1 $aRecentFiles[$i][0] = $aRecentFiles[$i +1][0] GUICtrlSetData($aRecentFiles[$i][1], $aRecentFiles[$i][0]) Next GUICtrlDelete($aRecentFiles[$aRecentFiles[0][0]][1]) $aRecentFiles[$aRecentFiles[0][0]][1] = $idDummyInactive $aRecentFiles[0][0] -= 1 If $aRecentFiles[0][0] = 0 Then GUICtrlDelete($aRecentFiles[0][1]) $aRecentFiles[0][1] = $idDummyInactive EndIf EndFunc ;==> DeleteRecentItem #EndRegion ;==> core functions #Region ; example code Func Example() Local $sGUITitle = "New Project", $hGUI = GUICreate($sGUITitle, 500, 200) ; create GUI Local _ ; declare menu arrays $ahMenu[2] = [" File "," Options"], _ ; 1D array assigned to menus $ahMenuItem = GetMenuItems() ; 2D array assigned to menu item controls For $i = 0 To UBound($ahMenu) -1 $ahMenu[$i] = GUICtrlCreateMenu($ahMenu[$i]) ; create menu For $j = 1 To $ahMenuItem[0][$i] ; add menu item controls $ahMenuItem[$j][$i] = GUICtrlCreateMenuItem($ahMenuItem[$j][$i], $ahMenu[$i]) Next Next Local $iMenuInsertPos = 4 ; this is the menuentry position for the most recent file GUICtrlCreateMenuItem('', $ahMenu[0], $iMenuInsertPos) ; create dividor Local $aRecentFiles[9][2] = [[0]], _ ; zero previously stored items - assuming that the recent files list is empty at startup $idDummyInactive = GUICtrlCreateDummy() ; never send messages to $idDummyInactive For $i = 0 To 8 ; [IMPORTANT] Windows assigned a unique control ID to $idDummyInactive $aRecentFiles[$i][1] = $idDummyInactive ; temporarily set all (recent files list) controls to never receive messages Next GUISetState(@SW_SHOW) Local $msg, $sFilePath While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $ahMenuItem[5][0] ExitLoop Case $ahMenuItem[1][0] ; File ==> New New() WinSetTitle($hGUI , WinGetTitle($hGUI), $sGUITitle) Case $ahMenuItem[2][0] ; File ==> Open $sFilePath = Open() If Not @error Then WinSetTitle($hGUI , WinGetTitle($hGUI), $sFilePath) UpdateRecentFiles($aRecentFiles, $ahMenu, $sFilePath, $iMenuInsertPos) EndIf Case $ahMenuItem[3][0] ; File ==> Save $sFilePath = Save(WinGetTitle($hGUI)) If @error Then MsgBox($MB_OK, "Action Failed", "Unable to save file") ContinueLoop ; [use your own code logic] Else WinSetTitle($hGUI , WinGetTitle($hGUI), $sFilePath) UpdateRecentFiles($aRecentFiles, $ahMenu, $sFilePath, $iMenuInsertPos) ; update recent files here EndIf Case $ahMenuItem[4][0] ; File ==> Save As $sFilePath = SaveAs() If @error Then MsgBox($MB_OK, "Action Failed", "Unable to save file") ContinueLoop ; [use your own code logic] Else WinSetTitle($hGUI , WinGetTitle($hGUI), $sFilePath) UpdateRecentFiles($aRecentFiles, $ahMenu, $sFilePath, $iMenuInsertPos) ; update recent files here EndIf Case $ahMenuItem[1][1] ; Options ==> Clear Recent Files ClearRecentFiles($aRecentFiles, $idDummyInactive) Case $aRecentFiles[1][1], $aRecentFiles[2][1], $aRecentFiles[3][1], $aRecentFiles[4][1], $aRecentFiles[5][1], $aRecentFiles[6][1], $aRecentFiles[7][1], $aRecentFiles[8][1] For $i = 1 To $aRecentFiles[0][0] If $msg = $aRecentFiles[$i][1] Then $sFilePath = OpenRecent($aRecentFiles[$i][0]) If Not @error Then WinSetTitle($hGUI , WinGetTitle($hGUI), $sFilePath) UpdateRecentFiles($aRecentFiles, $ahMenu, $sFilePath, $iMenuInsertPos) ; update recent files here ElseIf @error = 1 Then If MsgBox(BitOR($MB_YESNO, $MB_DEFBUTTON2, $MB_TASKMODAL), "Action Failed", "Unable to locate " & $aRecentFiles[$i][0] & @CRLF & _ "Do you want to remove this item from the menu?") = 6 Then DeleteRecentItem($aRecentFiles, $i, $idDummyInactive) EndIf ExitLoop ; return to the While loop EndIf Next EndSwitch WEnd EndFunc ;==> Example Func New() ; start a new project [your code here] EndFunc ;==> New Func Open() Local $sFilePath = FileOpenDialog("Open", @DocumentsCommonDir, "All (*.*)") If @error Then Return SetError(1) ; read file [your code here] Return $sFilePath EndFunc ;== Open Func OpenRecent($sFilePath) If Not FileExists($sFilePath) Then Return SetError(1) ; unable to open recent file ; read file [your code here] Return $sFilePath EndFunc ;== OpenRecent Func Save($sFilePath) If Not FileExists($sFilePath) Then Local $sNewPath = SaveAs() If @error Then Return SetError(1) ; unable to save file Return $sNewPath EndIf ; save file [your code here] Return $sFilePath EndFunc ;==> Save Func SaveAs() Local $sFilePath = FileSaveDialog( "Save As", @DocumentsCommonDir, "All (*.*)") If @error Then Return SetError(1) ; unable to save file ; save new or existing file [your code here] Return $sFilePath EndFunc ;==> SaveAs Func GetMenuItems() Local $aMenuItem[6][2] $aMenuItem[0][0] = 5 ; number of items on the File Menu $aMenuItem[0][1] = 1 ; number of items on the Options Menu ; File Menu $aMenuItem[1][0] = "New" $aMenuItem[2][0] = "Open" $aMenuItem[3][0] = "Save" $aMenuItem[4][0] = "Save As" $aMenuItem[5][0] = "Exit" ; Options Menu $aMenuItem[1][1] = "Clear Recent Files" Return $aMenuItem EndFunc ;==> GetMenuItems #Region ; example code Run the example, open some files and check for new menu items that are added. Then try a few other menu options and check the various changes occurring in the File menu.
  13. I'm having a hard time figuring out how to make a menu without any tab stops for the buttons. I made a shell menu for BIOS flashing in WinPE and in it I don't want *any* buttons to be tab stopped. If I try to use GUICtrlSetStyle to remove the tab stops from all the buttons, the first button declared in the menu ends up the default (so the user could press the spacebar and the button is activated). Melba23 posted some code like below a long time ago in this post but it seems to do the same thing as GUICtrlSetStyle does. Any tips/help is appreciated. _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) #include <ButtonConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("GUICloseOnESC", 0) ; prevent user from pressing escape key and accidentally cancelling the GUI HotKeySet("+!{ESC}", "_doCMD") ; shift-alt-escape for a command dialogue during GUI (lab/service use) #include <Array.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> GLobal $s_Cmd1, $s_Cmd2, $s_Cmd3, $s_Cmd4, $s_Cmd5 $s_Debug = 0 $s_dbgArray = 0 Opt("GUICloseOnESC", 0) ; prevent user from pressing escape key and accidentally cancelling the GUI HotKeySet("+!{ESC}", "_doCMD") ; shift-alt-escape for a command dialogue during GUI (lab/service use) $MainMenu = GUICreate("Main BIOS Menu", 600, 400, -1, -1, 0, $WS_EX_TOPMOST) $Button1 = GUICtrlCreateButton("1", 48, 64, 75, 25) $Label1 = GUICtrlCreateLabel("One", 136, 68, 186, 20) $Button2 = GUICtrlCreateButton("2", 48, 110, 75, 25) $Label2 = GUICtrlCreateLabel("Two", 136, 113, 389, 20) $Button3 = GUICtrlCreateButton("3", 48, 172, 75, 25) $Label3 = GUICtrlCreateLabel("Three", 136, 176, 186, 20) $Button4 = GUICtrlCreateButton("4", 48, 218, 75, 25) $Label4 = GUICtrlCreateLabel("Four", 136, 221, 389, 20) $Button5 = GUICtrlCreateButton("5", 48, 272, 75, 25) $Label5 = GUICtrlCreateLabel("Five", 136, 274, 280, 20) $Button6 = GUICtrlCreateButton("Cancel", 475, 340, 75, 25) $Label6 = GUICtrlCreateLabel("Click to cancel the operations", 300, 345, 175, 20) $Label0 = GUICtrlCreateLabel("Please choose one of the following 5 options:", 171, 16, 271, 20) $Label7 = GUICtrlCreateLabel("Which system do you want to set up? [Press or click 1, 2, 3, 4 or use 5 to flash]", 78, 312, 456, 20) $Group1 = GUICtrlCreateGroup("IVS", 36, 44, 513, 101) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("IAS", 36, 152, 513, 101) GUICtrlCreateGroup("", -99, -99, 1, 1) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button1), $GWL_STYLE), BitNOT($WS_TABSTOP))) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button2), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button2), $GWL_STYLE), BitNOT($WS_TABSTOP))) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button3), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button3), $GWL_STYLE), BitNOT($WS_TABSTOP))) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button4), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button4), $GWL_STYLE), BitNOT($WS_TABSTOP))) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button5), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button5), $GWL_STYLE), BitNOT($WS_TABSTOP))) _WinAPI_SetWindowLong(GUICtrlGetHandle($Button6), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($Button6), $GWL_STYLE), BitNOT($WS_TABSTOP))) ;~ GUICtrlSetStyle($Button1, 0) ;~ GUICtrlSetStyle($Button2, 0) ;~ GUICtrlSetStyle($Button3, 0) ;~ GUICtrlSetStyle($Button4, 0) ;~ GUICtrlSetStyle($Button5, 0) ;~ GUICtrlSetStyle($Button6, 0) GUISetState(@SW_SHOW, $MainMenu) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Button6 GUISetState(@SW_HIDE, $MainMenu) MsgBox(4096, "Cancel", "Operation cancelled. Please remove the media and click OK to reboot.") Exit Case $nMsg = $Button1 Or _IsPressed("31") Or _IsPressed("61") ; is the button, keyboard number, or keypad number pressed? _doRun(@ScriptDir & "\" & $s_Cmd1) Case $nMsg = $Button2 Or _IsPressed("32") Or _IsPressed("62") _doRun(@ScriptDir & "\" & $s_Cmd2) Case $nMsg = $Button3 Or _IsPressed("33") Or _IsPressed("63") _doRun(@ScriptDir & "\" & $s_Cmd3) Case $nMsg = $Button4 Or _IsPressed("34") Or _IsPressed("64") _doRun(@ScriptDir & "\" & $s_Cmd4) Case $nMsg = $Button5 Or _IsPressed("35") Or _IsPressed("65") _doRun(@ScriptDir & "\" & $s_Cmd5) EndSelect WEnd ;~ ;============================================================================= ;~ ;==================================Functions================================== ;~ ;============================================================================= ;~ ;============================================================================= ;~ ; Run function for batch or executable files, hides main menu when running ;~ ;============================================================================= Func _doRun($RunFile) GUISetState(@SW_HIDE, $MainMenu) RunWait(@ComSpec & " /c " & $RunFile) GUISetState(@SW_SHOW, $MainMenu) EndFunc ;==>_doRun ; -------------------------------------------------- ; Run a command prompt for lab/field troubleshooting ; -------------------------------------------------- Func _doCMD() HotKeySet("+!{ESC}") ; deactivate hotkey to prvent spawning multiple cmd boxes with it GUISetState(@SW_HIDE, $MainMenu) ; hide the GUI RunWait(@ComSpec & " /c " & "cmd.exe", "", @SW_SHOW) GUISetState(@SW_SHOW, $MainMenu) ; bring the GUI back up HotKeySet("+!{ESC}", "_doCMD") ; reset the hotkey shift-alt-escape for a command dialogue (emergency use) EndFunc ;==>_doCMD
  14. Hi All, I have a custom icon for the tray menu icon, which was working until I copied in the example code for a custom menu when clicking on the tray icon, now it just displays the default AutoIt tray icon. The menu works fine, but the tray icon initiates as the AutoIt default icon and the icon won't change on event. Can anyone advise what I need to do to use my custom icon while retaining the tray custom menu? Thanks! Also, the While 1 ... WEnd makes me nervous, how does this not lock up the system? If anyone would like to comment on that - thanks. Opt("TrayMenuMode", 3) #include <TrayConstants.au3> Local $idAbout = TrayCreateItem("About") Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) While 1 Switch TrayGetMsg() Case $idAbout MsgBox(1,"test","test msg") Case $idExit Exit EndSwitch WEnd If Not FileExists (@TempDir & "\MyIcons") Then DirCreate(@TempDir & "\MyIcons") FileInstall(".\Grey-1.ico", @TempDir & "\MyIcons\Grey-1.ico", 1) FileInstall(".\Yellow-1.ico", @TempDir & "\MyIcons\Yellow-1.ico", 1) TraySetIcon(@TempDir & "\MyIcons\Grey-1.ico");Change icon to grey initially ; If X happens then change tray icon to yellow ; If Y happens then change tray icon to grey
  15. Hi, i'm looking for a way to get the text of selected item from a popup menu here is my script, it works fine for non-Explorer.exe window (tested on SciTE on both context menu and menubar menu), but fails on displayed menu on Desktop... Local $hDLL, $hWinEventProc, $hHook Local $LastMenuItem[5] ;Save last menu item propieties Local $EVENT_Min = 0x0006 ;An MSAA event indicating that a pop-up menu was displayed. Local $EVENT_Max = 0x0007 ;An MSAA event indicating that a pop-up menu was closed. Local $hWinEventProc = DllCallbackRegister("_WinEventProc", "none", "hwnd;int;hwnd;long;long;int;int") If Not @error Then OnAutoItExitRegister("OnAutoItExit") Else MsgBox(16 + 262144, "Error", "DllCallbackRegister(_WinEventProc) did not succeed.") Exit EndIf $hHook = _SetWinEventHook($EVENT_Min, $EVENT_Max) If @error Then MsgBox(16 + 262144, "Error", "_SetWinEventHook() did not succeed.") Exit EndIf While True Sleep(250) ;function that get last menu item propieties _PopupMenuItem() WEnd Func _WinEventProc($hHook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime) Switch $iEvent Case 6 ConsoleWrite("(i) pop-up menu was displayed..."&@CRLF) Case 7 _SelectedMenuItem() ConsoleWrite("(i) pop-up menu was closed..."&@CRLF) EndSwitch EndFunc ;==>_WinEventProc Func _SetWinEventHook($iEventMin, $iEventMax) Local $aRet Local Const $WINEVENT_OUTOFCONTEXT = 0x0 Local Const $WINEVENT_SKIPOWNPROCESS = 0x2 $aRet = DllCall("User32.dll", "hwnd", "SetWinEventHook", _ "uint", $iEventMin, _ "uint", $iEventMax, _ "hwnd", 0, _ "ptr", DllCallbackGetPtr($hWinEventProc), _ "int", 0, _ "int", 0, _ "uint", BitOR($WINEVENT_OUTOFCONTEXT, $WINEVENT_SKIPOWNPROCESS)) If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_SetWinEventHook Func OnAutoItExit() If $hWinEventProc Then DllCallbackFree($hWinEventProc) If $hHook Then DllCall("User32.dll", "int", "UnhookWinEvent", "hwnd", $hHook) EndFunc ;==>OnAutoItExit Func _PopupMenuItem() Local $aRect, $hMenu = False, $MenuItem[9] Local $hDesktop = _WinAPI_GetDesktopWindow() Local $hChild = _WinAPI_GetWindow( $hDesktop, 5 ), $i = 0 Local $hWindow = WinGetHandle("[ACTIVE]") Local $hChild = _WinAPI_GetWindow($hDesktop, 5) Local $i = 0 While $hChild And $i < 5 If _WinAPI_GetClassName( $hChild ) = "#32768" Then $hMenu = _SendMessage( $hChild, 0x01E1 ) ExitLoop EndIf $hChild = _WinAPI_GetWindow( $hChild, 2 ) $i += 1 WEnd If $hMenu Then Local $iCount = _GUICtrlMenu_GetItemCount($hMenu), $sText For $i = 0 To $iCount - 1 If $i = _GUICtrlMenu_MenuItemFromPoint($hWindow, $hMenu) Then If _GUICtrlMenu_GetItemEnabled($hMenu, $i) Then $MenuItem[0] = $hWindow $MenuItem[1] = $hMenu $MenuItem[2] = $i $MenuItem[3] = _GUICtrlMenu_GetItemText($hMenu, $i ) $MenuItem[4] = _GUICtrlMenu_GetItemRectEx($hWindow, $hMenu, $i) If $LastMenuItem[0] <> $MenuItem[0] Or $LastMenuItem[1] <> $MenuItem[1] Or $LastMenuItem[2] <> $MenuItem[2] Then $LastMenuItem = $MenuItem ConsoleWrite("* mouse over item: "&$LastMenuItem[3]&@CRLF) EndIf EndIf ExitLoop EndIf Next EndIf EndFunc Func _SelectedMenuItem() Local $tPOINT = _WinAPI_GetMousePos() ConsoleWrite("(i) last mouse position: "&DllStructGetData($tPoint, "X")&":"&DllStructGetData($tPoint, "Y")&@CRLF) If _WinAPI_PtInRect($LastMenuItem[4], $tPOINT) Then ConsoleWrite("-> selected item: "&$LastMenuItem[3]&@CRLF) Else ConsoleWrite("(i) last menu item position Rect: "&DllStructGetData($LastMenuItem[4], "Left")&">"&DllStructGetData($LastMenuItem[4], "Right")&":"&DllStructGetData($LastMenuItem[4], "Top")&"V"&DllStructGetData($LastMenuItem[4], "Bottom")&@CRLF) EndIf EndFunc ; Functions From Include Directory Func _WinAPI_GetWindow($hWnd, $iCmd) Local $aResult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hWnd, "uint", $iCmd) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $aResult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Or Not $aResult[0] Then Return SetError(@error, @extended, '') Return SetExtended($aResult[0], $aResult[2]) EndFunc Func _GUICtrlMenu_GetItemCount($hMenu) Local $aResult = DllCall("user32.dll", "int", "GetMenuItemCount", "handle", $hMenu) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult") Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam) If @error Then Return SetError(@error, @extended, "") If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn] Return $aResult EndFunc Func _GUICtrlMenu_GetItemRectEx($hWnd, $hMenu, $iItem) Local $tRECT = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct") Local $aResult = DllCall("user32.dll", "bool", "GetMenuItemRect", "hwnd", $hWnd, "handle", $hMenu, "uint", $iItem, "struct*", $tRECT) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tRECT) EndFunc Func _GUICtrlMenu_GetItemText($hMenu, $iItem, $bByPos = True) Local $iByPos = 0 If $bByPos Then $iByPos = 0x00000400 Local $aResult = DllCall("user32.dll", "int", "GetMenuStringW", "handle", $hMenu, "uint", $iItem, "wstr", "", "int", 4096, "uint", $iByPos) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $aResult[3]) EndFunc Func _GUICtrlMenu_GetItemInfo($hMenu, $iItem, $bByPos = True) Local $tInfo = DllStructCreate("uint Size;uint Mask;uint Type;uint State;uint ID;handle SubMenu;handle BmpChecked;handle BmpUnchecked;" & _ "ulong_ptr ItemData;ptr TypeData;uint CCH;handle BmpItem") DllStructSetData($tInfo, "Size", DllStructGetSize($tInfo)) DllStructSetData($tInfo, "Mask", 0x0000003F) Local $aResult = DllCall("user32.dll", "bool", "GetMenuItemInfo", "handle", $hMenu, "uint", $iItem, "bool", $bByPos, "struct*", $tInfo) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tInfo) EndFunc Func _GUICtrlMenu_GetItemStateEx($hMenu, $iItem, $bByPos = True) Local $tInfo = _GUICtrlMenu_GetItemInfo($hMenu, $iItem, $bByPos) Return DllStructGetData($tInfo, "State") EndFunc Func _GUICtrlMenu_GetItemEnabled($hMenu, $iItem, $bByPos = True) Return BitAND(_GUICtrlMenu_GetItemStateEx($hMenu, $iItem, $bByPos), 0x00000002) = 0 EndFunc Func _GUICtrlMenu_MenuItemFromPoint($hWnd, $hMenu, $iX = -1, $iY = -1) If $iX = -1 Then $iX = _WinAPI_GetMousePosX() If $iY = -1 Then $iY = _WinAPI_GetMousePosY() Local $aResult = DllCall("user32.dll", "int", "MenuItemFromPoint", "hwnd", $hWnd, "handle", $hMenu, "int", $iX, "int", $iY) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_GetMousePosX($bToClient = False, $hWnd = 0) Local $tPoint = _WinAPI_GetMousePos($bToClient, $hWnd) If @error Then Return SetError(@error, @extended, 0) Return DllStructGetData($tPoint, "X") EndFunc Func _WinAPI_GetMousePosY($bToClient = False, $hWnd = 0) Local $tPoint = _WinAPI_GetMousePos($bToClient, $hWnd) If @error Then Return SetError(@error, @extended, 0) Return DllStructGetData($tPoint, "Y") EndFunc Func _WinAPI_PtInRect(ByRef $tRECT, ByRef $tPoint) Local $aResult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $tRECT, "struct", $tPoint) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_GetMousePos($bToClient = False, $hWnd = 0) Local $iMode = Opt("MouseCoordMode",1) Local $aPos = MouseGetPos() Opt("MouseCoordMode", $iMode) Local $tPoint = DllStructCreate("struct;long X;long Y;endstruct") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) If $bToClient And Not _WinAPI_ScreenToClient($hWnd, $tPoint) Then Return SetError(@error + 20, @extended, 0) Return $tPoint EndFunc Func _WinAPI_ScreenToClient($hWnd, ByRef $tPoint) Local $aResult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hWnd, "struct*", $tPoint) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_GetDesktopWindow() Local $aResult = DllCall("user32.dll", "hwnd", "GetDesktopWindow") If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Cause of the problem: _WinAPI_PtInRect fails on Explorer.exe windows because _GUICtrlMenu_GetItemRectEx returns relative rectangle bounds to the menu (i think) where always X1 = 0. Any suggestions to make this script works on all menus? Thanks
  16. Greetings people of the AutoIt community! I think I have discovered some possible wrong verbiage in the HelpFile. I'm trying to make my software detect the _IsPressed("KEY") for the RIGHT MENU button on the keyboard. You all have a RIGHT MENU button on your keyboard (maybe you haven't noticed it), it's they key between the Right ALT key and the Right CTRL Key. However!!!!!!! In the helpfile it says the RIGHT MENU key is "A5", that is not true for me. A5 is actually the Right ALT key. So my question is, what is the _IsPressed HexKey for the RIGHT MENU button? #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("A5", $hDLL) Then Sleep(100) msgbox(0,"Test", "Pressed!") Sleep(250) EndIf WEnd DllClose($hDLL) If you try to run the above code, the msgbox will only appear if you press the Right ALT key, even though the helpfil says that A5 is the Right Menu Key hex. Thank you, Brian
  17. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 22) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Exampleguictrlsetimage this awesome little example from the Helpfile My question is this: does a Menu created with a function like guictrlcreatemenu have any special attributes? In stead of using guictrlcreatemenu, can I simply create a 'panel' and then run a series of picture buttons on it, behaving like a menu? I guess what I want to know is (a) if a menu contains any additional functionality which makes it a preferred choice over a row of buttons? (b) since we can not make a button menu, would a row of buttons work when presented to the user as a menu? Anything else I should know? Thanks
  18. Hi guys, I'm using this startup example to allow the program menu to insert an option to "AutoStart" the script. What I'd like to do is update the checkbox of the menu item after they click it to then reflect the "AutoStart" state (on or off). How do I update the menu on the event someone clicks the menu option? The registry is updating correctly, and if I close and re-run the script the menu is updated, but not in the same script execution. I wasn't sure with TrayItemSetState for my "Func AutoStart()" Function what the "controlID" was. I tried 0 through to 3 and "AutoStart" text. Perhaps this is where I'm going wrong? ; Add custom tray icon menu #NoTrayIcon #include <MsgBoxConstants.au3> #include <TrayConstants.au3> Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #include '_Startup.au3' TrayCreateItem("AutoStart") TrayItemSetOnEvent(-1, "AutoStart") If _StartupRegistry_Exists() Then TrayItemSetState(-1, $TRAY_CHECKED) Else TrayItemSetState(-1, $TRAY_UNCHECKED) EndIf TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "About") TraySetState($TRAY_ICONSTATE_SHOW) ; ################## ; ### OTHER CODE ### ; ################## Func About() MsgBox(0,"About","etc") EndFunc Func AutoStart() If _StartupRegistry_Exists() Then _StartupRegistry_Uninstall() TrayItemSetState("AutoStart", $TRAY_UNCHECKED) Else _StartupRegistry_Install() TrayItemSetState("AutoStart", $TRAY_CHECKED) EndIf EndFunc Func ExitScript() Exit EndFuncThanks!
  19. Hi ^^, Just a little list of question: 1. How to make an Var which defines everything like ' * ' Var of Windows 2. How to add The Var(1.) within the a ComboBox or In the Menu 3. How to load simply an *.au3 File wich adding a GUI and to the Main GUI a Button 4. Using XML Files instead of 3. (I know the XMLDom or how it was named but Include file isn't anymore on my side avaible) 5. Progressbar which is attached to Loading the File of 3./4. Thanks to everyone who helps :3
  20. Hi I'm trying to make a small script (windowless), when you run it there needs to appear a context-menu where the cursor is. So if you double-click on the script file it looks like the menu appears on the script icon.. is this easy to do? can't find an answer directly, wish i could post some code to begin with but I have no clue how to start this Can i use $hMenu = GUICtrlCreateContextMenu(-1) for this with no window? dll calls are welcome to if it's not possible the simple way Like always, thanks in advance! TheAutomator
  21. Hello How does Autoit detect when you click on a menu button? (not a sub-menu item, but the actual menu button itself) $Form = GUICreate("", 410, 270) $Menu_Help = GUICtrlCreateMenu("Help") GUISetState(@SW_SHOW) while true Switch GUIGetMsg() Case $Menu_Help msgbox(0,1,2) EndSwitch wend Thanks in advance TheAutomator [EDIT:] Should this be in the gui section?
  22. I have a question relating to this code example of the user funkey: >ComboBox with radiobuttons and checkboxes The last posted code example of funkey combining a drop-down list with a "check"-option is great and it does still work with Win 7 and the current AutoIt version. The only "handicap" that bothers me is that the drop-down menu of the combo-button closes every time when one of the options is checked / set. Unfortunately I does not understand the code completely but do you think it would be possible to modify the behavior of the menu to keep it open as long as the user clicks outside the menu (e.g.) to give the user the ability to choose multiple options? Or maybe you know a GUI UDF package that contains a similar GUI element? I would be pleased for any tip / help. Auto42
  23. Hi! So what I need is a context menu like that from explorer when you right click on desktop. But i don't know if that is possible. I searched a little and I found nothing, maybe you guys have any ideas ? I mean something like that : But...I know how do that from the GUIcreateblahblah side...now the problem is that I want to do that without GUI! Like: if _IsPressed( "02", "user32.dll" ) then _Context(..) endif Please help!
  24. (The title of this example was originally "The Shell/Custom Favorites/Programs Menus".) This is an implementation of the Shell Favorites and Programs menus with the IShellMenu interface. The purpose of this menu system is to create a popup menu from a directory structure consisting of subfolders and internet or program links. The menu will look like the Favorites menu in Internet or Windows Explorer (as it looked when XP SP2 was released in August 2004). The IShellMenu interface can generally be used to create a menu from a directory structure. The menu items will be supplied with the same icons as the link files and they will be supplied with tooltips too. When you click a menu item the command associated with the internet or program link will be executed. The Favorites and Programs menus will create popup menus from the directory structures given by $CSIDL_FAVORITES, $CSIDL_PROGRAMS, $CSIDL_STARTMENU, $CSIDL_COMMON_PROGRAMS, $CSIDL_COMMON_STARTMENU. The Custom Favorites and Custom Programs menus can be used to create custom popup menus from custom directory structures. Note that the context (right click) menu is working in the Favorites menu. Update #4 2014-05-03: AutoIt 3.3.10 This example was created under 3.3.8 and based on APIConstants.au3 and WinAPIEx.au3 by Yashied. The original example runs under 3.3.10 without any changes at all. But a lot of unused constants and functions are included. In 3.3.10 the two UDFs are divided into several smaller UDFs. This makes it much easier to just include, what is needed. This update only includes the necessary UDFs. You find the new and old zip in bottom of the post. Update #3 2012-11-06: Programs menus Added the Programs menus from the directory structures given by $CSIDL_PROGRAMS, $CSIDL_STARTMENU, $CSIDL_COMMON_PROGRAMS, $CSIDL_COMMON_STARTMENU. To create a menu like the "All Programs" menu copy the two "Start Menu" folders (your own + "All Users") to the "Custom Programs 1" folder and overwrite the existing "Start Menu" folder. Then select the menu item "Custom Programs | Custom Programs 1". Update #2 2012-11-03: Custom Favorites menus If you are creating an AutoIt program and want to add a custom Favorites menu with relevant internet links all you have to do is to create a directory structure, add the subfolders (optional) and links and call the ShowFavsProgsMenu() function with a path to the directory. And you will get a menu that looks like and works like the Favorites menu in Internet Explorer. You can see two custom Favorites menus in the examples. Added two small directory structures to the zip to be used for the custom Favorites menus. Fixed an error: OleInitialize() is used to initialize COM in stead of CoInitialize() (necessary to make the Copy command in the context menu work). Update #1 2012-11-01: Window procedure Because a popup menu like the Favorites menu is modal, it's necessary to use some kind of a window procedure to catch the menu messages. When it's a popup menu it should be enough to have the window procedure running while the popup menu is displayed. In the original scripts the window procedure was created with these commands: $hNewWinProc = DllCallbackRegister( "NewWindowProc", "int", "hwnd;uint;wparam;lparam" ) ; New window procedure $hOldWinProc = _WinAPI_SetWindowLong( $hGui, $GWL_WNDPROC, DllCallbackGetPtr( $hNewWinProc ) ) ; Old window procedureThe procedure was started in the main script in the example and was running as long as the script was running. In this update the menu messages is catched with a hook procedure: $hFavMenuMsg = DllCallbackRegister( "FavMenuMsg", "long", "int;wparam;lparam" ) $hFavMenuMsgHook = _WinAPI_SetWindowsHookEx( $WH_MSGFILTER, DllCallbackGetPtr( $hFavMenuMsg ), 0, _WinAPI_GetCurrentThreadId() ) ; $WH_MSGFILTER installs a hook procedure that monitors messages generated as a ; result of an input event in a dialog box, message box, menu, or scroll bar.The procedure is started in the bottom of the ShowFavoritesMenu() function immediately after the Favorites menu is displayed on the screen, and the procedure is stopped when the menu disappears from the screen. Either because the menu is cancelled or a selection is made. (If you comment out these commands in ShellFavoritesMenu.au3 the Favorites menu will still show up. But the submenus will not be expanded if you keep the mouse steady over a submenu or use the arrow keys.) This hook procedure is much better than the original window procedure. It's much easier to integrate the Favorites menu in other programs when it isn't depending on a "global" window procedure. A "global" window procedure can also have some influence on the GUI (at least on XP, I think it's better on 7). In the original example you saw it clearly when the GUI lost focus. When the GUI got focus back the upper line of the edit box could be behind the toolbar. This is not a problem with a hook procedure only running when the Favorites menu is displayed. Added an example with a menu. Zip updated. First post 2012-10-30 This is an implementation of the Favorites menu primary with the IShellMenu interface but several other interfaces are used as well. The main function: Func ShowFavoritesMenu( $hWnd, $hMenu, $xCoord, $yCoord ) ; --- Create a menu band object and the IShellMenu interface --- Local $oIShellMenu, $pIShellMenu ; Create a menu band object and get a pointer to the IShellMenu interface CoCreateInstance( $tCLSID_MenuBand, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IShellMenu, $pIShellMenu ) $oIShellMenu = ObjCreateInterface( $pIShellMenu, $sIID_IShellMenu, $dtag_IShellMenu ) If Not IsObj( $oIShellMenu ) Then Return SetError(1,0,0) ; --- Initialize the interface --- If $oIShellMenu.Initialize( $NULL, -1, $ANCESTORDEFAULT, BitOR( $SMINIT_TOPLEVEL, $SMINIT_VERTICAL ) ) <> $S_OK Then Return SetError(2,0,0) ; --- Specify the folder for the menu band to browse --- ; Get a pointer to the IShellFolder interface for the desktop Local $pIShellFolder = $NULL, $oIShellFolderDesktop, $pIShellFolderDesktop, $pidlRel SHGetDesktopFolder( $pIShellFolderDesktop ) SHGetSpecialFolderLocation( $NULL, $CSIDL_FAVORITES, $pidlRel ) $oIShellFolderDesktop = ObjCreateInterface( $pIShellFolderDesktop, $sIID_IShellFolder, $dtag_IShellFolder ) $oIShellFolderDesktop.BindToObject( $pidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) If $pIShellFolder = $NULL Then Return SetError(3,0,0) ; Get the registry key with the "Order" value of the Favorites folder Local $hRegOrder = _WinAPI_RegOpenKey( $HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites", $KEY_READ ) If $hRegOrder = 0 Then Return SetError(4,0,0) ; Specify the folder for the menu band to browse If $oIShellMenu.SetShellFolder( $pIShellFolder, $pidlRel, $hRegOrder, BitOR( $SMSET_BOTTOM, $SMSET_USEBKICONEXTRACTION ) ) <> $S_OK Then Return SetError(5,0,0) _WinAPI_CoTaskMemFree( $pidlRel ) _WinAPI_RegCloseKey( $hRegOrder ) ; --- Append a static menu to the menu band --- If $oIShellMenu.SetMenu( $hMenu, $hWnd, $SMSET_TOP ) <> $S_OK Then Return SetError(6,0,0) ; --- Get access to IMenuPopup, IDeskBar and IDeskBand interfaces --- Local $pIMenuPopup, $pIDeskBar, $pIDeskBand ; The IMenuPopup interface If $pIShellMenu Then If $oIShellMenu.QueryInterface( $tRIID_IMenuPopup, $pIMenuPopup ) <> $S_OK Then Return SetError(7,0,0) EndIf ; The IDeskBar interface If $pIMenuPopup Then Local $oIMenuPopup = ObjCreateInterface( $pIMenuPopup, $sIID_IMenuPopup, $dtag_IMenuPopup ) If $oIMenuPopup.QueryInterface( $tRIID_IDeskBar, $pIDeskBar ) <> $S_OK Then Return SetError(8,0,0) EndIf ; The IDeskBand interface If $pIDeskBar Then Local $oIDeskBar = ObjCreateInterface( $pIDeskBar, $sIID_IDeskBar, $dtag_IDeskBar ) If $oIDeskBar.QueryInterface( $tRIID_IDeskBand, $pIDeskBand ) <> $S_OK Then Return SetError(9,0,0) EndIf ; --- Create a menu desk bar object and the IMenuPopup interface --- Local $oIUnknown, $pIUnknown, $oIMenuPopup, $pIMenuPopup ; Create a menu desk bar object and get a pointer to the IUnknown interface CoCreateInstance( $tCLSID_MenuDeskBar, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IUnknown, $pIUnknown ) $oIUnknown = ObjCreateInterface( $pIUnknown, $sIID_IUnknown, $dtag_IUnknown ) ; Create the IMenuPopup interface $oIUnknown.QueryInterface( $tRIID_IMenuPopup, $pIMenuPopup ) $oIMenuPopup = ObjCreateInterface( $pIMenuPopup, $sIID_IMenuPopup, $dtag_IMenuPopup ) If Not IsObj( $oIMenuPopup ) Then Return SetError(10,0,0) ; --- Create a menu band site object and the IBandSite interface --- Local $oIBandSite, $pIBandSite ; Create a menu band site object and get a pointer to the IBandSite interface CoCreateInstance( $tCLSID_MenuBandSite, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IBandSite, $pIBandSite ) $oIBandSite = ObjCreateInterface( $pIBandSite, $sIID_IBandSite, $dtag_IBandSite ) If Not IsObj( $oIBandSite ) Then Return SetError(11,0,0) ; --- Set the band site object as client for the desk bar object --- If $oIMenuPopup.SetClient( $pIBandSite ) <> $S_OK Then Return SetError(12,0,0) ; --- Add the desk band object to the band site object --- If $oIBandSite.AddBand( $pIDeskBand ) <> $S_OK Then Return SetError(13,0,0) ; --- Show the Favorites menu --- Local $tPOINT = DllStructCreate( $tagPOINT ) DllStructSetData( $tPOINT, "X", $xCoord ) DllStructSetData( $tPOINT, "Y", $yCoord ) Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, "Left", $xCoord ) DllStructSetData( $tRECT, "Top", $yCoord+1 ) DllStructSetData( $tRECT, "Right", $xCoord ) DllStructSetData( $tRECT, "Bottom", $yCoord+1 ) $oIMenuPopup.Popup( $tPOINT, $tRECT, $MPPF_ALIGN_RIGHT ) ; --- Create the IMenuBand interface --- Local $oIDeskBand $oIDeskBand = ObjCreateInterface( $pIDeskBand, $sIID_IDeskBand, $dtag_IDeskBand ) $oIDeskBand.QueryInterface( $tRIID_IMenuBand, $pIMenuBand ) $oIMenuBand = ObjCreateInterface( $pIMenuBand, $sIID_IMenuBand, $dtag_IMenuBand ) If Not IsObj( $oIMenuBand ) Then Return SetError(14,0,0) ; $oIMenuBand and $pIMenuBand are global variables ; $oIMenuBand is used to handle the messages from the Favorites menu in the function below ; $pIMenuBand is used to test if the Favorites menu is open ($pIMenuBand <> $NULL) Return 0 EndFunc Example The zip contains the example as you can see in the picture. There are two versions of the example: A version based on a toolbar (ExShellFavsProgsMenus.au3), and a version based on a menu bar (ExShellFavsProgsMenus2.au3). The purpose of the text box is just to have something to put in the window. The zip contains also the ShellFavsProgsMenus.au3 UDF. This zip contains the original scripts for 3.3.8. You need APIConstants.au3 and WinAPIEx.au3 by Yashied. The UDFs are not included in the zip. The zip can be opened with 7-Zip. ShellFavsProgsMenus.zip This zip contains the updated scripts for 3.3.10. Only a matter of UDFs. These scripts will not run under 3.3.8. TheFavoritesMenu.7z Testet on XP 32 bit and Win 7 32/64 bit.
  25. Hello! So I want a context menu in my bigger program, but I don't really know how to do it realtime so it won't cause program "lag". What i want to do is to select item, and then pops out context menu and then if I select option it will do smt. Please help! Btw I started with this... #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 314, 233, 192, 124) $ListView1 = GUICtrlCreateListView("Test|_Test", 14, 26, 154, 188) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $ListViewArray[100] Local $OptionsArray[100] ;~ Local $contextmenu = GUICtrlCreateContextMenu($ListView1_0) ;~ Local $newsubmenu = GUICtrlCreateMenu("FUN", $contextmenu) ;~ $opt1 = GUICtrlCreateMenuItem("op1", $newsubmenu) For $i = 0 To 6 If $ListViewArray[$i] == "" Then $ListViewArray[$i] = GUICtrlCreateListViewItem( "test" & $i & "|" & "test" & $i * 2, $ListView1 ) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch For $item In $ListViewArray If $item <> "" And GUICtrlRead( GUICtrlRead( $ListView1 ) ) == GUICtrlRead( $item ) Then $contextmenu = GUICtrlCreateContextMenu($item) $submenu = GUICtrlCreateMenu("FUNCS", $contextmenu) $option1 = GUICtrlCreateMenuItem("op1", $submenu) EndIf Next Sleep(10) WEnd
×
×
  • Create New...