1

I would like to select text, press a hotkey to trigger an application open, paste the selected text into the newly opened application. In my case, my application is called everything, a file locator on windows. It was stored under D drive, and updated to the latest version.

Here is my code:

#f::
{
    A_Clipboard := ""
    ; Copy selected text to clipboard
    Send "^c"
    ClipWait ; Wait for 2 seconds for clipboard to contain text
    SetTitleMatchMode 2
    
    if WinExist("*everything*")
        {
        WinActivate 
        MsgBox "Everything was found."
        }
        ; Use the window found by WinExist.
    else {
        Run "D:\Downloads\everything\Everything.exe"
        Sleep 1000  
        SendInput A_Clipboard
        Send "^v"
        MsgBox "Everything was not found."
        }    
}

This script copies the selected text, opens the application. The problem is that it does not paste the selected text into Everything.

If I press ctrl+V manually, the selected text will paste into the search window in Everything. WinExist can not find Everything, I tested with a message box. The winTitle of Everything is "everything.exe".

Please help. Thank you.

0

1 Answer 1

0

Try it this way:

#Requires AutoHotkey v2.0

#f::
{ 
    A_Clipboard := ""
    ; Copy selected text to clipboard
    Send "^c"
    if !ClipWait(2)
    {
        MsgBox "The attempt to copy text onto the clipboard failed."
        return
    }   
    Run "D:\Downloads\everything\Everything.exe" " -s `"" A_Clipboard "`""
}
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, When I select multiple words (like an article title) to search, I would run into a pop-up box by Everything. It states "Unable to open the file list: D:\Downloads\AutoHotKey\scripts(the first word of the selected words) is not a valid file list. And in the search window, only the first word was pasted.
Strategies to maintain skeletal muscle mass in the injured athlete Nutritional considerations and exercise mimetics. It is just an example. Any multiple words will yield the pop-up box by Everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.