Define -Translate -Synonyms of Highlighted using Copilot

Hello all

I want to use AHK to do :
1- explain/define the highlighted terms

2- Translate to Arabic

3- Give Synonyms - Examples of use.

what is wrong in this code

; Example AHK script to achieve the desired functionality
; When Ctrl+F6 is pressed while text is highlighted, a menu pops up with prompts to choose from

^F6::
    ; Get the highlighted text
    Clipboard := ""
    Send ^c
    ClipWait, 1

    ; If text is not empty, show the menu
    if (Clipboard != "")
    {
        Menu, MyMenu, Add, Define/Explain the highlighted term, DefineExplain
        Menu, MyMenu, Add, Translate the highlighted into (Language - Arabic), TranslateArabic
        Menu, MyMenu, Add, Suggest synonyms of the highlighted, Synonyms
        Menu, MyMenu, Show
    }
return

DefineExplain:
    ; Send the prompt to Copilot
	Run, https://copilot.microsoft.com/
    SendInput define/explain the highlighted term
return

TranslateArabic:
    ; Send the prompt to Copilot
	Run, https://copilot.microsoft.com/
    SendInput Translate the highlighted into (Language - Arabic)
return

Synonyms:
    ; Send the prompt to Copilot
	Run, https://copilot.microsoft.com/
    SendInput suggest synonyms of the highlighted with examples of use
return

emoji
Parents
  •  

    what is wrong in this code

    I run your script and I get what I expected.

    I guess you know that:

    • You’d need a Sleep command before the SendInput lines in order to let your browser to open the Copilot web page.Try with Sleep 2000 and then decrease the 2 seconds timer if it’s too high.
    • The appropriate text box to input the prompt should have the focus, so the string after SendInput goes to something meaningful.
    • And finally, you’d need to press an Enter button to actually run the prompt. SendInput {Enter} will make it.

    What do you expect that is not happening?

    emoji
  • Thank you for your reply

    I need the term and the prompt to be written to get the answer from Copilot

    -----------------

    ; Example AHK script to achieve the desired functionality
    ; When Ctrl+F6 is pressed while text is highlighted, a menu pops up with prompts to choose from
    
    ^F6::
        ; Get the highlighted text
        Clipboard := ""
        Send ^c
        ClipWait, 1
    
        ; If text is not empty, show the menu
        if (Clipboard != "")
        {
            Menu, MyMenu, Add, Define/Explain the highlighted term, DefineExplain
            Menu, MyMenu, Add, Translate the highlighted into (Language - Arabic), TranslateArabic
            Menu, MyMenu, Add, Suggest synonyms of the highlighted, Synonyms
            Menu, MyMenu, Show
        }
    return
    
    DefineExplain:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput define and explain the highlighted term
    SendInput {Enter}
    return
    
    TranslateArabic:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput Translate the highlighted into (Language - Arabic)
    SendInput {Enter}
    return
    
    Synonyms:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput suggest synonyms of the highlighted with examples of use
    SendInput {Enter}
    return
    

    emoji
Reply
  • Thank you for your reply

    I need the term and the prompt to be written to get the answer from Copilot

    -----------------

    ; Example AHK script to achieve the desired functionality
    ; When Ctrl+F6 is pressed while text is highlighted, a menu pops up with prompts to choose from
    
    ^F6::
        ; Get the highlighted text
        Clipboard := ""
        Send ^c
        ClipWait, 1
    
        ; If text is not empty, show the menu
        if (Clipboard != "")
        {
            Menu, MyMenu, Add, Define/Explain the highlighted term, DefineExplain
            Menu, MyMenu, Add, Translate the highlighted into (Language - Arabic), TranslateArabic
            Menu, MyMenu, Add, Suggest synonyms of the highlighted, Synonyms
            Menu, MyMenu, Show
        }
    return
    
    DefineExplain:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput define and explain the highlighted term
    SendInput {Enter}
    return
    
    TranslateArabic:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput Translate the highlighted into (Language - Arabic)
    SendInput {Enter}
    return
    
    Synonyms:
        ; Send the prompt to Copilot
    	Run, https://copilot.microsoft.com/
    Sleep 1000
        SendInput suggest synonyms of the highlighted with examples of use
    SendInput {Enter}
    return
    

    emoji
Children