Jump to content
nacerbaaziz

how to get the pressed menu item with out variable

Recommended Posts

nacerbaaziz

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

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
nacerbaaziz

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 by nacerbaaziz

Share this post


Link to post
Share on other sites
nacerbaaziz

Is this possible?
Because I asked someone who said this is impossible in the AUTOIT

Share this post


Link to post
Share on other sites
InnI
#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

 

  • Like 1

Share this post


Link to post
Share on other sites
nacerbaaziz

thank you

but how i can use the WM_COMMAND

Share this post


Link to post
Share on other sites
InnI

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

 

  • Like 1

Share this post


Link to post
Share on other sites
nacerbaaziz

it's work my friend thank you  very much.

 

Share this post


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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      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
       
    • nacerbaaziz
      By nacerbaaziz

      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
    • nacerbaaziz
      By nacerbaaziz
      Detect if the focus item is a button or check box
      Hello everyone.
      My dears I have a problem
      When I try to use
      ControlGetFocus function
      it  doesn't recognize the check  boxes.
      The result is that the selector is a button
      Although the specified is a check box
      but I want a way to identify the check boxes.
      Because I want to make a tool that helps screen readers users
      I hope you have the solution.
      Thank you in advance.
       
    • jesus40
      By jesus40
      Hello friends, i have a working curl command that show informations about my account on binance.com, but_it dont work with autoit code without curl.exe.
      I want to do it without curl, because the whole process much Slower_ with StdoutRead (I want get the response in variable.)
      My Curl command in Autoit:
      This 2 are works, but_ i would like to do it without curl.exe
      $apikey="XYZ" sCommand = @ScriptDir & '\curl.exe -k -H "X-MBX-APIKEY: ' & $apikey & '" -X GET "https://api.binance.com/api/v3/account?' & $request the same in .bat  file
      curl.exe -k -H "X-MBX-APIKEY: XYZ" -X GET "https://api.binance.com/api/v3/account?timestamp=1514917812000&signature=85bdee77e53cd521e1d5229fbfb459d53799c42b3fa4596d73f1520fad5f965a" (I use curl with -k option which allows curl to make insecure connections, because there is problem with the sites certificate, (cURL error 60))
       
      I tried many variations, this is the latest... I cant get the same response.
      curl $error message (I changed ): {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
      autoit version $error message (Response code:400): Mandatory parameter 'timestamp' was not sent, was empty/null, or malformed.
       
      $request = $query & '&signature=' & $signature $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://api.binance.com/api/v3/account", False) $oHTTP.SetRequestHeader("X-MBX-APIKEY", $apikey) $oHTTP.Send($request) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 then MsgBox(4096, "Response code", $oStatusCode) EndIf  
      thanks
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.