mistabirdy Posted December 13, 2011 Posted December 13, 2011 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.
water Posted December 13, 2011 Posted December 13, 2011 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 2024-07-28 - Version 1.6.3.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 (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
mistabirdy Posted December 13, 2011 Author Posted December 13, 2011 It can be anywhere. Word, Excel, Web Browser, Texteditor, AutoIt GUI ...
Mikeman27294 Posted December 13, 2011 Posted December 13, 2011 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.
mistabirdy Posted December 14, 2011 Author Posted December 14, 2011 Thank you very much Mikeman!! It's working It's working ... maybe It could have problem if there is a object/image copied in the clip. But I don't care about this
Mikeman27294 Posted December 14, 2011 Posted December 14, 2011 Yeah, that's true. I might be able to think of a way that it might be able to get image URLs, but what sort of objects are you referring to?
somdcomputerguy Posted December 14, 2011 Posted December 14, 2011 You should put some Sleep in the While...WEnd loop, at least 10.., to avoid CPU bashing. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now