iCode Posted October 2, 2011 Share Posted October 2, 2011 (edited) i use LibreOffice and this has been bugging me for awhile but so far i haven't been able to find a cause if i use StringStripWS() with flag 7, (and only with 7) i get weird results when pasting in Office. for example if you use this script (and the hot-key doesn't seem to matter, as long as it's free in Office - here it's CTRL+SPACE)...HotKeySet('^{SPACE}', '_paste') While 1 Sleep(250) WEnd Func _paste() $str = ClipGet() Sleep(10) $str_a = StringStripWS($str, 7) ClipPut($str_a) Sleep(10) Send('^v') Send('{ENTER 2}') $str_b = StringStripWS($str, 3) ClipPut($str_b) Sleep(10) Send('^v') EndFunc and then copy this sample...a b c this will be the output you paste (CTRL+SPACE)...a b c a b c so the above works as expected, but if you use this sample...a b c this will be the output, where the first StringStripWS() fails to output the 'b' and 'c'...a a b c i can get the job done using a regular expression, but i'm wondering why StringStripWS() is failing with flag 7? Edited October 2, 2011 by iCode FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) Link to comment Share on other sites More sharing options...
JohnOne Posted October 2, 2011 Share Posted October 2, 2011 I would hazard a guess that there is some other formatting character being copied from your office seeing as how it is only that application that the function fails with. See if you get unexpected characters HotKeySet('^{SPACE}', '_paste') While 1 Sleep(250) WEnd Func _paste() $str = ClipGet() $astr = StringSplit($str,"") For $i = 1 To $astr[0] ConsoleWrite(Asc($astr[$i]) & " ") Next ConsoleWrite(@CRLF) EndFunc ;==>_paste AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
iCode Posted October 2, 2011 Author Share Posted October 2, 2011 I would hazard a guess that there is some other formatting character being copied from your office... thing is, it happens when copying from anywhere. i even made sure to preview my first post and copy the 2nd 'abc' sample and pasted it into Office so the source does not seem to matter, nor the string. the problem is with OO i think. i just ran more tests using different methods to send keys to OO and the output got borked. in one case it output 'a' on one page, 'b' on another and 'c' on a 3rd. Java < FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) Link to comment Share on other sites More sharing options...
JohnOne Posted October 2, 2011 Share Posted October 2, 2011 But when you paste it into notepad it works fine right? It does for me. So idoubt its a problem with stringstripws. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
iCode Posted October 3, 2011 Author Share Posted October 3, 2011 yeah, it's only Libre/OO where the problem is i agree it's not likely a StringStripWS problem, but i wasn't sure at first anyway, thanks for the help! FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) Link to comment Share on other sites More sharing options...
czardas Posted October 3, 2011 Share Posted October 3, 2011 (edited) I tend to avoid having to use any kind of office application unless I need a nice print format for something official. One of the reasons is that I don't fully understand how they work. But besides that, I don't like autoformatting and popup messages that interrupt you every time you try to do something. Although they are great programs, things like this irritate me. Heres a way you can test for AscII characters in the string. Then you can compair the results to the AscII code table to see if there are any characters you didn't expect. If there are unicode characters present, then I don't know. #include <Array.au3> Local $sString = "1760" ; replace this with your string Local $sChars = "" For $i = 0 To 255 ; Look for AscII characters If StringInStr($sString, Chr($i)) Then $sChars &= $i & "," Next $sChars = StringTrimRight($sChars, 1) ; remove the final delimeter Local $aArray = StringSplit($sChars, ",", 2) _ArrayDisplay($aArray) Ah, I notice John already suggested something similar. Edited October 3, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
iCode Posted October 3, 2011 Author Share Posted October 3, 2011 i tend to agree with your view on office suites - i very much like the FOSS community, but i don't like Java at all and most of them require it i didn't run the AscII test yet FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) Link to comment Share on other sites More sharing options...
czardas Posted October 3, 2011 Share Posted October 3, 2011 i didn't run the AscII test yetI'd be interested to hear your results. operator64 ArrayWorkshop 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