nacerbaaziz Posted August 6, 2017 Share Posted August 6, 2017 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 7, 2017 Moderators Share Posted August 7, 2017 An example of what you want would be great, as I believe there is a language barrier issue. Please provide an example/screenshot that shows exactly what you're after. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nacerbaaziz Posted August 7, 2017 Author Share Posted August 7, 2017 (edited) OK this is an example i want when i pressed ani item from the favourites menu the script run the path #RequireAdmin #include <GUIConstantsEx.au3> #include <file.au3> local $hGUI, $menu, $file, $path, $msg $hGUI = GUICreate("menu item") $menu = GUICtrlCreateMenu("Favourites") GUISetState() $file = @scriptDir & "\file.txt" ;Writing file FileWrite($file, @systemDir & "\notepad.exe" & @crlf) FileWrite($file, @systemDir & "\explorer.exe" & @crlf) FileWrite($file, @systemDir & "\regedit.exe") ; add item to menu for $i = 1 to _FileCountLines($file) $add = GUICtrlCreateMenuItem(FileReadLine($file, $i), $menu) next FileDelete($file) While 1 Switch GUIGetMSG() case $GUI_event_close exit EndSwitch Wend Edited August 7, 2017 by nacerbaaziz Link to comment Share on other sites More sharing options...
nacerbaaziz Posted August 7, 2017 Author Share Posted August 7, 2017 Is this possible? Because I asked someone who said this is impossible in the AUTOIT Link to comment Share on other sites More sharing options...
InnI Posted August 8, 2017 Share Posted August 8, 2017 expandcollapse popup#RequireAdmin #include <GuiMenu.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <file.au3> Local $hGUI, $menu, $file $hGUI = GUICreate("menu item") $menu = GUICtrlCreateMenu("Favourites") GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $file = @ScriptDir & "\file.txt" ;Writing file FileWrite($file, @WindowsDir & "\notepad.exe" & @CRLF) FileWrite($file, @WindowsDir & "\explorer.exe" & @CRLF) FileWrite($file, @WindowsDir & "\regedit.exe") ; add item to menu For $i = 1 To _FileCountLines($file) GUICtrlCreateMenuItem(FileReadLine($file, $i), $menu) Next FileDelete($file) While 1 Switch GUIGetMsg() Case $GUI_event_close Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $item = _GUICtrlMenu_GetItemSubMenu(_GUICtrlMenu_GetMenu($hGUI), 0) Run(_GUICtrlMenu_GetItemText($item, _GUICtrlMenu_MenuItemFromPoint($hGUI, $item))) Return $GUI_RUNDEFMSG EndFunc nacerbaaziz 1 Link to comment Share on other sites More sharing options...
nacerbaaziz Posted August 8, 2017 Author Share Posted August 8, 2017 thank you but how i can use the WM_COMMAND Link to comment Share on other sites More sharing options...
InnI Posted August 8, 2017 Share Posted August 8, 2017 If you don't know how wm_command works then use native message loop #RequireAdmin #include <GUIConstantsEx.au3> #include <file.au3> Local $hGUI, $menu, $file, $item[3] $hGUI = GUICreate("menu item") $menu = GUICtrlCreateMenu("Favourites") GUISetState() $file = @ScriptDir & "\file.txt" ;Writing file FileWrite($file, @WindowsDir & "\notepad.exe" & @CRLF) FileWrite($file, @WindowsDir & "\explorer.exe" & @CRLF) FileWrite($file, @WindowsDir & "\regedit.exe") ; add item to menu For $i = 1 To _FileCountLines($file) $item[$i - 1] = GUICtrlCreateMenuItem(FileReadLine($file, $i), $menu) Next FileDelete($file) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_event_close Exit Case $item[0] To $item[2] Run(GUICtrlRead($msg, 1)) EndSwitch WEnd nacerbaaziz 1 Link to comment Share on other sites More sharing options...
nacerbaaziz Posted August 8, 2017 Author Share Posted August 8, 2017 it's work my friend thank you very much. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now