Jump to content

Search the Community

Showing results for tags 'Clipboard'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

  1. Programs like Ditto are a great augmentation to the Windows clipboard where it keeps a list of items you copy and paste and you can go back to days, weeks, months later. It also comes in handy for multiple copied items you need to paste over and over again. https://sourceforge.net/projects/ditto-cp/ Windows 10 also now has a clipboard history capability (though not as robust, I think, as Ditto). https://www.windowscentral.com/how-use-new-clipboard-windows-10-october-2018-update I would like to simulate this type of clipboard history into my own apps independent of Windows' clipboard, but I haven't a clue as to where to begin. Thank you in advance for any suggestions, examples, shelved codes. ☺
  2. Hello. I have designed and created a simple Clipboard manager in AutoIt. The project is open for any ideas, I hope you found it useful (and if you did please like my post so I can continue making software). Features [Done] Can store data in up to 5 slots. [Done] Options form. [Done] System Tray menu. [Done] Supports Hot-keys when pasting/copying data. [Done] Ability to copy and store text. [Done] Clipper theme. [Coming soon] Ability to copy and store files and folders. [Coming soon] Clipboard history form. ( currently logs history into a text file ) And Much Much More! Source Conclusion If you find any bugs or you have any ideas you are free to leave them here. Please give this script a try because it took time. If you enjoyed this script PLEASE smash the like button, Thanks! ALSO: Have any script ideas? Please share them with me because I will make them! Clipper.au3
  3. _ClipPutHTML Okay, since I created the _ClipPutHyperlink() function, I figured I might as well just go one step further and open up the whole HTML Clipboard send/put interface and make it really simple to use - not only for simple Hyperlinks, but also for complete pieces of HTML code as well. Note that 'PlainText' is the optional view of your HTML code that should be free of formatting. This is helpful when pasting to applications that don't accept HTML formatted strings, such as Notepad. Note also that the HTML code NEEDS to be encoded in UTF-8 format. (For straight-ANSI/ASCII code, you don't need to do anything, UTF-8 encoding only comes into play for Unicode formatting). Anyway, bundled in the ZIP is the UDF and a short example (same as the below HTMLPut Example). Additionally, see the sample code for _ClipGetHTML(). Example 1: HyperlinkPut: ; Special Unicode text call _ClipPutHyperlink("http://www.google.co.jp/",ChrW(0x30B0)& ChrW(0x30FC)& ChrW(0x30B0)& ChrW(0x30EB)& " (Japanese Google)") ; Regular text _ClipPutHyperlink("http://www.google.com","Google")- Example 'paste' Output - Unicode Hyperlink: グーグル (Japanese Google) Regular Hyperlink: Google Example 2: HTMLPut - Example 'paste' output - Headline TextThis is a paragraph showing the formatting possibilities using the _ClipPutHTML() functions. The regular modifiders, such as bold, italics, and underlines work as usual, just like all other HTML formatting. Here's an example list: List item #1.List item #2.List item #3 with a Hyperlink Get the Code at my Site Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I credit If the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1) The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to. Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
  4. hello autoit group please i've a question i had make a function that put some thing into the clipBoard and paste it using the send function e.g ClipPut("hello") send("^v") when the keyboard is english all things work fine but when the keyboard is arabic the send command write the ltr v insted of the text in clipboard i was tryed to use send("{ctrldown}v{ctrlUp}") but the same please can any one help me
  5. Hi, from other postings here as a start I'm quite Close to my Goal of putting formatted text to the clipboard: #include-once #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Global $g_idLblMsg, $g_hRichEdit Example("The first text will be formatted ""as is""" & @CRLF & _ "(Default Font and font size)", "This text is formatted differently") MsgBox(0, "Rich Text copied", "Formatted Text put to clipboard") Func Example($TextDefault, $TextCourier) Local $hGui, $iMsg, $idBtnNext, $iStep = 0 $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, $TextDefault, 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60) GUISetState(@SW_SHOW) _GUICtrlRichEdit_SetSel($g_hRichEdit, -1, -1) ; set selection behind last CHAR in RTF_EDIT _GUICtrlRichEdit_SetFont($g_hRichEdit, 8, "Courier New") ; change font to 8pt, Courier New _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & $TextCourier) _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, -1) ; select all the content of the RTF_EDIT _GUICtrlRichEdit_Copy($g_hRichEdit) ; put the selection to the clipboard EndFunc ;==>Example Finally the clipboard content has to hold pre-formatted data to be pasted into an email body. for the 2nd part I'd like to add a frame around the text, like I did manually before taking this screenshot. Any suggestions, or maybe some absolutely different Approach? CU, Rudi.
  6. I'm creating a tool which automatically saves screenshots. I've found that some images appear corrupt after saving. I've narrowed the source down to screenshots taken from within an RDP session via the Ctrl+Alt+Plus (PrtScn equivalent) and Ctrl+Alt+Minus (Alt+PrtScn equivalent) key combos. Here is the example code: #include <ClipBoard.au3> #include <GDIPlus.au3> If _ClipBoard_IsFormatAvailable($CF_BITMAP) Then ConsoleWrite("+Bitmap found on Clipboard" & @CRLF) If Not _ClipBoard_Open(0) Then MsgBox(16, "Error", "_ClipBoard_Open failed") Exit EndIf $hClipboardImage = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hClipboardImage) $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") _GDIPlus_ImageSaveToFileEx($hBitmap, @ScriptDir & "\" & TimerInit() & "_Clipboard_Image.jpg", $sCLSID, 0) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Else MsgBox(48, @ScriptName, "No Bitmap found on Clipboard") EndIf If you copy a local window to the clipboard via Alt+PrtScn the above works fine. If you copy a window in an RDP session via Ctrl+Alt+Minus it saves the image, but the left-hand edge appears to contain a few pixels sliced off the right-hand side of the bitmap (see two attached images for examples; one good, one bad). If you paste directly into MSPaint, the image appears correctly, so the clipboard contents is good. It seems to be the process of converting the bitmap handle to an image file via GDIPlus which corrupts it (though I may be wrong about this). I've tried inspecting the contents of the clipboard via the _ClipBoard_EnumFormats example and I've noticed the clipboard from the RDP session contains a couple more formats; Local: Clipboard formats ..: 3 Clipboard format 1 .: Bitmap Clipboard format 2 .: DIB Clipboard format 3 .: DIB V5 RDP: Clipboard formats ..: 5 Clipboard format 1 .: DataObject Clipboard format 2 .: DIB Clipboard format 3 .: DIB V5 Clipboard format 4 .: Ole Private Data Clipboard format 5 .: Bitmap However the _ClipBoard_GetDataEx function is specifying the $CF_BITMAP constant for the format, which both instances contain, so I'm not sure the extra formats have any impact? I've tried using a combination of _ClipBoard_GetDataEx($CF_DIB) and _GDIPlus_BitmapCreateFromMemory in an effort to write the binary directly to a file, instead of using a bitmap handle, however this doesn't appear to work and just returns a zero and doesn't set @error to anything, which isn't covered in the help file (a failure should return a zero and set the @error level to something). I've hunted around the forums and tried everything I can think of. I can normally figure most things out without posting but I've been dipping in and out of this script for a few months now and have finally thrown in the towel and must ask you guys for help, which isn't a decision I take lightly. Your help is, as always, greatly appreciated.
  7. I want to copy just the selected text in an input control and put it to the clipboard, but GuiCtrlRead() always reads all of the text in the control. In this test code, when I highlight a portion of the left control's text and press ^C, I want to copy just that text to the clipboard; but when I highlight a portion of the right control's text and press ^C, I want to copy all of its text to the clipboard. #include <Debug.au3> _DebugSetup(@ScriptName & "_debug.txt", False, 2, "") _DebugOut("=============== " & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & " ====================") #include <GUIConstants.au3> #include <WinAPI.au3> #include <Array.au3> Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Set OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("Event_GUIClose") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $hWnd_MainWin, $iID_Left, $iID_Right _Main() Func _Main() $hWnd_MainWin = GUICreate("test7", 200, 300) $iID_Left = GUICtrlCreateInput("AAA BBB CCC (get Selected text)", 10, 30, 200, 25) GUICtrlSetOnEvent($iID_Left, "handle_left_btn") $iID_Right = GUICtrlCreateInput("DDD EEE FFF (get All text)", 10, 60, 200, 25) GUICtrlSetOnEvent($iID_Right, "handle_right_btn") Local $aAccelKeys[1][2] = [["^c", $hWnd_MainWin]] GUISetAccelerators($aAccelKeys) GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') GUISetState() ; Make everything visible While 1 Sleep(127) WEnd EndFunc ;==>_Main Func handle_CTRL_C_key() ConsoleWrite("+++: handle_CTRL_C_key() entered" & @CRLF) Local $hCtrl, $ctrlID, $control_classname, $text $control_classname = ControlGetFocus($hWnd_MainWin) $hCtrl = ControlGetHandle($hWnd_MainWin, "", $control_classname) $ctrlID = _WinAPI_GetDlgCtrlID($hCtrl) If ($ctrlID = $iID_Left) Then $text = GUICtrlRead($ctrlID) ClipPut($text) ConsoleWrite("+++: Copied selected text:" & @CRLF & "==>" & $text & "<==" & @CRLF) ElseIf ($ctrlID = $iID_Right) Then $text = GUICtrlRead($ctrlID) ClipPut($text) ConsoleWrite("+++: Copied all text:" & @CRLF & "==>" & $text & "<==" & @CRLF) EndIf EndFunc ;==>handle_CTRL_C_key Func Event_GUIClose() Exit (99) EndFunc ;==>Event_GUIClose Func handle_left_btn() ConsoleWrite("+++: handle_left_btn() entered" & @CRLF) EndFunc ;==>handle_left_btn Func handle_right_btn() ConsoleWrite("+++: handle_right_btn() entered" & @CRLF) EndFunc ;==>handle_right_btn
  8. i want to copy a picture file to clipboard, so that i can paste the picture through ctrl+V this is my code ,but it dosen't work : #AutoIt3Wrapper_UseX64 = n #Include <Clipboard.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\1.jpg') _ClipBoard_Open(0) _ClipBoard_SetDataEx($hClipboard_Bitmap,$CF_BITMAP) _ClipBoard_Close() _GDIPlus_Shutdown() can you help me
  9. Hello. I fail trying to save content from WhatsApp other then plain text to a file that way, that non-char-content will be preserved in it's correct encoding. e.g. Emojis are spoiled. I've tried to do so using just filewrite() as well as forcing UTF #include <clipboard.au3> MsgBox(0,"Ready to read clipboard","Mark some WhatsApp content with non-char elements, e.g. Emojis, copy that to your clipboard (CTRL+c), then click OK here.") $ClipContent=_ClipBoard_GetData() ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ClipContent = ' & $ClipContent & @CRLF & '>Error code: ' & @error & @CRLF & "Extended: " & @extended & @CRLF) ;### Debug Console $File="C:\temp\ClipSaveToFile.txt" $h=FileOpen($File,2+8+64) ; overwrite, create path, UTF16 FileWrite($h,$ClipContent) FileClose($h) $h=FileOpen($File,64) $NeuGelesen=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $NeuGelesen = ' & $NeuGelesen & @CRLF & '>Error code: ' & @error & @CRLF & StringLen ($NeuGelesen) & @CRLF ) ;### Debug Console FileClose($h) _ClipBoard_SetData($NeuGelesen) MsgBox(0,"Done","Re-read content of TEMP file was placed to the clipboard. Now paste this into WhatsApp. (Emojis will be spoiled)") I've also tried other encodings (16, 32, 64, 512) Or what is a different, functional approach to save WhatsApp Content to File in a way, to be able to to get it back to post it back to WhatsApp? Regards, Rudi.
  10. Hello to you, dear developers! Could you please tell me if there is an easy way to determine if the information was pasted from the clipboard? Without any variation of the insertion via Ctrl+V, or through the context menu. I revised the Help and many forum topics, but found nothing suitable. Can there be any WinAPI system events that determine this event?
  11. Its possible to past previously copied text to somewhere with autoit script ? If yes, How it ? example : Before I copied ABCD and then copied the PQRS, how to past the previously copied ABCD ?
  12. I seem to have an issue with clipget() - the following bit of code copy URL from chrome address bar - than using clipget() i try to grab the URL into a variable and input it into a spreadsheet. the script did not put anything into the sheet originally I though it was an issue with OOo/LibO Calc UDF and posted it there : than I tried writing $NewURL into a text file and than just a msgbox but it comes blank. (the URL is in the clipboard as i can paste it) send ("!d") ;select URL in browser send ("^c") ;copy selected URL Local $NewURL = ClipGet() MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, $sTitle, $NewURL ) am I doing something wrong? is there an issue with a URL characters?
  13. Here's a short UDF that will, at least in most cases, detect whether a window can be copied from or pasted to programmatically--for example, by Send()ing ctl-c, ctl-v. This is often disabled when programs (like your AutoIt script) run at a lower UAC integrity level than the application they are trying to operate on. #include <WinAPI.au3> Func _WindowIsPasteable($handle) ;accepts window handle; returns true or false whether a window will accept Ctl-C, Ctl-V Local $bCanPaste = True Local $hTestWindowPID = 0 Local $hTestWindowTID = _WinAPI_GetWindowThreadProcessId($handle, $hTestWindowPID) _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId(), $hTestWindowTID, True);attach to window we want to paste into $bCanPaste = _WinAPI_GetFocus() ;Test whether window is paste-able--returns False if it is not _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId, $hTestWindowTID, False);detach from window thread Return $bCanPaste EndFunc Pass it a window handle; it returns true or false whether a window will accept programmatic pasting. The function may not work on the CMD window, since it handles the clipboard uniquely. This function works by attaching to the program thread of the window whose handle it receives, then attempting to perform a GetFocus on that thread. In most cases, the attempt will fail if the window will not accept programmatic copy-paste.
  14. Hey I have a GUI with an edit-field and a button. First I write some text into the edit-field and select a part of it. After that I press the button, and the selection is edited. How would I do that, though? When the text is selected and I press the button, it's unselected before the button actually raises an event.
  15. Hello Guys, I am trying to make a screenshoot copy it to clipboard and paste it into a word document i want to do that to simplify my procedures création. I am trying to use the way of sending Keys "^c" & "^v" i tryed also CTRLDOWN and c but no one of these is working. First question : Why that's not working? Is there anyother way i can work with ? I watched the help file for FileCopy but it s only moving Files and not copy them. Maybe you can see somthing going wrong in my script but i guess it s not a syntax problem. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ScreenCapture.au3> #include <MsgBoxConstants.au3> HotKeySet("{F2}", "Capture") HotKeySet("{F3}", "Windows") HotKeySet("{F4}", "Copy") Global $Numero = 0 Attendre () Capture() Func Capture() ; Capture full screen $Numero = $Numero+1 _ScreenCapture_Capture (@DesktopDir & "\ScreenCapture\Image"&$Numero&".jpg") ShellExecute( @DesktopDir &"\ScreenCapture\Image"&$Numero&".jpg") Sleep (500) Run("C:\WINDOWS\EXPLORER.EXE /Select, /n,/e," & @DesktopDir & "\ScreenCapture\Image"&$Numero&".jpg" ) WinWaitActive("ScreenCapture") Sleep(1500) Send("^c") ;~ Send ("{CTRLDOWN}") ;~ Sleep(10) ;~ Send ("C") ;~ Sleep(10) ;~ Send ("{CTRLUP}") EndFunc ;==>Example Func Windows () Global $Windows = WinGetTitle("[active]") MsgBox($MB_SYSTEMMODAL, "Windows", "Windows selected for copy is : "&@CRLF&$Windows) EndFunc Func Copy () WinActivate (""&$Windows) Sleep (100) Send("^v") ;~ Send ("{CTRLDOWN}") ;~ Sleep(10) ;~ Send ("V") ;~ Sleep(10) ;~ Send ("{CTRLUP}") EndFunc Func Attendre () While 1 Sleep (10) ;~ GUICreate ("Help",100,100) WEnd EndFunc
  16. Hi All I have used my script to paste a string ($TestCSVGenerator) onto the clipboard - it has text seperated by tabs and at certain intervals there are CRLF. I am certain that this is a valid string because after I run my script (and it fails to do what I need) I can then manually 'Paste' the string into Excel using CTRL v and Excel puts the text in rows separated by the tab position and starts a new row of cells after a CRLF. (I make sure that the clipboard was empty before running my program). All I need is a command that pastes the string into a certain cell and in theory the above should happen but it doesn't! First I tried the following: _Excel_RangeWrite ($oWorkbook, 1, $TestCSVGenerator, "C18", False, True) This pastes, but everything goes in one cell! I've tried all the combinations of True/false Next I tried: _Excel_RangeCopyPaste($oWorkbook.ActiveSheet, Default, "C18") This pastes nothing at all (gives @error =4 ), if I define a range of cells Excel does highlight them. Any ideas or alternative methods? I guess I could paste the text painfully cell by cell but Excel seems to understand what I have on the clipboard if I paste it manually - it's the automation that is flooring me! Cheers James
  17. Hi all, I am playing with this code. My aim is to get the data created by an autoit exe from vb.net. But i think this is not the safest method. Look at this code. And suggest me some better ideas. This is my autoit code #include <Clipboard.au3> _ClipBoard_Open (Null) _ClipBoard_Empty ( ) Local $s_path = "F:\MyFolder\Myfile.ini" Local $s_val = IniRead($s_path,"Mysection","Mykey","def") _ClipBoard_SetData($s_val, 1) _ClipBoard_Close ( ) ExitI have compile this autoit file as MyEXE.exe And this is my vb.net code Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim text As String Process.Start("C:\Users\Vinod\Desktop\MyEXE.exe") text = Clipboard.GetText(TextDataFormat.Text) Label1.Text = text End SubThis is working, but if we copy something just before the button click, then we didn't get the proper value. So i am seeking any better ideas.
  18. Hello I am trying to store the last 5 clipboard contents to a array. When i run my code, autoit is jumping in front of the system control +c and it is not copying anything to the clipboard. I am stumped, any ideas? Global $x=0 Global $arr[5] HotKeySet("^c","_stepper") #cs******************************************************************************************************* ////////////////////////////////////////////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ #ce******************************************************************************************************* func _stepper() MsgBox(0, "Just message", "stepper is called") $arr[$x]=ClipGet() $x=$x+1 if $x=5 then $x=0 MsgBox(0, "Just message",$x) EndFunc #cs******************************************************************************************************* ////////////////////////////////////////////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ #ce******************************************************************************************************* While 1 Sleep(500) WEnd
  19. Hi Here is a UDF which allows you to have more than 1 item in the Clipboard and handle binaries not just text!. Can handle ALL data types text or images or binaries HTML yada yada. Gives autoIT functionality that potentially AHK can do , multiple paste buffers ClipboardEx.UDF - ; Clipboard 'Extended' creates a memory copy of current clipboard, and adds meta data like size and type sense. Credits to J Rowes for some of this code. ClipboardHistory.UDF: Simple LIFO History. ClipBoardHistoryGUI.UDF : Clipboard History viewer for history - can view items in history (mouse over) use mouse click to select an ltem and put on clipboard. Any files with the word 'example' in the name will run. Enjoy Ok version 2 - works on autoIT v 3.12. w7 added another example file. ClipboardHistoryV2.zip
  20. If you need to generate text data, this tool is for you. If you are gathering data from multiple sources and filtering it, or sorting it, this tool is for you. Generating text data manually can be time-consuming and mind-numbing. To ease my pain in this endeavour, I created this tool. I allows you to: - Gather data from multiple sources without having to paste it again and again in some editor before anything can be done to it. A user-defined string separator is used to separate the appended clipboard entries into records. - Or take a single line of formatted data and multiplying it by hundreds, then incrementing its lead field. Typical use: copy a line such as 2015/03/23 data 1 This is a test And this is a value where tabs separate data fields, for example. Then after generating a clipboard buffer where the line is repeated 10 times, and then incrementing it, the date at the start is detected and the day/month/year date value is correctly incremented This value is the output, and it is then placed into the clipboard: 2015/03/23 data 1 This is a test And this is a value 2015/03/24 data 1 This is a test And this is a value 2015/03/25 data 1 This is a test And this is a value 2015/03/26 data 1 This is a test And this is a value 2015/03/27 data 1 This is a test And this is a value 2015/03/28 data 1 This is a test And this is a value 2015/03/29 data 1 This is a test And this is a value 2015/03/30 data 1 This is a test And this is a value 2015/03/31 data 1 This is a test And this is a value 2015/04/01 data 1 This is a test And this is a value - Or if you are tring to filter records, enter a list of strings to find in the clipboard buffer and only keep the records that contain one of the find strings, or only keep the records that don't have one of the find strings This tool runs in the background and allows copying information that is scattered in documents or web pages etc to the clipboard by appending to what is already in the clipboard. To make the updated clipboard buffer more usable and separate records, a separator is used. The default separator is CRLF, but it can be changed to any user text string including CR or LF. Using the clipboard separator, records can be sorted as text up and down before pasting them, or you can copy a list and sort it in the clipboard before pasting it back sorted. Use hotkeys ctrl-alt-c to copy-append, ctrl-alt-x to cut-append, ctrl-alt-f to parse the clipboard text contents, and only keep the records that contain a find string ctrl alt d, prompt for find string, then find records in clipboard that contain the string and remove them only keeping other records in clipboard ctrl alt h, prompt for a find and a replace string, replace and update the clipboard ctrl-alt-r to run the current text selection as a command, ctrl-alt-F1 to display the list of commands, ctrl-alt-arrow up or down to sort up or down the entries, ctrl-alt-s to bring up the setup dialog, to set the separator, and other values. ctrl-alt-q to quit. There are a few more commands that I use to easily generate large amounts of testing data. ctrl-alt-g copies what is selected and prompts the user for the number of times the selection should be repeated. Then if each record starts with a number, or a date with format yyyy/mm/dd, or time, ctrl-alt-i increments the numeric or date or time value for each record. If these ctrl-alt keys are not convenient, you can change them in the first 8 HotKeySet statements of the code to fit what you need. This works fine for me on my windows 7 64 bit machines. If you find that you have problems on a different platform, please share your fixes. Enjoy, and please share your improvements. #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> #include <Date.au3> Local $sClipSeparator = @CRLF ; some apps at times misbehave and hog the clipboard for a while, they are supposed to release it and may take their time before they release it, if ever... Local $dNumberOfRetries = 3 ; number of times to try again in case it's needed Local $dWaitTimeMilliSec = 200 ; how long to wait between tries, in milliseconds Local $IncrementValue = 1 Local $Version = "1.01" ; if you change the key assignments below, you may want to also modify the Help() function accordingly HotKeySet("^!c", "CopyAppend") ; ctrl alt c, copy append HotKeySet("^!f", "FilterInClpRecords") ; ctrl alt f, prompt for find string, then find records in clipboard that contain the string and remove other records from clipboard HotKeySet("^!d", "FilterOutClpRecords") ; ctrl alt d, prompt for find string, then find records in clipboard that contain the string and remove them only keeping other records in clipboard HotKeySet("^!h", "ReplaceInClpRecords") ; ctrl alt h, prompt for a find and a replace string, replace and update the clipboard HotKeySet("^!x", "CutAppend") ; ctrl alt x, cut append HotKeySet("^!r", "RunSelection") ; ctrl alt r, run selection as command line HotKeySet("^!s", "ClipAppendSetup") ; ctrl alt s HotKeySet("^!q", "QuitClipAppend") ; ctrl alt q HotKeySet("!^{UP}", "SortAscending") ; ctrl alt up HotKeySet("!^{DOWN}", "SortDescending") ; ctrl alt down HotKeySet("!^{F1}", "Help") ; ctrl alt F1 ; This reads the current text selection, then prompts for number of needed lines in output buffer. HotKeySet("^!g", "GenerateListFromSelection") ; If the ctrl alt g list is numeric or date time or starts with a number or date time, ctrl alt i uses the setup increment or decrement value to increment or decrement each buffer entry HotKeySet("^!i", "InOrDecrementSelection") ; ctrl alt i, looks at record starts, if it is date or numeric and of consistent length, updates that prefix to increase or decrease with each record ReadSettings() ; The loop that will go on and on while the app is running, between sleeps autoit checks to see if a hotkey from statements above was called from the keyboard while 1 Sleep(100) WEnd ;=========Functions called by hot keys=============== Func ClipAppendSetup() ; Run the clipAppend setup GUI Local $listValue Local $LocalSep Local $boolSepIsLitt = False Local $frmSetup = GUICreate("Append to Clipboard, setup", 530, 220, 50, 5) GUISetBkColor(0x005555, $frmSetup) WinSetTrans($frmSetup, "", 230) ;set transparency level to 200 (0=invisible, 255=opaque) GUICtrlCreateGroup("Clipboard Separator", 5, 5, 520, 110) Local $rbLiteral = GUICtrlCreateRadio("Enter a custom separator string:",20, 20) Local $rbNonLiteral = GUICtrlCreateRadio("Select a non-literal separator string:",20, 40) Local $lbSeps = GUICtrlCreateList("", 210, 50,300, 60) Local $edit = GUICtrlCreateEdit("", 210, 20, 300, 25, $ES_AUTOHSCROLL) Local $CurrentListSelection Local $bSelectionIsCustom = False Switch($sClipSeparator) case @CR $CurrentListSelection = "CR" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case @LF $CurrentListSelection = "LF" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case @CRLF $CurrentListSelection = "CRLF" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case Else $bSelectionIsCustom = True GUICtrlSetState($rbLiteral, $GUI_CHECKED) EndSwitch if $bSelectionIsCustom Then GUICtrlSetState($lbSeps, $GUI_DISABLE) Else GUICtrlSetState($edit, $GUI_DISABLE) GUICtrlSetData($lbSeps, "CR|LF|CRLF", $CurrentListSelection) EndIf Local $lblTries = GUICtrlCreateLabel("Number of tries:", 20, 125) Local $cboTries = GUICtrlCreateCombo($dNumberOfRetries, 110, 125, 50) GUICtrlSetData(-1,"1|2|3|4|5|6|7") Local $lblWait = GUICtrlCreateLabel("Delay between tries (ms):",260, 125) Local $cboDelay = GUICtrlCreateCombo($dWaitTimeMilliSec, 390, 125, 50) GUICtrlSetData(-1,"100|200|300|400|500|600|700|800|900|1000") Local $incVal = GUICtrlCreateLabel("Increment value:",20, 150) Local $cboInc = GUICtrlCreateCombo($IncrementValue, 110, 150, 50) Local $Data = "-20" for $i = -19 to 20 $Data &= "|" & $i Next GUICtrlSetData(-1, $Data) Local $btnSave = GUICtrlCreateButton("Save Settings", 20, 180, 120, 25) Local $btnCancel = GUICtrlCreateButton("Cancel", 390, 180, 120, 25) GUICtrlSetState($btnSave, $GUI_DISABLE) GUISetState(@SW_SHOW) Local $idMsg while 1 $idMsg = GUIGetMsg() Switch($idMsg) case $GUI_EVENT_CLOSE, $btnCancel GUIDelete($frmSetup) ;Exit ;debug Return case $rbLiteral $boolSepIsLitt = True GUICtrlSetState($lbSeps, $GUI_DISABLE) GUICtrlSetState($edit, $GUI_ENABLE) case $rbNonLiteral $boolSepIsLitt = False GUICtrlSetState($lbSeps, $GUI_ENABLE) GUICtrlSetState($edit, $GUI_DISABLE) case $lbSeps $listValue = "@" & GUICtrlRead($lbSeps) GUICtrlSetState($btnSave, $GUI_ENABLE) case $cboInc GUICtrlSetState($btnSave, $GUI_ENABLE) case $btnSave if $boolSepIsLitt Then $sClipSeparator = GUICtrlRead($edit) Else $sClipSeparator = GetStringValue($listValue) EndIf $dNumberOfRetries = GUICtrlRead($cboTries) $dWaitTimeMilliSec = GUICtrlRead($cboDelay) $IncrementValue = GUICtrlRead($cboInc) GUIDelete($frmSetup) SaveSettings() ; save the clipboard separator to the registry value HKCU\software\clipappend\$sClipSeparator Return case $edit, $cboTries, $cboDelay GUICtrlSetState($btnSave, $GUI_ENABLE) EndSwitch WEnd EndFunc Func CopyAppend() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 send ("^c") Local $NewClp = ClipGet() PutToClp($CurrentClipString & $sClipSeparator & $NewClp) case 1 ; The data in the clipboard is NOT text Send ("^c") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc func CutAppend() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 send ("^x") Local $NewClp = GetTextClipboard() PutToClp($CurrentClipString & $sClipSeparator & $NewClp) case 1 Send ("^x") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func FilterInClpRecords() FilterClpRecords(True) EndFunc Func FilterOutClpRecords() FilterClpRecords(False) EndFunc Func GenerateListFromSelection() send("^c") ; get the selection Sleep(100) Local $CurrentClipString = GetTextClipboard() Local $RepeatNumber = int(InputBox("Repeat Number", "Please enter a number between 0 and 36767:")) if $RepeatNumber > 0 Then Local $OutBuf = $CurrentClipString for $i = 1 to $RepeatNumber-1 $OutBuf = $OutBuf & $sClipSeparator & $CurrentClipString Next PutToClp($OutBuf) EndIf EndFunc Func Help() Local $sHelpBuffer = "ClipAppend list of commands" & @LF & "====================" & @LF $sHelpBuffer &= "Ctl-alt-S to set up the clipboard delimitor" & @LF $sHelpBuffer &= "Ctrl-alt-c to copy and append the current selection (if it can be copied)" & @LF $sHelpBuffer &= "Ctrl-alt-x to cut and append the current selection (if it can be cut)" & @LF $sHelpBuffer &= "Ctrl-alt-r to run the current selection as a command line" & @LF $sHelpBuffer &= "Ctrl-alt-f to only keep clipboard records that contain user find strings" & @LF $sHelpBuffer &= "Ctrl-alt-d to only keep clipboard records that DO NOT contain user find strings" & @LF $sHelpBuffer &= "Ctrl-alt-up/down to sort the clipboard contents up or down" & @LF $sHelpBuffer &= "Ctrl-alt-g to repeat a selected line in current document n times, where the user is prompted for n" & @LF $sHelpBuffer &= "Ctrl-alt-i to autoincrement numerically or date wise the clipboard buffer from command above" & @LF $sHelpBuffer &= "Ctrl-alt-q to quit" & @LF $sHelpBuffer &= "Ctrl-alt-F1 to bring up this message" MsgBox(32,"ClipAppend " & $Version & " Help",$sHelpBuffer) EndFunc Func InOrDecrementSelection() ; check if the buffer starts with a number on each item after splitting around the separator Local $CurrentClipString = GetTextClipboard() if StringInStr($CurrentClipString, $sClipSeparator)>0 Then Local $NumericStringStart = GetNumericStringStart($CurrentClipString) if stringlen($NumericStringStart)>0 Then ; since this starts with a number, it could be the start of a time, date, or date time substring Local $DateTimeStringStart = GetDateTimeStringStart($CurrentClipString) if $DateTimeStringStart <> -1 Then Local $IncValue = $DateTimeStringStart if StringInStr($IncValue, ":")>0 Then ; includes time Local $arTimeInfo = StringSplit($IncValue, ":") Switch($arTimeInfo[0]) case 1 ;we increment minutes Local $OutBuf = IncDate($CurrentClipString, "n", $IncValue) $IncValue = _DateAdd("n", $IncValue, $IncrementValue) case 2 ; we increment seconds Local $OutBuf = IncDate($CurrentClipString, "s", $IncValue) $IncValue = _DateAdd("s", $IncValue, $IncrementValue) EndSwitch Else ; does not include time, we increment days Local $OutBuf = IncDate($CurrentClipString, "D", $IncValue) $IncValue = _DateAdd("D", $IncValue, $IncrementValue) EndIf PutToClp($OutBuf) Else Local $IncValue = $NumericStringStart Local $iLen = stringlen($NumericStringStart) Local $arClip = StringSplit($CurrentClipString, $sClipSeparator, 1) for $i = 1 to $arClip[0] $arClip[$i] = $IncValue & StringRight($arClip[$i], stringlen($arClip[$i]) - stringlen($NumericStringStart)) $IncValue = IncStringNumber($IncValue, $iLen) Next Local $OutBuf = _ArrayToString($arClip, $sClipSeparator, 1, $arClip[0], $sClipSeparator) PutToClp($OutBuf) EndIf EndIf EndIf EndFunc Func QuitClipAppend() Exit EndFunc Func ReplaceInClpRecords() Local $CurrentClipString = GetTextClipboard() if StringLen($CurrentClipString)>0 Then Local $FindString = InputBox("ClipAppend", "Please enter the find string:") if StringLen($FindString)>0 Then Local $ReplaceString = InputBox("ClipAppend", "Please enter the replace string:") if StringInStr($CurrentClipString, $sClipSeparator)>0 Then Local $arClip = StringSplit($CurrentClipString, $sClipSeparator) for $i = 1 to $arClip[0] if StringInStr($arClip[$i], $FindString)>0 Then $arClip[$i] = StringReplace($arClip[$i], $FindString, $ReplaceString) EndIf Next Local $sOut = _ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator) PutToClp($sOut) Else if StringInStr($CurrentClipString, $FindString)>0 Then PutToClp(StringReplace($CurrentClipString, $FindString, $ReplaceString)) EndIf EndIf EndIf Else MsgBox(0, "Warning!", "No clipboard text!") EndIf EndFunc func RunSelection() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 ; PutToClp("") commented because it often causes the next command to fail send ("^c") SetError(0) Local $RunSelection = ClipGet() if StringLen($RunSelection)=0 Then Switch(@error) case 1 MsgBox(0,"Error!", "Failed to copy the selection to the clipboard") case 2 MsgBox(0,"Error!", "The selection is not text") case Else MsgBox(0,"Error!", "Failed to access the clipboard, @error = " & @error) EndSwitch Return Else ; PutToClp("") commented because it often causes the next command to fail PutToClp($CurrentClipString) Local $Result = ShellExecute($RunSelection) ; better than using the run cmd, since it can also interpret a link, an exe, a txt if $Result = 0 Then MsgBox(0,"Error!", "Failed to run the command '" & $RunSelection & "'") EndIf EndIf case 1 Send ("^x") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func SortAscending() SetError(0) Local $clp = ClipGet() Switch(@error) case 0 Local $arClip = StringSplit($clp, $sClipSeparator, 1) _ArraySort($arClip,0, 1) PutToClp(_ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator)) case 1 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard is empty") case 2 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard contents are not alphanumeric") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func SortDescending() SetError(0) Local $clp = ClipGet() Switch(@error) case 0 Local $arClip = StringSplit($clp, $sClipSeparator, 1) _ArraySort($arClip,1, 1) PutToClp(_ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator)) case 1 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard is empty") case 2 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard contents are not alphanumeric") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc ;==============End of Functions called by hot keys=============== ;====================Support Functions ========================== Func FilterClpRecords($boolInclude) Local $CurrentClipString = GetTextClipboard() if StringLen($CurrentClipString)>0 Then ; There is a clipboard text to search and filter Local $arFindStrings = InputBoxWCheckBox("ClipAppend", "Please enter the find string:", "Please uncheck to stop entering data") if $arFindStrings <> -1 Then ; The user entered at least one find string Local $sOutClip ; output string that will be written to the clipboard when populated below if StringInStr($CurrentClipString, $sClipSeparator)>0 Then ; the clipboard text has multiple records Local $arClip[0], $arFound[0] _ArrayAdd($arClip, $CurrentClipString, 0, $sClipSeparator) ;populate the array of current clipboard records $arClip ; for each user find string, for $i = 0 to UBound($arFindStrings) - 1 Local $arNewFound[0] ; populate an array of indexes where the current find string was found, $arNewFound $arNewFound = _ArrayFindAll($arClip, $arFindStrings[$i], 0, 0, 0, 1) ; append the contents of array $arNewFound to already found array $arFound _ArrayConcatenate($arFound, $arNewFound) Next _ArrayUnique($arFound) ; remove duplicates (different user find strings may be found in the same record) _ArraySort($arFound) ; sort so looping through array items points to increasing indexes of array $arClip if $boolInclude Then ; $boolInclude is the instruction to filter in strings where find strings are found Local $arOutClip[UBound($arFound)] ; declare output clipboard record array with same size as array of found records ; populate output clipboard array for $i = 0 to UBound($arOutClip) - 1 $arOutClip[$i] = $arClip[$arFound[$i]] Next if UBound($arOutClip)>0 then $sOutClip = _ArrayToString($arOutClip,$sClipSeparator) ; serialize the array into a string for output EndIf ElseIf Ubound($arClip) > UBound($arFound) Then ; if not all clipboard records contain one of the find strings, if UBound($arFound) = 0 Then Return ; nothing was found, keep the clipboard as is Else Local $arOutClip[UBound($arClip) - UBound($arFound)] Local $iFound = 0 Local $FoundIndex = $arFound[$iFound] Local $OutClipIndex = 0 for $i = 0 to UBound($arClip) - 1 if $FoundIndex < $i Then ; the current clipboard record does not contain any of the find strings, $arOutClip[$OutClipIndex] = $arClip[$i] $OutClipIndex += 1 ; increment output clipboard array index for (possible) use in later loop Else $iFound += 1 $FoundIndex = $arFound[$iFound] EndIf Next $sOutClip = _ArrayToString($arOutClip,$sClipSeparator) EndIf ;Else ; all records have found strings, the clipboard contents should be emptied, leave $sOutClip as is, which is empty EndIf PutToClp($sOutClip) Else ; clipboard contents has only one record, msgbox(0,@ScriptLineNumber, "clipboard contents has only one record") for $i = 0 to UBound($arFindStrings) - 1 MsgBox(0,@ScriptLineNumber, "checking out " & $arFindStrings[$i]) if StringInStr($CurrentClipString, $arFindStrings[$i])>0 Then If $boolInclude Then Return Else PutToClp("") EndIf EndIf Next EndIf EndIf Else MsgBox(0, "Warning!", "No clipboard text!") EndIf EndFunc Func GetDateTimeStringStart($Buf) local $arClip = StringSplit($Buf, $sClipSeparator, 1) ; don't want to check all entries if there are thousands, limit it to 30 Local $scope = $arClip[0] if $scope > 30 then $scope = 30 Local $SubString = "" for $i = 1 to $scope if $SubString = "" Then $SubString = GetNumSubstring($arClip[$i], "/:") Else if stringlen($arClip[$i])>0 Then Local $NewSubString = GetNumSubstring($arClip[$i], "/:") if $NewSubString <> $SubString Then MsgBox(0, "Error!", "Buffer line " & $i & " is different from buffer line " & $i - 1 & "!") Return -1 EndIf EndIf EndIf Next Return $SubString EndFunc Func GetNumericStringStart($Buf) local $arClip = StringSplit($Buf, $sClipSeparator, 1) ; don't want to check all entries if there are thousands, limit it to 30 Local $scope = $arClip[0] if $scope > 30 then $scope = 30 Local $LeftNumeric, $boolDifferent = False for $i = 1 to $scope if $i = 1 Then $LeftNumeric = GetNumSubstring($arClip[$i]) Else Local $NewLeftNumeric = GetNumSubstring($arClip[$i]) if $NewLeftNumeric <> $LeftNumeric Then MsgBox(0, "Error!", "Buffer line " & $i & " is different from buffer line " & $i - 1 & "!") Return -1 EndIf EndIf if StringLen($LeftNumeric) = 0 then MsgBox(0, "Error!", "Buffer line 1 does not start with a number") Return -1 EndIf Next Return $LeftNumeric EndFunc Func GetNumSubstring($sIn, $NonNumAcceptableChars = "") Local $Char, $Ret for $i = 1 to stringlen($sIn) $Char = StringMid($sIn, $i, 1) if Asc($Char)>47 and Asc($Char)<58 Then $Ret &= $Char ElseIf StringInStr($NonNumAcceptableChars, $Char)>0 Then $Ret &= $Char Else ExitLoop EndIf Next if StringLen($NonNumAcceptableChars)>0 Then ; check if it's a date, time, or date time if _DateIsValid($Ret)=0 Then $Ret = "" ; date time is not valid EndIf EndIf Return $Ret EndFunc func GetStringValue($Value) if StringLeft($Value, 1) = "@" Then Switch($Value) case "@CR" Return @CR case "@LF" Return @LF case "@CRLF" return @CRLF case Else Return $Value EndSwitch Else Return $Value EndIf EndFunc Func GetTextClipboard($dFailedNum = 0) Local $ClipText = ClipGet() ; first try to get the text clipboard value Switch(@error) case 0 Return $ClipText case 1 SetError(0) Return "" case 2 Return "" case 3,4 if $dFailedNum = -1 then ; -1 flags that if it fails, we return an empty string and the error set in the ClipGet() call Return "" EndIf ; it failed once, try again till the set number of tries is reached While ++$dFailedNum < $dNumberOfRetries Sleep($dWaitTimeMilliSec) SetError(0) $ClipText = GetTextClipboard(-1) ; use -1 to flag not to keep going recursively forever if @error = 0 Then ; no error, this means that the call succeeded, the function job is complete Return $ClipText EndIf WEnd MsgBox(0, "Error!", "The clipboard seems to be locked, it failed to respond after " & $dNumberOfRetries & " attempts, with " & $dWaitTimeMilliSec & " between tries.") EndSwitch EndFunc Func IncDate($Buf, $Type, $IncValue) Local $arClip = StringSplit($Buf, $sClipSeparator, 1) Local $iLen = stringlen($IncValue) for $i = 1 to $arClip[0] $arClip[$i] = $IncValue & StringRight($arClip[$i], stringlen($arClip[$i]) - $iLen) $IncValue = _DateAdd($Type, $IncrementValue, $IncValue) Next Return _ArrayToString($arClip,$sClipSeparator, 1, $arClip[0], $sClipSeparator) EndFunc Func IncStringNumber($sIn, $iLen) Local $sFormat = "%0" & $iLen & "d" ; build the format string, see PrintFormat in help for the syntax $sIn = $sIn*1 + $IncrementValue ; multyplying by one internally converts the string that contains characters between 0 and 9 to a numeric value Return StringFormat($sFormat, $sIn) EndFunc ; returns an array of user strings, user enters till the checkbox is unchecked Func InputBoxWCheckBox($Title, $Prompt, $CheckBoxLabel) Local $boolChecked = True Local $boolClearEdit = True Local $arUE[1] Local $GuiID = GUICreate($Title, 415, 120) Local $PromptID = GUICtrlCreateLabel($Prompt, 5, 10, 200) Local $UserInputID = GUICtrlCreateInput("",210, 10, 200) Local $cbDoneID = GUICtrlCreateCheckbox($CheckBoxLabel, 5, 35) GUICtrlSetState(-1, $GUI_CHECKED) Local $cbEmptyEditOnOK = GUICtrlCreateCheckbox("Delete Find string on OK press", 200, 35) GUICtrlSetState(-1, $GUI_CHECKED) Local $btnCancel = GUICtrlCreateButton("Cancel", 5, 60, 70) Local $btnOK = GUICtrlCreateButton("OK", 340, 60, 70) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState(@SW_SHOW, $GuiID) While 1 local $msg = GUIGetMsg() Switch($msg) Case $GUI_EVENT_CLOSE GUIDelete($GuiID) ExitLoop case $cbDoneID $boolChecked = BitAND(GUICtrlRead($cbDoneID), $GUI_CHECKED) = $GUI_CHECKED case $cbEmptyEditOnOK $boolClearEdit = BitAND(GUICtrlRead($cbEmptyEditOnOK), $GUI_CHECKED) = $GUI_CHECKED case $btnCancel GUIDelete($GuiID) Return -1 case $btnOK Local $UserEntry = GUICtrlRead($UserInputID) if stringlen($UserEntry)>0 Then if StringLen($arUE[0]) = 0 Then $arUE[0] = $UserEntry Else _ArrayAdd($arUE, $UserEntry) EndIf if $boolClearEdit Then GUICtrlSetData($UserInputID, "") EndIf EndIf if $arUE = 0 And Not $boolChecked Then GUIDelete($GuiID) return -1 ElseIf $arUE <> 0 And Not $boolChecked Then GUIDelete($GuiID) Return $arUE EndIf EndSwitch WEnd EndFunc Func PutToClp($sClp) Local $Res = ClipPut($sClp) Local $Attempts = 1 while $res = 0 and $Attempts < $dNumberOfRetries ; while failure Sleep($dWaitTimeMilliSec) $Res = ClipPut($sClp) $Attempts += 1 WEnd if $Res = 0 Then ; failed MsgBox(0,"Error!", "Failed to write to the clipboard!") EndIf EndFunc Func ReadRegSetting($Setting, $Type) Local $RetVal SetError(0) $RetVal = RegRead("HKCU\software\ClipAppend", $Setting) Switch(@error) case 0 if StringLen($RetVal)>0 Then Return $RetVal Else Return -1 EndIf case -1 ; in case the ClipAppend key is there, but not the $Setting value Return -1 case 1 ; expected on first use, there is no ClipAppend key, create it RegWrite("HKCU\software\ClipAppend") Return -1 case 2 Return -1 case else ; should never get here MsgBox(0,"Error!", "Failed to write to the registry, @error = " & @error) Return -1 EndSwitch EndFunc Func ReadSettings() Local $RetVal $RetVal = ReadRegSetting("ClipSeparator", "REG_MULTI_SZ") if $RetVal <> -1 Then $sClipSeparator = $RetVal EndIf $RetVal = ReadRegSetting("CopyCutRetries", "REG_SZ") if $RetVal <> -1 Then $dNumberOfRetries = $RetVal EndIf $RetVal = ReadRegSetting("RetryDelay", "REG_SZ") if $RetVal <> -1 Then $dWaitTimeMilliSec = $RetVal EndIf $RetVal = ReadRegSetting("IncrementValue", "REG_SZ") if $RetVal <> -1 Then $IncrementValue = $RetVal EndIf EndFunc Func SaveSettings() SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "ClipSeparator", "REG_MULTI_SZ", $sClipSeparator) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the separator value to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "CopyCutRetries", "REG_SZ", $dNumberOfRetries) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the number of copy retries to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "RetryDelay", "REG_SZ", $dWaitTimeMilliSec) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the retry delay to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "IncrementValue", "REG_SZ", $IncrementValue) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the increment value to the registry, error = " & @error) EndIf EndFunc ;====================End Support Functions ==========================
  21. _ClipGetHTML Seeing as how I created the _ClipPutHTML() & _ClipPutHyperlink() functions, I figured why not complete the set of available functions and finish out the HTML clipboard read/set UDFs. The below example is included in the ZIP file on my site. Example: HTML Clipboard Monitor #include <Misc.au3> ; _IsPressed() #include <_ClipGetHTML.au3> ; ================================================================================================ ; <HTMLClipBoardMonitor.au3> ; ; Simple program used to Monitor and Report on HTML formatted ClipBoard data ; ; Functions: ; MemoWrite() ; from the AutoIT documentation examples ; ; Dependencies: ; <_ClipGetHTML.au3> ; _ClipGetHTML() ; ; See also: ; <_ClipPutHTML.au3> ; ; Author: Ascend4nt, and [??] (whoever coded the AutoIT Help examples with MemoWrite()) ; ================================================================================================ Global $iMemo ; MemoWrite and GUI creation courtesy of AutoIT Help Examples ; Write message to memo Func MemoWrite($sMessage = "") GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Local $hGUI Local $sHTMLStrPrev="",$aHTMLData Local $sPlainText,$aHTMLLinks ; Create GUI $hGUI = GUICreate("HTML ClipBoard Monitor ([F5] Forces Refresh)", 600, 400) $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, 0x200000) ; $WS_VSCROLL=0x00200000 GUICtrlSetLimit($iMemo,1000000) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() Do $aHTMLData=_ClipGetHTML() If Not @error And ($aHTMLData[0]<>$sHTMLStrPrev Or _IsPressed("74")) Then $sPlainText=ClipGet() ; Clear the Edit Control GUICtrlSetData($iMemo,"","") MemoWrite("==== New HTML Data received ("&@HOUR&':'&@MIN&":"&@SEC&") ===="&@CRLF&"Version #"&$aHTMLData[1]&@CRLF& _ "Fragment Start:"&$aHTMLData[2]&", Fragment End:"&$aHTMLData[3]&@CRLF& _ "Selection Start (optional [-1=unavailable]):"&$aHTMLData[4]& _ ", Selection End (optional):"&$aHTMLData[5]&@CRLF& _ "Source URL (optional string):"&$aHTMLData[6]&@CRLF& _ "4 characters at Fragment Start:"&StringMid($aHTMLData[0],$aHTMLData[2],4)&@CRLF& _ "4 characters at Fragment End:"&StringMid($aHTMLData[0],$aHTMLData[3],4)&@CRLF) If $aHTMLData[4]<>-1 Then MemoWrite("4 characters at Selection Start:"&StringMid($aHTMLData[0],$aHTMLData[4],4)&@CRLF& _ "4 characters at Selection End:"&StringMid($aHTMLData[0],$aHTMLData[5],4)) EndIf MemoWrite("---- CF_HTML Header (size="&StringLen($aHTMLData[7])&") ----"&@CRLF&$aHTMLData[7]&@CRLF) MemoWrite("---- RAW HTML Data (UTF-8 size="&StringLen($aHTMLData[0])&") ----"&@CRLF&BinaryToString($aHTMLData[0],4)&@CRLF) MemoWrite("---- Plain Text Variant (size="&StringLen($sPlainText)&") ----"&@CRLF&$sPlainText) #cs ; Want to put it back just the way it came? This is one approach, but ; the Offsets will not be placed properly ;_ClipPutHTML($aHTMLData[0],$sPlainText) ; This is the proper way: Local $sHTMLData=$aHTMLData[7]&$aHTMLData[0] _ClipBoard_SendHTML($sHTMLData,$sPlainText) #ce $sHTMLStrPrev=$aHTMLData[0] EndIf Until _IsPressed("1B") Or GUIGetMsg()=-3 ; $GUI_EVENT_CLOSE=-3 GUIDelete($hGUI)Get the Code at my Site Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.*EDIT: added Memory Lock/Unlock (recommended and often-used way to ensure a successful grab of a Clipboard memory object), and added clarification on correct way to get memory block size
  22. Hello everyone, I need a simple code to be able to know if current clipboard content is a string text or a file path (a file has been copied) I think i must use @error but i can't be able to get any results. Example: $clipboard = ClipGet() if $clipboard <> $last And $clipboard <> "" And @error=0 Then ; the clipbord contain a string Endif Please help.
  23. I created this little script: HotKeySet("!g", "searchgoogle") While 1 Sleep(10000) WEnd Func searchgoogle() Sleep(500) Send( "^c" ) Sleep(500) $ClipB2 = ClipGet() $url = "http://www.google.com/search?q=" & $ClipB2 Sleep(300) MsgBox(0,"",$url) EndFunc I just select a word and invoke the hotkey. More than an hour I try to change the Sleep values but something still does not work: When I invoke the 1st time the hotkey, almost always it returns the correct url, but when I reuse the hotkey a few times it doesn't copy any more and the url is constructed with previous clipboard value. Does anyone know what is wrong in my script?
  24. Hi... How to put data to clipboard in all available formats? I use _ClipBoard_GetData to save all formats data to files but when I try to put them again to clipboard using _ClipBoard_SetData, I have available only the last data format which I used. After that when I try put this data to "Microsoft Word" I get only "Cleaned" text format. When I the set last format as a HTML and I put to "Micorosft Word" everything fine, but I can't put to Notepad (I get empty value). When I doing this same with _ClipBoard_GetDataEx to save data to memory object (not to file) and put them again using _ClipBoard_SetDataEx all data formats are available... Help?
×
×
  • Create New...