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

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
what is wrong in this code
I run your script and I get what I expected.
I guess you know that:
What do you expect that is not happening?
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
I couldn’t see the video in this forum, but I downloaded and watched it in local mode.
First, the 1000 ms timer is too short. The web page is not opened yet when the SedInput commad kicks in. Set the timer parameter of Slepp at least to 4000 and see what happens.
Second, the text box doesn’t have the focus. It works for me if I press SHIFT+TAB 4 times.
Taking this into account, the following script works for me:
DefineExplain:
; Send the prompt to Copilot
Run, https://copilot.microsoft.com/
Sleep 4000 ; needed to let the browswer to open the webpage
SendInput {Shift down} ; Hold the SHIFT key down
Loop 4
{
SendInput {Tab}
Sleep 200
}
SendInput {Shift UP}
; Free the SHIFT key SendInput define/explain the highlighted term
SendInput {Enter} ; to run the prompt
return
Not tested heavily though…
You will need to do the same with TranslateArabic and Synonyms labels.
I couldn’t see the video in this forum, but I downloaded and watched it in local mode.
First, the 1000 ms timer is too short. The web page is not opened yet when the SedInput commad kicks in. Set the timer parameter of Slepp at least to 4000 and see what happens.
Second, the text box doesn’t have the focus. It works for me if I press SHIFT+TAB 4 times.
Taking this into account, the following script works for me:
DefineExplain:
; Send the prompt to Copilot
Run, https://copilot.microsoft.com/
Sleep 4000 ; needed to let the browswer to open the webpage
SendInput {Shift down} ; Hold the SHIFT key down
Loop 4
{
SendInput {Tab}
Sleep 200
}
SendInput {Shift UP}
; Free the SHIFT key SendInput define/explain the highlighted term
SendInput {Enter} ; to run the prompt
return
Not tested heavily though…
You will need to do the same with TranslateArabic and Synonyms labels.
I found Copilot preview in the Tray
could you please modify the code to launch Copilot Preview instead of the Browser
could you please modify the code to launch Copilot Preview instead of the Broweser
I’m sorry, I don’t use Copilot and I don’t know how to open it from the Tray.