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?
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 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.
I discovered a better way to do something very similar, but it uses OpenAI (via the API), instead of Copilot. It's AHK, so very easy to add custom prompts. You can basically create prompts to do anything you can imagine, and the results are instantaneously pasted at your cursor. I wrote a short article about it @ https://beijer.uk/blog/two-autohotkey-scripts-to-select-amp-process-text-with-the-chatgpt-api .
I also made a quick screencast: app.screencast.com/R9t6kwyrl5225
Thanks for sharing that Michael... very cool. Good that it uses V2 as well as I'm already having problems trying to convert every script I ever had from V1. Didn't expect it to be that hard, but it is when you're not a developer!
Paul Filkin | RWS Group
________________________
Design your own training!
You've done the courses and still need to go a little further, or still not clear?
Tell us what you need in our Community Solutions Hub
Michael Beijer
Thank you very much for sharing your Bot
I found this
https://github.com/ecornell/ai-tools-ahk/releases
AI Tools - AutoHotkey - Enable global hotkeys to run custom OpenAI prompts on text in any window.
The default hotkeys and prompts are set to the following:
Ctrl+Shift+j
- (Auto-select text - Fix spelling) - Auto selects the current line or paragraph and runs the "Fix Spelling" prompt and replaces it with the corrected version.
Ctrl+Shift+k
- (Auto-select text - Prompt Menu) - Auto selects the current line or paragraph and opens the prompt menu.
Ctrl+Alt+Shift+k
- (Manual-select text - Prompt Menu) - Opens the prompt menu to pick the prompt to run on the selected text.
Best
I've found various LLMs (especially Claude-3.5-Sonnet) are actually pretty good at converting AHK v1 to v2!
Cool, thanks for the tip. Yes, there are many of these little tools now (on GitHub), often based on AutoHotkey, which allow you to do some pretty amazing things via the OpenAI API.