Bitten Posted February 15, 2012 Share Posted February 15, 2012 Hi, I have seen several topics regarding this, but none seems to hold the answer im looking for. Please forgive me if i have missed something. Im trying to automate part of a system to handle lookups of customer numbers, i want to automate is in a way so that autoit can accept input in the form of selected text if present, if not it should open a dialog window where the user can input the data to search for. The dialog part is working fine, but i can't seem to find a method for detecting if any text is currently marked. I can't use the clipboard, as this may already contain customer data, thus preventing the dialog from showing. I have no idea if this is at all possible, but im guessing there might be something in windows that knows if anything is marked.. Any feedback or alternative solutions are welcome. Link to comment Share on other sites More sharing options...
KaFu Posted February 15, 2012 Share Posted February 15, 2012 You'll have to provide more info. What type of control are you refering to, containing the potential selection? Use the AU3Info tool to get those infos. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Bitten Posted February 16, 2012 Author Share Posted February 16, 2012 Well the text selection could happen in outlook, chrome, firefox, adobe reader, internet explorer.. or any similar program. I was hoping that some part of windows was aware that something was selected somewhere, and was able to tell me. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 16, 2012 Moderators Share Posted February 16, 2012 Bitten,You can use the clipboard - just save the current content before trying to capture a new highlighted area. Run this script. Put something on the clipboard, highlight another area and then press "q" - you will see the original clipboard content appear in the SciTE console and a MsgBox display the new selection (or telling you there is no selection). Once you have closed the MsgBox, the original clipboard content is restored and displayed: HotKeySet("{ESC}", "On_Exit") HotKeySet("q", "_Check_HighLit") While 1 Sleep(10) WEnd Func _Check_HighLit() ; Save clipboard contents Local $vTemp = ClipGet() ; Display for test ConsoleWrite("Current contents:" & $vTemp & @CRLF & @CRLF) ; See if anything is highlighted by copying it to the clipboard Send("^c") ; Check if there is anything on the clipboard Local $sContent = ClipGet() If $sContent Then MsgBox(0, "HighLit", $sContent) Else MsgBox(0, "Nothing", "Dialog to get user input") EndIf ; Replace previous contents ClipPut($vTemp) ; Display for test ConsoleWrite("Current contents:" & ClipGet() & @CRLF & @CRLF) EndFunc Func On_Exit() Exit EndFuncAny use? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Bitten Posted February 16, 2012 Author Share Posted February 16, 2012 (edited) Hi Melba, Unfortunately, your script wont work, it dosnt take in account that something might already be in the clipboard, and thus, not show the input dialog, or at least thats how its working for me?. I think i may have to make some sort of tracker to track how old the clipboard data is, so it will be able to figure out if its a new selection, or some old stuff. Edited February 16, 2012 by Bitten Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 16, 2012 Moderators Share Posted February 16, 2012 Bitten, Sorry about that oversight - just add a line to clear the clipboard after you have saved the current contents: ; Save clipboard contents Local $vTemp = ClipGet() ; Display for test ConsoleWrite("Current contents:" & $vTemp & @CRLF & @CRLF) ; Empty clipboard ClipPut("") Better now? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Bitten Posted February 16, 2012 Author Share Posted February 16, 2012 You know.. that might actually do the trick! Going to test it as soon as a get a minute. It was a lot simpler than what i was expecting.. Awesome! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 16, 2012 Share Posted February 16, 2012 Would the ControlCommand() function, with the 'GetSelected' command, work here? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Bitten Posted February 21, 2012 Author Share Posted February 21, 2012 Just a small update. The script Melba suggested works perfectly. Thnx a bunch! Link to comment Share on other sites More sharing options...
1RV34 Posted February 21, 2012 Share Posted February 21, 2012 I have always wondered this, if you use Local $vTemp = ClipGet() ClipPut() ClipPut($vTemp) it will work when a string or files were selected, but any other data (like image data) will be lost. Any solutions to keeping the image data? Because ClipGet() won't return it MsgBox(0x40040, "", "Hello Forum!") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 21, 2012 Moderators Share Posted February 21, 2012 1RV34,Take a look at the Clipboard.au3 UDF in the Help file. There are functions there that allow you to retrieve/set the clipboard data in other formats. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ozmike Posted November 21, 2012 Share Posted November 21, 2012 (edited) HiSo that binary data and images won't be lost..when you try to restoreThis UDF will help..you restore the clipboard for ALL formats text / imagesThe clipboard.udf is only half the answer..Func getselected() ; Save clipboard contents Local $aClip _Clipboard_GetAll($aClip) ; Empty clipboard ClipPut("") ; See if anything is highlighted by copying it to the clipboard Send("^c") sleep(100); ; Check if there is anything on the clipboard Local $sContent = ClipGet() ; see if something highlighted... ; restore old clipboard - including binaries _ClipBoard_PutAll($aClip) Return ; EndFunc Edited November 21, 2012 by ozmike Link to comment Share on other sites More sharing options...
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