ferradavi Posted March 20, 2016 Posted March 20, 2016 Hi there! Is there a simple way to do this: (assuming to select the text above) HtItaswtdt Thanks to all for your attention
Moderators Melba23 Posted March 20, 2016 Moderators Posted March 20, 2016 ferradavi, #include <MsgBoxConstants.au3> $sString = "Hi there! Is there a simple way to do this:" $aRet = StringRegExp($sString, "(?:\A|\s)(.)", 3) $sLetters = "" For $i = 0 To UBound($aRet) - 1 $sLetters &= $aRet[$i] Next MsgBox($MB_SYSTEMMODAL, "Extracted", $sLetters) 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
iamtheky Posted March 20, 2016 Posted March 20, 2016 $sStr = "Hi there!" & @LF & _ "Is there a simple way to do this:" $aStr = stringsplit(stringreplace($sStr , @LF , " ") , " " , 2) $output = "" for $i = 0 to ubound($aStr) - 1 $output &= stringleft($aStr[$i] , 1) Next msgbox(0 , '' , $output) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted March 20, 2016 Posted March 20, 2016 of course Melba wins, I think locals get affinity on the server . His can be condensed unsafely. #include<array.au3> $sStr = "Hi there!" & @LF & _ "Is there a simple way to do this:" msgbox(0, '' , _ArrayToString(StringRegExp($sStr, "(?:\A|\s)(.)", 3) , "")) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Malkey Posted March 21, 2016 Posted March 21, 2016 And another method. #include <MsgBoxConstants.au3> Local $sString = "Hi there!" & @LF & _ "Is there a simple way to do this:" $aRet = StringRegExpReplace($sString, "(?s)(?!\b\w).*?", "") MsgBox($MB_SYSTEMMODAL, "Results", _ 'The first letter of the words in the selected text: ' & @LF & @LF & _ '"' & $sString & '"' & @LF & @LF & _ 'are:' & @LF & @LF & _ '"' & $aRet & '"')
ferradavi Posted March 21, 2016 Author Posted March 21, 2016 (edited) Very very cool!! How to obtain instantly the result after selecting text? I mean clicking the left button mouse and releasing it in a active window. Thanks Edited March 21, 2016 by ferradavi
ferradavi Posted March 21, 2016 Author Posted March 21, 2016 Hey guys, I need your help... what's wrong about this code: expandcollapse popup#include <Misc.au3> #include <MsgBoxConstants.au3> HotKeySet('{ESC}', '_Exit') Global $hDLL = DllOpen('user32.dll') While 1 if _IsPressed ( '1', $hDLL) Then If _IsPressed('11', $hDLL) AND _IsPressed('1', $hDLL) Then do sleep (200) until _IsPressed ('11', $hDLL )<>1 AND _IsPressed('1', $hDLL) <>1 _GetText() EndIf EndIf Sleep(200) WEnd Func _Exit() DllClose($hDLL) Exit EndFunc Func _GetText() Local $PrevClip = ClipGet() Send('^c') ConsoleWrite(ClipGet() & @LF) Local $sString=string($PrevClip) ClipPut($PrevClip) $aRet = StringRegExp($sString, "(?:\A|\s)(.)", 3) $sLetters = "" For $i = 0 To UBound($aRet) - 1 $sLetters &= $aRet[$i] Next MsgBox($MB_SYSTEMMODAL, "Extracted", $sLetters) EndFunc
ferradavi Posted March 22, 2016 Author Posted March 22, 2016 expandcollapse popup#include <Misc.au3> #include <MsgBoxConstants.au3> HotKeySet('{ESC}', '_Exit') Global $hDLL = DllOpen('user32.dll') While 1 if _IsPressed ('1', $hDLL) or _IsPressed ('10', $hDLL) Then If _IsPressed('10', $hDLL) And _IsPressed('1', $hDLL) Then do sleep (200) until _IsPressed ('10', $hDLL )<>1 And _IsPressed('1', $hDLL) <>1 Send('^c') _Extract() EndIf EndIf WEnd Func _Exit() DllClose($hDLL) Exit EndFunc Func _Extract() Local $sData = ClipGet() $sString = $sData $aRet = StringRegExp($sString, "(?:\A|\s)(.)", 3) $sLetters = "" For $i = 0 To UBound($aRet) - 1 $sLetters &= $aRet[$i] Next MsgBox($MB_SYSTEMMODAL, "Extracted", $sLetters) EndFunc ... and finally I got it!
Danyfirex Posted March 22, 2016 Posted March 22, 2016 (edited) Hi just for fun. A not regexp example. #include <array.au3> $sStr = "Hi there!" & @LF & _ "Is there a simple way to do this:" Local $aSplit = StringSplit($sStr, " " & @CRLF) Local $sOut = "" For $i = 1 To $aSplit[0] $sOut &= StringLeft($aSplit[$i], 1) Next ConsoleWrite($sOut & @CRLF) Saludos Edited March 22, 2016 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Gianni Posted March 22, 2016 Posted March 22, 2016 just for fun, A not regexp nor array example. $sStr = "Hi there!" & @LF & _ "Is there a simple way to do this:" $sStr = StringReplace(StringReplace(StringReplace(StringStripWS($sStr, 7), @CR, " "), @LF, " "), @TAB, " ") Local $i = StringLen($sStr), $sOut = "" While $i $i = StringInStr($sStr, " ", 0, -1, $i - 1) $sOut = StringMid($sStr, $i + 1, 1) & $sOut WEnd ConsoleWrite($sOut & @CRLF) iamtheky 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
iamtheky Posted March 22, 2016 Posted March 22, 2016 $sStr = "Hi there!" & @LF & _ "Is there a simple way to do this:" $sOut = "" while 1 $sOut &= stringleft($sStr , 1) If Not StringInStr($sStr , " ") Then exitloop $sStr = stringtrimleft($sStr , StringinStr(StringReplace($sStr , @LF, " "), " " , 0 , 1)) wend msgbox(0, '' , $sOut) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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