Sign in to follow this  
Followers 0
jvanegmond

Convert Text To Au3

17 posts in this topic

#1 ·  Posted (edited)

Very useful for creating those multiline messageboxes!

#include <GUIConstants.au3>
; == GUI generated with Koda ==
GUICreate("Convert Au3/Txt", 519, 379, 192, 125)
$Box = GUICtrlCreateEdit("", 0, 0, 433, 373, -1,$WS_EX_CLIENTEDGE)
$ConvertTxt = GUICtrlCreateButton("Convert" & @LF & "Txt > Au3", 440, 0, 75, 73,$BS_MULTILINE)
$ConvertAu3 = GUICtrlCreateButton("Convert" & @LF & "Au3 > Txt", 440, 80, 75, 73,$BS_MULTILINE)
$Option = GUICtrlCreateCheckbox("Single-Line", 440, 160, 75, 73)
$Exit = GUICtrlCreateButton("Exit", 440, 348, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case ($msg = $GUI_EVENT_CLOSE) OR ($msg = $Exit)
            Exit
        Case $msg = $ConvertTxt
            If GUICtrlRead($Option) = $GUI_CHECKED Then
                GUICtrlSetData($Box, '"' & StringReplace(GUICtrlRead($Box),@CRLF, '" & @CRLF & "') & '"')
            Else
                GUICtrlSetData($Box, '"' & StringReplace(GUICtrlRead($Box),@CRLF, '" & @CRLF & _' & @CRLF & '"') & '"')
            EndIf
        Case $msg = $ConvertAu3
            If GUICtrlRead($Option) = $GUI_CHECKED Then
                GUICtrlSetData($Box, StringTrimRight(StringTrimLeft(StringReplace(GUICtrlRead($Box),'" & @CRLF & "', @CRLF ),1),1))
            Else
                GUICtrlSetData($Box, StringTrimRight(StringTrimLeft(StringReplace(GUICtrlRead($Box),'" & @CRLF & _' & @CRLF & '"', @CRLF ),1),1))
            EndIf
    EndSelect
WEnd

[Edit] Now with multi-line/Single-line option! Thanks goes to heibel for the idea ( Groeten terug ! )

Edited by Manadar

Share this post


Link to post
Share on other sites



Ha, I'd never thought of simplifing it before, nice one, I'm sure it will come in handy.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi, maybe an extra option to make the text>au3 results in one single line?

groetjes! :D

Share this post


Link to post
Share on other sites

Great idea, heibel! I just implemented this new feature.

Just tick the checkbox for a single-line conversion!

Okay, works!

Last (?)request: some restore or save button (in clipboard) to be able to get the 'original text' back again...

Thanks anyway. :D

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Okay, works!

Last (?)request: some restore or save button (in clipboard) to be able to get the 'original text' back again...

Thanks anyway. :D

Why not just use the au3 to text to get it back?

Edit:

Oops, you said clipboard, I totally missed that :D

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Why not just use the au3 to text to get it back?

Ah, your are right, that works.

Must say:missed it since the poor brains was expecting some undo-botton. (just worked on something else and therefore....)

Greatings (groeten)

Share this post


Link to post
Share on other sites

Here, since I made the mistake:

#include <GUIConstants.au3>
; == GUI generated with Koda ==
GUICreate("Convert Au3/Txt", 519, 379, 192, 125)
$Box = GUICtrlCreateEdit("", 0, 0, 433, 373, -1,$WS_EX_CLIENTEDGE)
$ConvertTxt = GUICtrlCreateButton("Convert" & @LF & "Txt > Au3", 440, 0, 75, 73,$BS_MULTILINE)
$ConvertAu3 = GUICtrlCreateButton("Convert" & @LF & "Au3 > Txt", 440, 80, 75, 73,$BS_MULTILINE)
$CopyToClip = GUICtrlCreateButton('Copy' & @LF & 'Clipboard', 440, 160, 75, 73, $BS_MULTILINE)
$Option = GUICtrlCreateCheckbox("Single-Line", 440, 240, 75, 73)
$Exit = GUICtrlCreateButton("Exit", 440, 348, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case ($msg = $GUI_EVENT_CLOSE) OR ($msg = $Exit)
            Exit
        Case $msg = $ConvertTxt
            If GUICtrlRead($Option) = $GUI_CHECKED Then
                GUICtrlSetData($Box, '"' & StringReplace(GUICtrlRead($Box),@CRLF, '" & @CRLF & "') & '"')
            Else
                GUICtrlSetData($Box, '"' & StringReplace(GUICtrlRead($Box),@CRLF, '" & @CRLF & _' & @CRLF & '"') & '"')
            EndIf
        Case $msg = $ConvertAu3
            If GUICtrlRead($Option) = $GUI_CHECKED Then
                GUICtrlSetData($Box, StringTrimRight(StringTrimLeft(StringReplace(GUICtrlRead($Box),'" & @CRLF & "', @CRLF ),1),1))
            Else
                GUICtrlSetData($Box, StringTrimRight(StringTrimLeft(StringReplace(GUICtrlRead($Box),'" & @CRLF & _' & @CRLF & '"', @CRLF ),1),1))
            EndIf
        Case $msg = $CopyToClip
            ClipPut(GUICtrlRead($Box))
    EndSelect
WEnd


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Okay, perhaps even better to:

- before first action: copy to clipoard as the save

- one button with restore (from clipboard)

?

or at least:

- the copy to clipboard (as now)

- also the paste from clipboard...

HTH (hopes this helpes)

Edited by heibel

Share this post


Link to post
Share on other sites

Okay, perhaps even better to:

- before first action: copy to clipoard as the save

- one button with restore (from clipboard)

?

or at least:

- the copy to clipboard (as now)

- also the paste from clipboard...

HTH (hopes this helpes)

Your right mouse button broke? :D

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

why not just use codewizard? (comes with the SciTE)

you can also get it here

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

why not just use codewizard? (comes with the SciTE)

you can also get it here

Ah, since we Dutch drink too much and always forget about all those possability's....

hihi

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ah, since we Dutch drink too much and always forget about all those possability's....

hihi

I can't help myself, i just heard i graduated high school and with the european soccer championship and all.. :D

[edit] Oranje !!

Edited by Manadar

Share this post


Link to post
Share on other sites

I can't help myself, i just heard i graduated high school and with the european soccer championship and all.. :D

[edit] Oranje !!

:P:D;)

Share this post


Link to post
Share on other sites

Never would have thought of this. Good for long strings.


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

this is useful..

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I made something kind of similar a while ago. It takes text that is copied to the clipboard and converts it into hexadecimal then formats it into a string usable by AutoIt. Here's the code:

Local $c="46756E63205F556E4865782820247348657820290D0A094C6F63616C20246153706C6974203D20537472696E6753706C
69742824734865782C202222292C202473526574203D2027272C2024690D0A09466F72202469203D203120746F2024615370
6C69745B305D207374657020320D0A0909247352657420263D204368722844656328246153706C69745B24695D2026202461
53706C69745B2469202B20315D29290D0A094E6578740D0A0952657475726E2024735265740D0A456E6446756E63"
ClipPut('Local $c=""' & @CRLF & '$c&="' & _StringChunk(_Hex(ClipGet()), 512, '"' & @CRLF & '$c&="') & '"' & @CRLF & '$c=_UnHex($c)' & @CRLF & @CRLF & _UnHex($c))

Func _Hex( $sStr )
    Local $aSplit = StringSplit($sStr, ""), $sRet = '', $i
    For $i = 1 to $aSplit[0]
        $sRet &= Hex(Asc($aSplit[$i]), 2)
    Next
    Return $sRet
EndFunc

Func _UnHex( $sHex )
    Local $aSplit = StringSplit($sHex, ""), $sRet = '', $i
    For $i = 1 to $aSplit[0] step 2
        $sRet &= Chr(Dec($aSplit[$i] & $aSplit[$i + 1]))
    Next
    Return $sRet
EndFunc

Func _StringChunk( $sStr, $iChrs, $sSep = @CRLF )
    Local $iLen = StringLen($sStr), $iMod = Mod($iLen, $iChrs), $iChrLeft = $iLen - $iMod, $sNew = ""
    For $i = 0 to $iChrLeft / $iChrs - 1
        $sNew = $sNew & StringTrimLeft(StringTrimRight($sStr, $iLen - ( $i * $iChrs + $iChrs )), ( $i * $iChrs )) & $sSep
    Next
    Return $sNew & StringRight($sStr, $iMod)
EndFunc
Edited by erifash

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0