Jump to content

HotKey with Marked Text as Arguments


Recommended Posts

Hello Community,

I like to mark a text and press a hotkey than one programm/script should be called and give this programm/script the marked text as argument to do something.

How can I realise this?

Creating Hotkey is not a problem. I can even create a normal windows shortcut and assign a hotkey.

The question is, how to pass the marked text as an argument.

Link to comment
Share on other sites

Where do you mark the text? In a GUI you created with the AutoIt script, in an Office application (word, excel ...), in a browser ..?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What I would do (probably not the best way to do it tho) would be like this:

HotKeySet("^q", "_HotkeyPressed") ;The hotkey is CTRL+Q and the function name is "_HotkeyPressed"
While 1 ;Just an infinite loop until the program exits
WEnd
Func _HotkeyPressed()
    $PreviousClipboard = ClipGet();Used to prevent data loss when running the function
    Send("^c")
    $Argument = ClipGet()
    Switch $Argument ;We are using a switch here because the variable we compare to will always be the same
        Case "Argument1" ;If the selected text was argument 1
            MsgBox(0,"",'Selected text was "Argument1"')
        Case "Argument2" ;If the selected text was argument 2
            MsgBox(0,"",'Selected text was "Argument2"')
        Case "Exit"
            MsgBox(0,"","The program will now exit")
            Exit
        Case Else ;If the selected text was not covered by any of the previous case expressions
            MsgBox(0,"",'Selected text was "' & $Argument & '"')
    EndSwitch
    ClipPut($PreviousClipboard);Ensures that the user doesnt lose any data on their clipboard
    Return
EndFunc

I haven't tested this but there isn't a doubt in my mind as to whether it will work or not.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...