Rawox Posted May 19, 2010 Share Posted May 19, 2010 (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 expandcollapse popup#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 May 19, 2010 by Rawox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 20, 2010 Moderators Share Posted May 20, 2010 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: ; 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 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 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