Sign in to follow this  
Followers 0
Rawox

@TAB etc. in .ini

2 posts in this topic

#1 ·  Posted (edited)

Ok, New problem...

If I copy a piece of AutoIt code it includes @TAB and @CRLF etc. but when I write directly what I copied to an .ini file it doesn't types those things.

Anyone knows how?

Thanks, Rawox

#include <GuiConstantsEx.au3>
#include <Array.au3>
#Include <GuiMenu.au3>

HotKeySet ( "^!v", "_showMenu" )

AdLibRegister ( "_checkClip" )

Global      $ClipHist = ""
Global      $itArray[1]
            $itArray[0] = "0"

            GUICreate ( "Test", 200, 200 )
$Button =   GUICtrlCreateButton ( "test", 10, 10 )
$Menu =     GUICtrlCreateContextMenu ( $Button )
            GUICtrlCreateMenuItem ( "", $Menu )
$Config =   GUICtrlCreateMenuItem ( "Configuration", $Menu )
            GUISetState ( @SW_HIDE )

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _showMenu()
    ControlClick ( "Test", "", $Button, "menu" )
EndFunc

Func _addToList ( $sText, $vChar = 30 )
    If $sText <> "" Then
        If StringInStr ( $sText, @TAB ) Then $nText = StringReplace ( $sText, @TAB, "" )
        If StringLen ( $nText ) > $vChar Then $nText = StringLeft ( $sText, $vChar ) & "..."
        _GUICtrlMenu_InsertMenuItem ( $Menu, 0, $nText, $itArray[$itArray[0]] )
        $itArray[0] = $itArray[0] + 1
        _writeIni()
        _paste()

            _ArrayAdd ( $itArray, $iText )
    EndIf
EndFunc

Func _paste()
    Run ( "notepad.exe" )
    WinActivate ( "Naamloos - Kladblok" )
    Sleep ( 500 )
    $var = StringSplit ( IniRead ( @ScriptDir & "\text.ini", "Array", "itArray", "" ), "|", 2 )
    Send ( $var[1] )
EndFunc

Func _checkClip()
    If ClipGet ( ) <> $ClipHist Then
        $ClipHist = ClipGet ( )
        _addToList ( ClipGet ( ) )
    EndIf
EndFunc

Func _writeIni()
    _ArrayDisplay ( $itArray )
    IniWrite ( @ScriptDir & "\text.ini", "Array", "itArray", _ArrayToString ( $itArray, "|" ) )
EndFunc
Edited by Rawox

Share this post


Link to post
Share on other sites



Rawox,

You have run into a limitation of the Windows ini file format - Values cannot hold such things as @CRLF or @TAB. :(

But you can replace them with escape sequences like this: :idea:

; This is what we want to write and recover
$sWrite = "Fred" & @CRLF & "Fred"
MsgBox(0, "Original", $sWrite)

; Convert the @CRLF to an escape sequence
$sWrite = StringReplace($sWrite, @CRLF, "\n")
MsgBox(0, "Writing", $sWrite)

; Write it
IniWrite("Test.ini", "Section", "Key", $sWrite)

; Read it back
$sRead = IniRead("Test.ini", "Section", "Key", "")
MsgBox(0, "Reading", $sRead)

; And reconvert the escape sequence
$sRead = StringReplace($sRead, "\n", @CRLF)
MsgBox(0, "Final", $sRead)

You could use \t to replace @TAB. Just make sure that the escape sequences do not appear in the values. :)

I hope this helps. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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