ViciousXUSMC Posted August 8, 2014 Share Posted August 8, 2014 (edited) So been messing with this idea in my freetime and everytime I feel like I made the right connection, just one small thing does not work. The idea would be this: Select text in a document or webpage and use a hotkey to copy it to the clipboard and run a given RegEx filter on it, push it back to the clipboard in its modified state so that when I paste into a document I get the results of the RegEx. I found this code that I think is a good base for adding text to the clipboard: #include <GuiConstantsEx.au3> ; AutoIt Code: http://www.autoitscript.com/ $gui = GUICreate('', 500, 300, 0, 0) ; input that will receive richtext clipboard data $input_clipboard = GuiCtrlCreateInput('my hidden input', 0, 0, 0, 0) ; copy plaintext to clipboard: ctrl+shift+c (normal copy to clipboard ctrl+c) HotKeySet('^+c', 'ClipPutPlainText') ; ctrl+shift+c ; replaces richtext in clipboard with plaintext Func ClipPutPlainText() ; set input value to whatever is currently in clipboard GUICtrlSetData($input_clipboard, ClipGet()) ; put plaintext data in clipboard ClipPut(GUICtrlRead($input_clipboard)) EndFunc While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd and I had this working for RegEx #include <array.au3> $array = StringRegExp("(My String)", "(My RegEx)", 3) For $i = 0 To UBound($array) - 1 MsgBox(0, "", $array[$i] & @CR) Next I tried to push $input_clipboard into my RegEx and then take those results back to the clipboard but I just get return codes. I tried _ArrayToClip() without too much luck. Should be rather easy and it was a good project for me to practice on but I think it's time to ask for a bit of help. Regards, Edited August 8, 2014 by ViciousXUSMC Link to comment Share on other sites More sharing options...
kylomas Posted August 8, 2014 Share Posted August 8, 2014 When you "push" $input_clipboard to your regexp are you using guictrlread($input_clipboard) ?? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
sahsanu Posted August 8, 2014 Share Posted August 8, 2014 (edited) I don't really know if I understood the question but something like this should work HotKeySet('^+c', 'ClipPutPlainText') ; ctrl+shift+c HotKeySet('^+s', '_Exit') ; ctrl+shift+s While 1 Sleep(100) WEnd Func ClipPutPlainText() $sClipGet = ClipGet() $sClipGet = StringRegExpReplace($sClipGet, "a", "(o_o )"); Just an example replacing letter a to (o_o ) ClipPut($sClipGet) EndFunc ;==>ClipPutPlainText Func _Exit() Exit EndFunc ;==>_Exit Cheers, sahsanu Edited August 8, 2014 by sahsanu Link to comment Share on other sites More sharing options...
kylomas Posted August 8, 2014 Share Posted August 8, 2014 @sahsanu - You are probably right on the mark. Regardless, we have neither enough definition of what the user wants nor do we have the code used to try his regexp. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted August 8, 2014 Share Posted August 8, 2014 StringRegExpReplace if much better suited to what I understand from the OP since it always returns a string, whether or not the match (replacement) succeeds or fails. That sems to fit to the term "filter" pretty well. Now StringRegExp is more problematic: a failure returns an array or not. Next, in the general case, what processing should be done to the array elements: concatenate them blindly or somehow grouped by number of captures at every match, or what? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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