Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817

    Exclamation Universal Anti-Recoil / Spread Reducer

    Hi All!

    Back with an update to the script i made.

    This time i also added an "Spread-reducer".
    I've done this by sending an MouseClick every 40ms.
    This However limits the ROF of some Weapons.

    UPDATE:
    I now made a Toggle Button to use "TAP" firing.
    This Function is also the "Spread-Reducer".
    Hotkey = Numpad6
    Default = TAP OFF



    You can now make settings for Tap fire function of without.
    Rememeber to save them under a different name like:
    (WeaponName)(Attachment) (TAP)
    416 Heavy Barrel Tap



    COPY the code below into an AUTOHOTKEY SCRIPT!

    HotKeys!
    Shots Fire before Going Left/Right, Default = 1( Moves X at the same time as Y)
    SHDown = Ins
    SHUP = Home

    ;Pixels up/down/left/right
    PixelUp = pgup
    PixelDown = pgdn
    PixelLeft = del
    PixelRight = end

    ;On/OFF
    ToggleNoRecoil = NumpadMult

    ;RPM this is set to 1550 wich result in an 40Ms delay on MouseClick
    Setting this any higher will generate an stuttering effect on Rate Of Fire
    DelayUp = NumpadAdd =
    DelayDown = NumpadSub

    ;Save and Load Function
    GetFromIni = Numpad0
    To load settings: Double Click setting in ListView
    to Save: Enter name and Click Save Button
    To Delete: Click Name in ListView and press Delete Button.
    MoveY = LButton ; Click RButton before LButton to use.

     
    Code:
    ;-------------------------------------------------------------------------------
    ;	GENERAL SETTINGS
    ;-------------------------------------------------------------------------------
    
    #NoEnv
    #SingleInstance force
    ;#InstallKeybdHook
    ;#InstallMouseHook
    #include IniLib1.0.ahk
    SetBatchLines -1
    
    
    
    
    ;SetWorkingDir %A_ScriptDir%
    ;ScriptName := A_ScriptName
    ;StringReplace, ScriptName, ScriptName, .ahk,, All0
    ;StringReplace, ScriptName, ScriptName, .exe,, All
    
    ;-------------------------------------------------------------------------------
    ;	Vars
    ;-------------------------------------------------------------------------------
    Tap = 0
    SH = 1
    pixelx = 0
    pixely= 0
    rpm = 1550
    NoRecoil = 0
    enough = 0
    ;xhair = 00
    
    ; X shots before to go Left/Right
    SHDown = Ins
    SHUP = Home
    ;Pixels up/down/left/right
    PixelUp = pgup
    PixelDown = pgdn
    PixelLeft = del
    PixelRight = end
    ;On/OFF
    ToggleNoRecoil = NumpadMult
    ;RPM
    DelayUp = NumpadAdd
    DelayDown = NumpadSub
    ;Save and Load Function
    GetFromIni = Numpad0
    MoveY = LButton
    
    
    
    
    ;-------------------------------------------------------------------------------
    ;	Hotkeys
    ;-------------------------------------------------------------------------------
    Hotkey, ~*$%SHDown%, DoSHDown
    Hotkey, ~*$%SHUp%, DoSHUp
    Hotkey, ~*$%PixelLeft%, DoPixelLeft
    Hotkey, ~*$%PixelRight%, DoPixelRight
    Hotkey, ~*$%PixelUp%, DoPixelUp
    Hotkey, ~*$%PixelDown%, DoPixelDown
    HotKey, ~*$%ToggleNoRecoil%, DoToggleNoRecoil
    HotKey, ~*$%DelayUp%, DoDelayUp
    HotKey, ~*$%DelayDown%, DoDelayDown
    HotKey, ~*$%GetFromIni%, GetFromINI
    #MaxThreadsPerHotkey 1
    Hotkey, ~*$%MoveY%, DoMoveY
    
    
    
    ;-------------------------------------------------------------------------------
    ;	Functions
    ;-------------------------------------------------------------------------------
    
    
    TipRPS(PopupText)
    {
    	Gui, Destroy
    	Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
    	Gui, Color, 000000
    	WinSet, Transparent, 100
    	Gui, Font, s8, norm, Verdana
    	Gui, Add, Text, x5 y5 c00ff00, %PopupText%
    	Gui, Show, NoActivate X0 Y36
    }
    
    TipOn(PopupText)
    {   
    	Gui, Destroy
    	Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
    	Gui, Color, 000000
    	WinSet, Transparent, 100
    	Gui, Font, s8, norm, Verdana
    	Gui, Add, Text, x5 y5 c00ff00, %PopupText%
    	Gui, Show, NoActivate X0 Y18
    }
    
    TipOff(PopupText)
    {
    	Gui, Destroy 
    	Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
    	Gui, Color, 000000
    	WinSet, Transparent, 100
    	Gui, Font, s8, norm, Verdana
    	Gui, Add, Text, x5 y5 cff0000, %PopupText%
    	Gui, Show, NoActivate X0 Y54
    }
    
    
    TipClear:
    {
    SetTimer,TipClear, 2000
    Gui, destroy
    }
    return
    
    ;-------------------------------------------------------------------------------
    ;	Hotkey labels
    ;-------------------------------------------------------------------------------
    Numpad6::
    If Tap = 0
    {
    	Tap +=1
    	TipOn("Tap  = ON")
    }
    else
    {
    	Tap -= 1
    	TipOn("Tap  = OFF")
    }
    return
    
    DoToggleNoRecoil:
    	if NoRecoil < 1
    	{
    		NoRecoil += 1
    		if NoRecoil = 1
    		{
    			SoundBeep, 800, 200
    			TipOn("ON")
    		}
    	}
    	else
    	{
    		NoRecoil := 0
    		SoundBeep, 200, 100
    		SoundBeep, 200, 100
    		TipOff("OFF")
    	}
    	return
    DoSHDown:
            If SH > 1
    			SH -= 1
    		SHK = 0
    		TipOn("SH  = " SH)
    		return
    		
    DoSHUp:
            If SH <20
    			SH += 1
    		SHK = 0
    		TipOn("SH  = " SH)
    		return
    		
    DoPixelLeft:
            if pixelx < 10
                     pixelx += 1
            TipOn("Pixel X Is " pixelX)
            return
    
    DoPixelRight:
            if pixelx > -10
                     pixelx -= 1
            TipOn("Pixel X Is " pixelX)
            return
    
    DoPixelUp:
    	if pixely < 50
    		pixely += 1
    	TipOn("Pixel Y Is " pixelY)
    	return
    
    DoPixelDown:
    	if pixely > 0
    		pixely -= 1
    	TipOn("Pixel Y Is " pixelY)
    	return
    
    DoDelayUp:
    	if rpm > 400
    		rpm -= 10
    	TipRPS("RPM: " rpm "  " "RPS:" f(rpm)) 
    	return
    
    DoDelayDown:
    	if rpm < 4000
    		rpm += 10
    	TipRPS("RPM: " rpm "  " "RPS:" f(rpm))
    	return
    
    DoPeriodUp:
    	if period > 100
    		period -= 100
    	TipOn("PERIOD IS " period)
    	return
    
    DoPeriodDown:
    	if period < 6000
    		period += 100
    	TipOn("PERIOD IS " period)
    	return
    
    
    ;----------------------------------------------SAVE, LOAD, DELETE, FUNC-------------------------------------------------------------------
    ;-----------------------------------------------------------------------------------------------------------------------------------------
    ;Pulls up Listview of Saved Weapon for easy picking.
    GetFromINI:
    Gui, Destroy
    SetTimer, TipClear, Off
    FileRead, ini, config.ini
    ; Create the ListView with 4 columns:0
    gui, add, text, section, Save To INI
    Gui, Add, Edit, r1 vWeaponSend
    Gui, Add, Button, gSaveToIni, Save
    Gui, Add, Button, gDelete, Delete
    gui, add, text, section, Double Click Below to LOAD from INI0
    Gui, Add, ListView, r20 h200 w300 gMyListView, Name|SH|X|Y|RPM|TAP
    
    sections := ini_getAllSectionNames(ini)
    Loop, Parse, sections, `,
    {
        LV_Add("", A_LoopField, ini_getValue(ini, A_LoopField, "SH"),ini_getValue(ini, A_LoopField, "X"),ini_getValue(ini,A_LoopField, "Y"), ini_getValue(ini, A_LoopField, "rpm"), ini_GetValue(ini, A_LoopField, "TAP"))
    }
    
    LV_ModifyCol(20)  ; Auto-size each column to fit its contents.
    LV_ModifyCol()  ; For sorting purposes.
    
    ; Display the window and return. The script will be notified whenever the user double clicks a row.
    Gui, Show
    return
    
    Delete:
    RowNumber = 0  ; This causes the first loop iteration to start the search at the top of the list.
    Loop
    {
        RowNumber := LV_GetNext(RowNumber)  ; Resume the search at the row after that found by the previous iteration.
        if not RowNumber  ; The above returned zero, so there are no more selected rows.
            break
        LV_GetText(Delete, RowNumber)
    	IniDelete, %A_WorkingDir%\config.ini, %Delete%
    	Gosub, GetFromIni
    }
    
    MyListView:
    if A_GuiEvent = DoubleClick
    {
    	LV_GetText(WeaponCall, A_EventInfo)
        LV_GetText(SH, A_EventInfo, 2)  ; Get the text from the row's first field.
        LV_GetText(pixelx, A_EventInfo, 3)
        LV_GetText(pixely, A_EventInfo, 4)  
    	LV_GetText(rpm, A_EventInfo, 5)
    	LV_GetText(Tap, A_EventInfo, 6)
        TipRPS(" Loaded!!    Weapon : " WeaponCall " " "Y : "pixely "  " "X : "pixelx "  "  "RPM : " rpm "  "" SH" "  " SH " "" TAP" TAP) 
    }
    
    
    SaveToINI:   
    {
    	Gui,Submit, Nohide0
    IniDelete, %A_WorkingDir%\config.ini, %WeaponSend%
    IniWrite,%SH%,%A_WorkingDir%\config.ini,%WeaponSend%,SH
    IniWrite,%pixely%,%A_WorkingDir%\config.ini,%WeaponSend%,Y
    IniWrite,%pixelx%,%A_WorkingDir%\config.ini,%WeaponSend%,X
    IniWrite,%rpm%,%A_WorkingDir%\config.ini,%WeaponSend%,rpm
    IniWrite,%TAP%,%A_WorkingDir%\config.ini,%WeaponSend%, Tap
    TipRPS(" Saved!!    Weapon :" WeaponSend " " "Y :" pixely "  " "X : " pixelx "  "  "RPM :" rpm "  ""SH" "  " SH " " "TAP" TAP)
    }
    
    
    GuiClose:
    Settimer, TipClear, 2000
    return
    ;------------------------------------------------------------------------------------------------------------
    ;------------------------------------------------------------------------------------------------------------
    
    DoMoveY: 
    	if NoRecoil = 1	
    		{
    			GetKeyState, state, RButton, P ; RButton must me held down to use the LButton(Mouse)
    			if state = U
    				return
    				loop 
    				{
    					GetKeyState, state2, LButton, P
    					if state2 = U
    					    return
    					    {
    						Clicks = 0	
    						if Tap = 1
    						{
    					       MouseClick, Left,,,,,D
    						   SetMouseDelay, f(rpm)
    						   MouseClick, Left,,,,,U
    					   }
    						     DllCall("mouse_event", "uint",1 , "Uint", 0,"Uint", pixely)
                                 SHK += 1
    						     { 
    						     If SH = %SHK% ; If equals then x
    							{
    						     SHK := 0 ; Resets Counter
    						     DllCall("mouse_event", "uint",1 , "Uint", pixelx,"Uint", 0)						
    					         }
    						     if Tap = 1
    						     {
    							sleep, 1
    						    }
    						    else
    						    {					       
    					        sleep, f(rpm)
    						    }
    							tooltip, %sleep%,0,00
    						}
    					}
    				}
    			}
            
        
    
    	
    
    
    	return
     
    	;-------------------------------interval per shot in Miliseconds----------------------------------------
     
     f(n)
    					   {
    						   Return Round(60000/n)
    						  
    					   }
    return




    - - - Updated - - -

    IniLib1.0.ahk
    Copy/past below script in an text file and rename it IniLib1.0.ahk
    put it in the same folder as script above.
     
    Code:
    /*
    Title: Basic ini string functions
        Operate on variables instead of files. An easy to use ini parser.
        
    About: License
        New BSD License
    Copyright (c) 2010, Tuncay
    All rights reserved.
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.
        * Neither the name of the Tuncay nor the
          names of its contributors may be used to endorse or promote products
          derived from this software without specific prior written permission.
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL Tuncay BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    About: Introduction
        Ini files are used mostly as configuration files. In general, they have the
        ".ini"-extension. It is a simple standardized organization of text data. 
        Many other simple programs use them for storing text.    
        
        AutoHotkey provides three commands IniDelete, IniRead and IniWrite. These
        commands are stable, but they have some disadvantages. First disadvantage
        is, that they access the file directly. The file on the disk is opened, 
        load into memory and then read or manipulated and then saved with every 
        single command.    
        With the custom functions I wrote here, the user accessess on variables 
        instead of files. This is super fast, in comparison to disk access. Ini 
        files can be created by Ahk just like any other variable. But Ahk itself 
        does not have any function to operate on ini strings (variables). If you 
        read often from ini file, then this might for you. 
        
        No other framework or library is required, no special object files are 
        created; just work on ordinary ini file contents or variables. The load
        and save functions are added for comfort reason and are not really needed.
        
        * *First do this:*
        
        > FileRead, ini, config.ini
        
        * *or load default file with:*
        
        > ini_load(ini)
        
        * *or create the content yourself:*
        
        (Start Code)
        ini =
        (
        [Tip]
        TimeStamp = 20090716194758
        [Recent File List]
        File1=F:\testfile.ahk
        File2=Z:\tempfile.tmp
        )
        (End Code)
        
        In this example "Tip" and "Recent File List" are name of the sections. The
        file consist in this example of 2 sections. Every section contains variables,
        so called "keys". Every key is a part of a section. In this example, the 
        section "Tip" have one key "TimeStamp". And every key has a content, 
        called value. The "TimeStamp" key have the value "20090716194758".
        
        After that, you can access and modify the content of the ini variable with 
        the following functions. But the modifications are only temporary and must 
        me saved to disk. This should be done by overwriting the source (not 
        appending).
        
        *Notes*: A keys content (the value) goes until end of line. Any space 
        surroounding the value is at default lost. For best compatibility, the
        names of section and key should consist of alpha (a-z), num (0-9) and the
        underscore only. In general, the names are case insensitiv.
    Links:
        * Lib Home: [https://autohotkey.net/~Tuncay/lib/index.html]
        * Download: [https://autohotkey.net/~Tuncay/lib/ini.zip]
        * Discussion: [https://www.autohotkey.com/forum/viewtopic.php?t=46226]
        * License: [https://autohotkey.net/~Tuncay/licenses/newBSD_tuncay.txt]
    Date:
        2010-09-26
    Revision:
        1.0
    Developers:
        * Tuncay (Author)
        * Mystiq (Tester and Co-Author of an important regex)
        * Fry (Tester)
    Category:
        String Manipulation, FileSystem
    Type:
        Library
    Standalone (such as no need for extern file or library):
        Yes
    StdLibConform (such as use of prefix and no globals use):
        Yes
    Related:
        *Format Specifications (not strictly implemented)*
        * Wikipedia - INI file [https://en.wikipedia.org/wiki/INI_file]
        * Cloanto Implementation of INI File Format [https://www.cloanto.com/specs/ini.html]
        
        *AutoHotkey Commands*
        * IniRead: [https://www.autohotkey.com/docs/commands/IniRead.htm]
        * IniWrite: [https://www.autohotkey.com/docs/commands/IniWrite.htm]
        * IniDelete: [https://www.autohotkey.com/docs/commands/IniDelete.htm]
        
        *Other Community Solutions*
        * INI Library by Titan: [https://www.autohotkey.com/forum/viewtopic.php?t=26141]
        * [Class] IniFile by bmcclure: [https://www.autohotkey.com/forum/viewtopic.php?t=41506]
        * [module] Ini by majkinetor: [https://www.autohotkey.com/forum/viewtopic.php?t=22495]
        * Auto read,load and save by Superfraggle: [https://www.autohotkey.com/forum/viewtopic.php?t=21346]
        * globalsFromIni by Tuncay: [https://www.autohotkey.com/forum/viewtopic.php?t=27928]
        * Read .INI file in one go by Smurth: [https://www.autohotkey.com/forum/viewtopic.php?t=36601]
    About: Examples
        
    Usage:
        
        (Code)
        value := ini_getValue(ini, "Section", "Key")                    ; <- Get value of a key.
        value := ini_getValue(ini, "", "Key")                           ; <- Get value of first found key.
        key := ini_getKey(ini, "Section", "Key")                        ; <- Get key/value pair.
        section := ini_getSection(ini, "Section")                       ; <- Get full section with all keys.
        
        ini_replaceValue(ini, "Section", "Key", A_Now)                  ; -> Update value of a key.
        ini_replaceKey(ini, "Section", "Key")                           ; -> Delete a key.
        ini_replaceSection(ini, "Section", "[Section1]Key1=0`nKey2=1")  ; -> Replace a section with all its keys.
        
        ini_insertValue(ini, "Section", "Key" ",ListItem")              ; -> Add a value to existing value.
        ini_insertKey(ini, "Section", "Key=" . A_Now)                   ; -> Add a key/value pair.
        ini_insertSection(ini, "Section", "Key1=ini`nKey2=Tuncay")      ; -> Add a section.
        
        keys := ini_getAllKeyNames(ini, "Section")                      ;
        <- Get a list of all key names.
        sections := ini_getAllSectionNames(ini)                         ; <- Get a list of all section names.
        (End Code)
    About: Functions
    Parameters:
        Content         - Content of an ini file (also this can be one section
                            only).
        Section         - Unique name of the section. Some functions support the
                            default empty string "". This leads to look up at 
                            first found section. 
        Key             - Name of the variable under the section.
        Replacement     - New content to use.
        PreserveSpace   - Should be set to 1 if spaces around the value of a key
                            should be saved, otherwise they are lost. The
                            surrounding single or double quotes are also lost.
        The 'get' functions returns the desired contents without touching the 
        variable.
        
        The 'replace' and 'insert' functions changes the desired content directly
        and returns 1 for success and 0 otherwise.
        
        There are some more type of functions and parameters. But these are not listed
        here.
    Remarks:
        On success, ErrorLevel is set to '0'. Otherwise ErrorLevel is set to '1' if
        key under desired section is not found.
        
        The functions are not designed to be used in all situations. On rare 
        conditions, the result could be corrupt or not usable. In example, there 
        is no handling of commas inside the key or section names.
        Any "\E" would end the literal sequence and switch back to regex. The
        "\E" sequence is not escaped, because its very uncommon to use backslashes
        inside key and section names. To workaround this, replace at every key or
        section name the "\E" part with "\E\\E\Q":
        
        > Name := "Folder\Edit\Test1"
        > IfInString, Name, \
        > {
        >     StringReplace, Name, Name, \E, \E\\E\Q, All
        > }
        > MsgBox % ini_getValue(ini, "paths", Name)
        This allows us to work with regex, but then at the end it should be closed 
        with "\Q" again.
        > ; Used regex at keyname: "Time.*"
        > value := ini_getValue(ini, "Tip", "\ETime.*\Q")
    */
    
    
    /*
    _______________________________________________________________________________
    _______________________________________________________________________________
    Section: Parse
    About: About
    Brief:
        Main functions for getting, setting and updating section or key.
    _______________________________________________________________________________
    _______________________________________________________________________________
    */
    
    
    ; .............................................................................
    ; Group: Get
    ;   Functions for reading data.
    ; .............................................................................
    
    
    /*
    Func: ini_getValue
        Read and return a value from a key
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Key             - Name of the variable under the section.
        PreserveSpace   - *Optional* Should be set to 1 if spaces around the value 
                            of a key should be saved, otherwise they are lost. The
                            surrounding single or double quotes are also lost.
                            Default is deleting surrounding spaces and quotes.
    Returns:
        On success the content of desired key is returned, otherwise an empty string.
    Examples:
        > value := ini_getValue(ini, "Tip", "TimeStamp")
        > MsgBox %value%
        *Output:*
        > 20090716194758
    */
    ini_getValue(ByRef _Content, _Section, _Key, _PreserveSpace = False)
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
        {
             _Section = \[\s*?\Q%_Section%\E\s*?]
        }
        ; Note: The regex of this function was rewritten by Mystiq.
        RegEx = `aiU)(?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R\s*\Q%_Key%\E\s*=(.*)(?=\R|$)
    /*
        RegEx := "`aiU)"
          . "(?:\R|^)\s*" . _Section . "\s*"         ;-- section
          . "(?:"
          . "\R\s*"                           ;-- empty lines
          . "|\R\s*[\w\s]+\s*=\s*.*?\s*(?=\R)"      ;-- OR other key=value pairs
          . "|\R\s*[;#].*?(?=\R)"                  ;-- OR commented lines
          . ")*"
          . "\R\s*\Q" . _Key . "\E\s*=(.*)(?=\R|$)"   ;-- match
    */
       
        If RegExMatch(_Content, RegEx, Value)
        {
            If Not _PreserveSpace
            {
                Value1 = %Value1% ; Trim spaces.
                FirstChar := SubStr(Value1, 1, 1)
                If (FirstChar = """" AND SubStr(Value1, 0, 1)= """"
                    OR FirstChar = "'" AND SubStr(Value1, 0, 1)= "'")
                {
                    StringTrimLeft, Value1, Value1, 1
                    StringTrimRight, Value1, Value1, 1
                }
            }
            ErrorLevel = 0
        }
        Else
        {
            ErrorLevel = 1
            Value1 =
        }
        Return Value1
    }
    
    
    /*
    Func: ini_getKey
        Read and return a complete key with key name and content.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Key             - Name of the variable under the section.
    Returns:
        On success the key and value pair in one string is returned, otherwise an empty string.
    Examples:
        > key := ini_getKey(ini, "Tip", "TimeStamp")
        > MsgBox %key%
        *Output:*
        > TimeStamp = 20090716194758
    */
    ini_getKey(ByRef _Content, _Section, _Key)
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
       
        ; Note: The regex of this function was rewritten by Mystiq.
        RegEx = `aiU)(?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R(\s*\Q%_Key%\E\s*=.*)(?=\R|$)
        If RegExMatch(_Content, RegEx, Value)
            ErrorLevel = 0
        Else
        {
            ErrorLevel = 1
            Value1 =
        }
        Return Value1
    }
    
    
    /*
    Func: ini_getSection
        Read and return a complete section with section name.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. (An enmpty string "" is not
                            working.)
    Returns:
        On success the entire section in one string is returned, otherwise an empty string.
        
    Examples:
        > section := ini_getSection(ini, "Tip")
        > MsgBox %section% 
        *Output:*
        > [Tip]
        > TimeStamp = 20090716194758
    */
    ini_getSection(ByRef _Content, _Section)
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
        RegEx = `aisUS)^.*(%_Section%\s*\R?.*)(?:\R*\s*(?:\[.*?|\R))?$
        If RegExMatch(_Content, RegEx, Value)
            ErrorLevel = 0
        Else
        {
            ErrorLevel = 1
            Value1 =
        }
        Return Value1
    }
    
    /*
    Func: ini_getAllValues
        Read and get a new line separated list of all values in one go.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - *Optional* Unique name of the section.
        Count           - *Variable Optional* The number of found values/keys.
    Returns:
        On success a newline "`n" separated list with all name of keys is returned, 
        otherwise an empty string. If section is specified, only those from that
        section is returned, otherwise from all sections.
    Remarks:
        Other than the other getAll-functions list separator, this function uses
        the new line "`n" character instead the comma "," for separating values.
        Also other than the other getValue functions, this does not provide any
        preserveSpaces option, as it allways preserves surrounding spaces and
        quotes.
    Examples:
        > values := ini_getAllValues(ini, "Recent File List")
        > MsgBox %values%
        *Output:*
        > F:\testfile.ahk
        > Z:\tempfile.tmp
    */
    ini_getAllValues(ByRef _Content, _Section = "", ByRef _count = "")
    {
        RegEx = `aisUmS)^(?=.*)(?:\s*\[\s*?.*\s*?]\s*|\s*?.+\s*?=(.*))(?=.*)$
        If (_Section != "")
            Values := RegExReplace(ini_getSection(_Content, _Section), RegEx, "$1`n", Match)
        Else
            Values := RegExReplace(_Content, RegEx, "$1`n", Match)
        If Match
        {
            Values := RegExReplace(Values, "`aS)\R+", "`n")
            ; Workaround, sometimes it catches sections. Whitespaces only should be eliminated also.
            Values := RegExReplace(Values, "`aS)\[.*?]\R+|\R+$|\R+ +$", "") 
            StringReplace, Values, Values, `n, `n, UseErrorLevel
            _count := ErrorLevel ? ErrorLevel : 0
            StringTrimLeft, Values, Values, 1
            ErrorLevel = 0
        }
        Else
        {
            ErrorLevel = 1
            _count = 0
            Values =
        }
        Return Values
    }
    
    
    /*
    Func: ini_getAllKeyNames
        Read and get a comma separated list of all key names in one go.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - *Optional* Unique name of the section.
        Count           - *Variable Optional* The number of found keys.
    Returns:
        On success a comma separated list with all name of keys is returned, 
        otherwise an empty string. If section is specified, only those from that
        section is returned, otherwise from all sections.
        
    Examples:
        > keys := ini_getAllKeyNames(ini, "Recent File List")
        > MsgBox %keys%
        *Output:*
        > File1,File2
    */
    ini_getAllKeyNames(ByRef _Content, _Section = "", ByRef _count = "")
    {
        RegEx = `aisUmS)^.*(?:\s*\[\s*?.*\s*?]\s*|\s*?(.+)\s*?=.*).*$
        If (_Section != "")
            KeyNames := RegExReplace(ini_getSection(_Content, _Section), RegEx, "$1", Match)
        Else
            KeyNames := RegExReplace(_Content, RegEx, "$1", Match)
        If Match
        {
            KeyNames := RegExReplace(KeyNames, "S)\R+", ",")
            ; Workaround, sometimes it catches sections. Whitespaces only should be eliminated also.
            KeyNames := RegExReplace(KeyNames, "S)\[.*?],+|,+$|,+ +", "") 
            StringReplace, KeyNames, KeyNames, `,, `,, UseErrorLevel
            _count := ErrorLevel ? ErrorLevel : 0
            StringTrimLeft, KeyNames, KeyNames, 1
            ErrorLevel = 0
        }
        Else
        {
            ErrorLevel = 1
            _count = 0
            KeyNames =
        }
        Return KeyNames
    }
    
    
    /*
    Func: ini_getAllSectionNames
        Read and get a comma separated list of all section names in one go.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Count           - *Variable Optional* The number of found sections.
    Returns:
        On success a comma separated list with all name of sections is returned, 
        otherwise an empty string.
        
    Examples:
        > sections := ini_getAllSectionNames(ini)
        > MsgBox %sections%
        *Output:*
        > Tip,Recent File List
    */
    ini_getAllSectionNames(ByRef _Content, ByRef _count = "")
    {
        RegEx = `aisUmS)^.*(?:\s*\[\s*?(.*)\s*?]\s*|.+=.*).*$
        SectionNames := RegExReplace(_Content, RegEx, "$1", MatchNum)
        If MatchNum
        {
            SectionNames := RegExReplace(SectionNames, "S)\R+", ",", _count)
            ; Workaround, whitespaces only should be eliminated.
            SectionNames := RegExReplace(SectionNames, "S),+ +", "") 
            StringReplace, SectionNames, SectionNames, `,, `,, UseErrorLevel
            _count := ErrorLevel ? ErrorLevel : 0
            _count := _count ? _count : 0
            StringTrimRight, SectionNames, SectionNames, 1
            ErrorLevel = 0
        }
        Else
        {
            ErrorLevel = 1
            _count = 0
            SectionNames =
            
            
        }
        Return SectionNames
    }
    
    
    ; .............................................................................
    ; Group: Replace
    ;   Functions for replacing existing data.
    ; .............................................................................
    
    
    /*
    Func: ini_replaceValue
        Updates the value of a key.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Key             - Name of the variable under the section. 
        Replacement     - *Optional* New content to use. If not specified, the 
                            content will be replaced with no content. That means
                            it is deleted/set to empty string.
        PreserveSpace   - *Optional* Should be set to 1 if spaces around the value 
                            of a key should be saved, otherwise they are lost. The
                            surrounding single or double quotes are also lost.
                            Default is deleting surrounding spaces.
    Returns:
        Returns 1 if key is updated to new value, and 0 otherwise (opposite of 
        ErrorLevel). 
        
    Examples:
        > ini_replaceValue(ini, "Tip", "TimeStamp", 2009)
        > value := ini_getValue(ini, "Tip", "TimeStamp")
        > MsgBox %value%
        *Output:*
        > 2009
    */
    ini_replaceValue(ByRef _Content, _Section, _Key, _Replacement = "", _PreserveSpace = False)
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
        If Not _PreserveSpace
        {
            _Replacement = %_Replacement% ; Trim spaces.
            FirstChar := SubStr(_Replacement, 1, 1)
            If (FirstChar = """" AND SubStr(_Replacement, 0, 1)= """"
                OR FirstChar = "'" AND SubStr(_Replacement, 0, 1)= "'")
            {
                StringTrimLeft, _Replacement, _Replacement, 1
                StringTrimRight, _Replacement, _Replacement, 1
            }
        }
        ; Note: The regex of this function was written by Mystiq.
        RegEx = `aiU)((?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R\s*\Q%_Key%\E\s*=).*((?=\R|$))
        _Content := RegExReplace(_Content, RegEx, "$1" . _Replacement . "$2", isReplaced, 1)
        If isReplaced
            ErrorLevel = 0
        Else
            ErrorLevel = 1
        Return isReplaced
    }
    
    
    /*
    Func: ini_replaceKey
        Changes complete key with its name and value.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Key             - Name of the variable under the section.
        Replacement     - *Optional* New content to use. If not specified, the 
                            content will be replaced with no content. That means
                            it is deleted/set to empty string.
                          The replacement should contain an equality sign.
                          (Expected form: "keyName=value")
    Returns:
        Returns 1 if key is updated to new value, and 0 otherwise (opposite of 
        ErrorLevel). 
        
    Examples:
        > ini_replaceKey(ini, "Tip", "TimeStamp", "TimeStamp=1980")
        > value := ini_getValue(ini, "Tip", "TimeStamp")
        > MsgBox %value%
        *Output:*
        > 1980
    */
    ini_replaceKey(ByRef _Content, _Section, _Key, _Replacement = "")
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
        If _Replacement !=
        {
            _Replacement = %_Replacement%
            _Replacement = `n%_Replacement%
        }
        ; Note: The regex of this function was written by Mystiq.
        RegEx = `aiU)((?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*)\R\s*\Q%_Key%\E\s*=.*((?=\R|$))
        _Content := RegExReplace(_Content, RegEx, "$1" . _Replacement . "$2", isReplaced, 1)
        If isReplaced
            ErrorLevel = 0
        Else
            ErrorLevel = 1
        Return isReplaced
    }
    
    /*
    Func: ini_replaceSection
        Changes complete section with all its keys and contents.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Replacement     - *Optional* New content to use. If not specified, the 
                            content will be replaced with no content. That means
                            it is deleted/set to empty string.
                          The replacement should contain everything what a section
                          contains, like the "[" and "]" before and after section
                          name and all keys with its equality sign and value.
                          (Expected form: "[sectionName]`nkeyName=value")
    Returns:
        Returns 1 if key is updated to new value, and 0 otherwise (opposite of 
        ErrorLevel). 
        
    Examples:
        > ini_replaceSection(ini, "Tip", "TimeStamp", "[Section1]`nKey1=Hello`nKey2=You!")
        > value := ini_getValue(ini, "Section1", "Key1")
        > MsgBox %value%
        *Output:*
        > Hello
    */
    ini_replaceSection(ByRef _Content, _Section, _Replacement = "")
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
        RegEx = `aisU)^(\s*?.*)%_Section%\s*\R?.*(\R*\s*(?:\[.*|\R))?$ 
        _Content := RegExReplace(_Content, RegEx, "$1" . _Replacement . "$2", isReplaced, 1)
        If isReplaced
            ErrorLevel = 0
        Else
            ErrorLevel = 1
        Return isReplaced
    }
    
    
    ; .............................................................................
    ; Group: Insert
    ;   Functions for adding new data.
    ; .............................................................................
    
    
    /*
    Func: ini_insertValue
        Adds value to the end of existing value of specified key.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. If it is specified to "", 
                            then section is ignored and first found key is get.
        Key             - Name of the variable under the section.
        Value           - Value to be inserted at end of currently existing value.
        PreserveSpace   - *Optional* Should be set to 1 if spaces around the value 
                            of a key should be saved, otherwise they are lost. The
                            surrounding single or double quotes are also lost.
                            Default is deleting surrounding spaces.
    Returns:
        Returns 1 if value is inserted, and 0 otherwise (opposite of ErrorLevel).
        
    Examples:
        > ini_insertValue(ini, "Recent File List", "File1", ", " . A_ScriptName)
        > value := ini_getValue(ini, "Recent File List", "File1")
        > MsgBox %value%
        *Output:*
        > F:\testfile.ahk, ini.ahk
    */
    ini_insertValue(ByRef _Content, _Section, _Key, _Value, _PreserveSpace = False)
    {
        If (_Section = "")
            _Section = (?:\[.*])?
        Else
             _Section = \[\s*?\Q%_Section%\E\s*?]
        If Not _PreserveSpace
        {
            _Value = %_Value% ; Trim spaces.
            FirstChar := SubStr(_Value, 1, 1)
            If (FirstChar = """" AND SubStr(_Value, 0, 1)= """"
                OR FirstChar = "'" AND SubStr(_Value, 0, 1)= "'")
            {
                StringTrimLeft, _Value, _Value, 1
                StringTrimRight, _Value, _Value, 1
            }
        }
        ; Note: The regex of this function was written by Mystiq.
        RegEx = S`aiU)((?:\R|^)\s*%_Section%\s*(?:\R\s*|\R\s*.+\s*=\s*.*?\s*(?=\R)|\R\s*[;#].*?(?=\R))*\R\s*\Q%_Key%\E\s*=.*?)((?=\R|$))
        _Content := RegExReplace(_Content, RegEx, "$1" . _Value . "$2", isInserted, 1)
        If isInserted
            ErrorLevel = 0
        Else
            ErrorLevel = 1
        Return isInserted
    }
    
    
    /*
    Func: ini_insertKey
        Adds a key pair with its name and value, if key does not already exists.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section. (An enmpty string "" is not
                            working.)
        Key             - Key and value pair splitted by an equality sign.
    Returns:
        Returns 1 if key is inserted, and 0 otherwise (opposite of ErrorLevel).
    Remarks:
        Currently, it works as a workaround with different function calls instead 
        of one regex call. This makes it slower against the other functions.
        
    Examples:
        > ini_insertKey(ini, "Tip", "TimeNow=" . 20090925195317)
        > value := ini_getValue(ini, "Tip", "TimeNow")
        > MsgBox %value%
        *Output:*
        > 20090925195317
    */
    ini_insertKey(ByRef _Content, _Section, _Key)
    {
        StringLeft, K, _Key, % InStr(_Key, "=") - 1
        sectionCopy := ini_getSection(_Content, _Section)
        keyList := ini_getAllKeyNames(sectionCopy)
        isInserted = 0
        If K Not In %keyList%
        {
            sectionCopy .= "`n" . _Key
            isInserted = 1
        }
        If isInserted
        {
            ini_replaceSection(_Content, _Section, sectionCopy)
            ErrorLevel = 0 
        }
        Else
        {
            ErrorLevel = 1
        } 
        Return isInserted
    }
    
    /*
    Func: ini_insertSection
        Adds a section and its keys, if section does not exist already.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section to be added and checked if
                            it is already existing.
        Keys            - *Optional* Set of key value pairs. Every key and value 
                            pair should be at its own line divided by a new line 
                            character.
    Returns:
        Returns 1 if section and the keys are inserted, and 0 otherwise (opposite 
        of ErrorLevel).
        
    Examples:
        > ini_insertSection(ini, "Tip", "Files", "Name1=Programs`nPath1=C:\Program Files")
        > value := ini_getValue(ini, "Files", "Name1")
        > MsgBox %value%
        *Output:*
        > Programs
    */
    ini_insertSection(ByRef _Content, _Section, _Keys = "")
    {
        RegEx = `aisU)^.*\R*\[\s*?\Q%_Section%\E\s*?]\s*\R+.*$
        If Not RegExMatch(_Content, RegEx)
        {
            _Content = %_Content%`n[%_Section%]`n%_Keys%
            isInserted = 1
            ErrorLevel = 0
        }
        Else
        {
            isInserted = 0
            ErrorLevel = 1
        }
        Return isInserted
    }
    
    
    /*
    _______________________________________________________________________________
    _______________________________________________________________________________
    Section: Additional
    About: About
    Brief:
        Other functions besides the core ones.
    _______________________________________________________________________________
    _______________________________________________________________________________
    */
    
    ; .............................................................................
    ; Group: File
    ;   Related routines about file handling with some comfort.
    ; .............................................................................
    
    /*
    Func: ini_load
        Reads an ini file into a variable and resolves any part of the path.
    Parameters:
        Content         - *Variable* On success, the file is loaded into this 
                            variable.
        Path            - *Optional* Source filename or -path to look for. It
                            can contain wildcards. If this is an existing directory 
                            (or contains backslash at the end), then default 
                            filename is appended. Default filename is ScriptName 
                            with ".ini" extension (in example "script.ini").
                            Relative Pathes are solved to current WorkingDir. 
                            Every part of the path (like filename and -extension) 
                            are optional. Default extension is logically ".ini". 
                            Binary files are not loaded. Empty string is resolved 
                            to "ScriptPathNoExt + .ini".
        convertNewLine  - *Optional* If this is true, all "`r`n" (CRLF) new line
                            sequence of files content will be replaced with "`n" 
                            (LF) only. Normally this is not necessary.
    Returns:
        The resolved full path which was searched for. If file exists, the full 
        path with correct case from the disk is get.
    Remarks:
        This function is not necessary to work with the ini-library. In fact, in 
        the heart, it does nothing else than FileRead. The filled variable is an
        ordinary string. You can work with custom functions other from this library
        on these variables, as if you would do allways.
        
        If file is not found or content is binary, or at any other reason ErrorLevel
        is set to 1 and Content is set to "" (empty).
    Examples:
        > ; Load content of default file into variable "ini".
        > path := ini_load(ini)
        > MsgBox %path%
        *Output:*
        > E:\Tuncay\AutoHotkey\scriptname.ini
    */
    ini_load(ByRef _Content, _Path = "", _convertNewLine = false)
    {
        ini_buildPath(_Path)
        error := true ; If file is found next, then its set to false.
        Loop, %_Path%, 0, 0
        {
            _Path := A_LoopFileLongPath
            error := false
            Break
        }    
        If (error = false)
        {
            FileRead, _Content, %_Path%
            If (ErrorLevel)
            {
                error := true
            }
            Else
            {
                FileGetSize, fileSize, %_Path%
                If (fileSize != StrLen(_Content))
                {
                    error := true
                }
            }
        }
        If (error)
        {
            _Content := ""
        }
        Else If (_convertNewLine)
        {
            StringReplace, _Content, _Content, `r`n, `n, All
        }
        ErrorLevel := error
        Return _Path
    }
    
    
    /*
    Func: ini_save
        Writes an ini file from variable to disk.
    Parameters:
        Content         - *Variable* Ini content to save at given path on disk.
        Path            - *Optional* Source filename or -path to look for. It
                            can contain wildcards. If this is an existing directory 
                            (or contains backslash at the end), then default 
                            filename is appended. Default filename is ScriptName 
                            with ".ini" extension (in example "script.ini").
                            Relative Pathes are solved to current WorkingDir. 
                            Every part of the path (like filename and -extension) 
                            are optional. Default extension is logically ".ini". 
                            Binary files are not loaded. Empty string is resolved 
                            to "ScriptPathNoExt + .ini".
        convertNewLine  - *Optional* If this is true, all "`n" (LF) new line
                            sequence of files content will be replaced with "`r`n"
                            (CRLF). Normally, Windows default new line sequence is
                            "`r`n". (Source is not changed with this option.)
        overwrite       - *Optional* If this mode is enabled (true at default), 
                            the source file will be updated. Otherwise, the
                            file is saved to disk only if source does not exist
                            already.
    Returns:
        The resolved full path which was searched for.
    Remarks:
        If overwrite mode is enabled and file could not be deleted, then ErrorLevel 
        is set to 1. Otherwise, if overwriting an existing file is not allowed 
        (overwrite = false) and file is existing, then ErrorLevel will be set to 1 
        also.
    Examples:
        > ; Write and update content of ini variable to default file.
        > path := ini_save(ini)
        > MsgBox %path%
        *Output:*
        > E:\Tuncay\AutoHotkey\scriptname.ini
    */
    ini_save(ByRef _Content, _Path = "", _convertNewLine = true, _overwrite = true)
    {
        ini_buildPath(_Path)
        error := false
        If (_overwrite)
        {
            Loop, %_Path%, 0, 0
            {
                _Path := A_LoopFileLongPath
                Break
            }    
            If FileExist(_Path)
            {
                FileDelete, %_Path%
                If (ErrorLevel)
                {
                    error := true
                }
            }
        }
        Else If FileExist(_Path)
        {
            error := true
        }
        If (error = false)
        {
            If (_convertNewLine)
            {
                StringReplace, _Content, _Content, `r`n, `n, All
                StringReplace, _Content, _Content, `n, `r`n, All
                FileAppend, %_Content%, %_Path%
            }
            Else
            {
                FileAppend, %_Content%, *%_Path%
            }
            If (ErrorLevel)
            {
                error := true
            }
        }
        ErrorLevel := error
        Return _Path
    }
    
    ; An internally used function, made not for public.
    ini_buildPath(ByRef _path)
    {
        ; Set to default wildcard if filename or exension are not set.
        If (_Path = "")
        {
            _Path := RegExReplace(A_ScriptFullPath, "S)\..*?$") . ".ini"
        }
        Else If (SubStr(_Path, 0, 1) = "\")
        {
            _Path .= RegExReplace(A_ScriptName, "S)\..*?$") . ".ini"
        }
        Else
        {
            If (InStr(FileExist(_Path), "D"))
            {
                ; If the current path is a directory, then add default file pattern to the directory.
                _Path .= "\" . RegExReplace(A_ScriptName, "S)\..*?$") . ".ini"
            }
            Else
            {
                ; Check all parts of path and use defaults, if any part is not specified.
                SplitPath, _Path,, fileDir, fileExtension, fileNameNoExt
                If (fileDir = "")
                {
                    fileDir := A_WorkingDir
                }
                If (fileExtension = "")
                {
                    fileExtension := "ini"
                }
                If (fileNameNoExt = "")
                {
                    fileNameNoExt := RegExReplace(A_ScriptName, "S)\..*?$")
                }
                _Path := fileDir . "\" . fileNameNoExt . "." . fileExtension
            }
        }
        Return 0
    }
    
    ; .............................................................................
    ; Group: Edit
    ;   These manipulates the whole ini structure (or an extracted section only).
    ; .............................................................................
    
    /*
    Func: ini_repair
        Repair and build an ini from scratch. Leave out comments and trim unneeded 
        whitespaces.
    Parameters:
        Content         - Content of an ini file (also this can be one 
                            section only).
        PreserveSpace   - *Optional* Should be set to 1 if spaces around the value 
                            of a key should be saved, otherwise they are lost. 
                            Default is deleting surrounding spaces.
        CommentSymbols  - *Optional* List of characters which are should be treated 
                            as comment symbols. Every single character in list is 
                            a symbol. Default are ";" and "#", in example defined 
                            as ";#". 
        LineDelim       - *Optional* A sequence of characters which should be the
                            delimiter as the line end symbol. Default is "`n", a
                            new line.
    Returns:
        The new formatted ini string with trimmed whitespaces and without comments.
    Remarks:
        Other than the most other functions here, the ini Content variable is not
        a byref and will not manipulated directly. The return value is the new ini.
        The LineDelim option can be leaved as is. Internally all commands of 
        AutoHotkey like MsgBox or FileAppend are working correctly with this.
        
        What it does is, building a new ini content string from an existing one.
        The reason to use this function is, if anyone have problems with the 
        source ini because of whitespaces or comments and formatting. The new
        resulting ini is consistently reduced to standard ini format (at least,
        it should).
        Dublicate key entries in same section are merged into one key. The last
        instance overwrites just the one before.
    Examples:
        (code)
        ini =
        (
        
            [ malformed section  ]
    city   =  Berlin'
    whatever='this ; is nasty'
         [bad]
    cat    =     'miao'
        )
        ini := ini_repair(ini, true)
        MsgBox %ini%
        (end)
        *Output:*
        (code)
    [malformed section]
    city=  Berlin'
    whatever='this 
    [bad]
    cat=     'miao'
        (end)
    */
    ini_repair(_Content, _PreserveSpace = False, _CommentSymbols = ";#", _LineDelim = "`n")
    {
        If (_CommentSymbols != "")
        {
            regex = `aiUSm)(?:\R\s*|(s*|\t*))[%_CommentSymbols%].*?(?=\R)
            _Content := RegExReplace(_Content, regex, "$1")
        }
        Loop, Parse, _Content, `n, `r
        {
            If (RegExMatch(A_LoopField, "`aiSm)\[\s*(.+?)\s*]", Match))
            {
                newIni .= _LineDelim . "[" . Match1 . "]"
                section := Match1
                KeyList := ""
            }
            Else If (RegExMatch(A_LoopField, "`aiSm)\s*(\b(?:.+?|\s?)\b)\s*=(.*)", Match))
            {
                If (_PreserveSpace = false)
                {
                    Match2 = %Match2%
                }
                If Match1 Not in %KeyList% ; Disallowes dublicate.
                {
                    KeyList .= "," . Match1
                }
                Else
                {
                    ; As a workaround it should be just deleted, because if set 
                    ; here the surrounding whitespaces are lost.
                    ini_replaceKey(newIni, section, Match1, "")
                }
                newIni .= _LineDelim . Match1 . "=" . Match2
            }
        }
        StringReplace, newIni, newIni, %_LineDelim%
        If (newIni != "")
        {
            ErrorLevel := 0
        }
        Else
        {
            ErrorLevel := 1
        }
        Return newIni
    }
    
    
    /*
    Func: ini_mergeKeys
        Merge two ini sources into first one. Adds new sections and keys and 
        processess existing keys.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only). This is the destination where new 
                            sections and keys are added into.
        source          - *Variable* This is also an ini content from which to 
                            retrieve the new data. These will be added into Content 
                            variable.
        updateMode      - *Optional* Defines how existing keys should be processed.
                            Default is ('1') overwriting last instance with newest 
                            one. 
            updateMode: '1' - ("Default") Replace existng key with newest/last one
                        from source.
            
            updateMode: '2' - Append everything to existing key in Content.
            
            updateMode: '3' - Replace only if source is higher than destination key
                        in Content.
            
            updateMode: '4' - Exclude keys in Content, which exists in both sources.
            
            updateMode: '0' - ("Or any other value") Does not manipulate existing keys
                        in Content, leaving them in their orginal state. Just add 
                        new unknown keys to Content.
                            
    Returns:
        Returns the steps taken to manipulate the destination Content. Every added or 
        manipulated key and section are rising by 1 the return value. 0 if nothing is
        changed.
    Remarks:    
        ErrorLevel is set to '1' if something is changed in Content, '0' otherwise.
        
        The Content variable is updated with the content from source. This means, new
        sections and keys are added allways. In a conflict where same key was found 
        in source again, in case it is existing in Content already, then the variable
        updateMode defines how they should be processed. Default is, to use last found
        key.
    Examples:
        (code)
        ini1=
        (LTrim
            [vasara]
            tuni=1232
            edg=94545
            k=1
        )
        ini2=
        (LTrim
            [vasara]
            tuni=9999
            c=
            edg=5
            [taitos]
            isa=17
        )
        ini_mergeKeys(ini1, ini2)
        MsgBox %ini1%
        (end)
        *Output:*
        (code)
            [vasara]
            tuni=9999
            edg=5
            k1
            c=
            [taitos]
            isa=17
        (end)
    */
    ini_mergeKeys(ByRef _Content, ByRef _source, _updateMode = 1)
    {
        steps := 0
        laststep := 0
        destSectionNames := ini_getAllSectionNames(_Content), sourceSectionNames := ini_getAllSectionNames(_source)
        Loop, Parse, sourceSectionNames, `,
        {
            sectionName := A_LoopField
            sourceSection := ini_getSection(_source, sectionName)
            If sectionName Not In %destSectionNames%
            {
                _Content .= "`n" . sourceSection
                steps++
                Continue
            }
            Else
            {
                destSection := ini_getSection(_Content, sectionName), destKeyNames := ini_getAllKeyNames(destSection), sourceKeyNames := ini_getAllKeyNames(sourceSection)
                Loop, Parse, sourceKeyNames, `,
                {
                    keyName := A_LoopField
                    If keyName Not In %destKeyNames%
                    {
                        destSection .= "`n" . ini_getKey(sourceSection, sectionName, keyName)
                        steps++
                        Continue
                    }
                    Else If (_updateMode = 1)
                    {
                        ini_replaceValue(destSection, sectionName, keyName, ini_getValue(sourceSection, sectionName, keyName))
                        steps++
                    }
                    Else If (_updateMode = 2)
                    {
                        ini_replaceValue(destSection, sectionName, keyName, ini_getValue(destSection, sectionName, keyName) . ini_getValue(sourceSection, sectionName, keyName))
                        steps++
                    }
                    Else If (_updateMode = 3)
                    {
                        If ((sourceValue := ini_getValue(sourceSection, sectionName, keyName)) > ini_getValue(destSection, sectionName, keyName))
                        {
                            ini_replaceValue(destSection, sectionName, keyName, sourceValue)
                            steps++
                        }
                    }
                    Else If (_updateMode = 4)
                    {
                        ini_replaceKey(destSection, sectionName, keyName, "")
                        steps++
                    }
                }
                If (laststep != steps)
                {
                    laststep := steps
                    ini_replaceSection(_Content, sectionName, destSection)
                }
            }
        }
        If (steps > 0)
        {
            ErrorLevel := 0
        }
        Else
        {
            ErrorLevel := 1
        }
        Return steps
    }
    
    
    ; .............................................................................
    ; Group: Convert
    ;   Export and import functions to convert ini structure.
    ; .............................................................................
    
    
    /*
    Func: ini_exportToGlobals
        Creates global variables from the ini structure.
    Parameters:
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        CreateIndexVars - *Optional* If this is set to 'true', some additional 
                            variables are created. These are variables for indexed
                            access of sections and keys. The scheme how the variables
                            named are described below under Remarks.
        Prefix          - *Optional* This is the leading part of all created variable
                            names. (Default: "ini")
        Seperator       - *Optional* This is part of all created variable names. It
                            is added between every section and key part and the 
                            leading part to separate them. (Default: "_")
        SectionSpaces   - *Optional* Every space inside section name will be replaced
                            by this character or string. This is needed for creating
                            AutoHotkey variables, which cannot hold spaces at name.
                            Default is to delete any space with empty value: "".
        PreserveSpace   - *Optional* Should be set to 1 if spaces around the value 
                            of a key should be saved, otherwise they are lost.
                            Surrounding quotes (" or ') are also lost, if not set
                            to 1. Default is deleting surrounding spaces and quotes.
    Returns:
        Gets count of all created keys (attention, keys in sense of ini keys, not variables). 
    Remarks:
        Creates global variables from ini source. The scheme for building the variables is
        following: 
        
        > Prefix  +  Seperator  +  SectionName  + Seperator  +  KeyName
        >   ini   +      _      +      Tip      +     _      + TimeStamp
        > --------------------------------------------------------------
        > ini_Tip_TimeStamp := "20090716194758"
        
        Standard prefix to every variable is "ini" and all parts are delimited by the 
        separator "_". The SectionSpaces parameter deletes at default every space from 
        name of section, because spaces inside ahk variable names are not allowed.
    CreateIndexVars:    
        These variables are created additionally to the other variables, if option 
        CreateIndexVars is set to true (or 1 or any other value evaluating to true).
        
        Scheme for sections
        > Prefix  +  Seperator  +  Index
        >   ini   +      _      +    1
        > ------------------------------
        > ini_1 := "Tip"
        
        Scheme for keys
        > Prefix  +  Seperator  +  SectionName  + Index
        >   ini   +      _      +      Tip      +   1
        > ---------------------------------------------
        > ini_Tip1 := "20090716194758"
        
        The index "0" contains number of all elements.
    Examples:
        > ini_exportToGlobals(ini, 0)
        > ListVars
        > Msgbox % ini_RecentFileList_File2
        *Output:*
        > Z:\tempfile.tmp
        
        The example would create all these variables with following 
        values:
        > ini_RecentFileList_File1 := "F:\testfile.ahk"
        > ini_RecentFileList_File2 := "Z:\tempfile.tmp"
        > ini_Tip_TimeStamp := "20090716194758"
        
        These variables would be created in addition to the above ones, if 
        CreateIndexVars option was set to true:
        > ini_0 := "2"
        > ini_1 := "Tip"
        > ini_2 := "RecentFileList"
        > ini_RecentFileList0 := "2"
        > ini_RecentFileList1 := "File1"
        > ini_RecentFileList2 := "File2"
        > ini_Tip0 := "1"
        > ini_Tip1 := "TimeStamp"
    */
    ini_exportToGlobals(ByRef _Content, _CreateIndexVars = false, _Prefix = "ini", _Seperator = "_", _SectionSpaces = "", _PreserveSpace = False)
    {
        Global
        Local secCount := 0, keyCount := 0, i := 0, Section, Section1, currSection, Pair, Pair1, Pair2, FirstChar
        If (_Prefix != "")
        {
            _Prefix .= _Seperator
        }
        Loop, Parse, _Content, `n, `r
        {
            If (Not RegExMatch(A_LoopField, "`aiSm)\[\s*(.+?)\s*]", Section))
            {
                If (RegExMatch(A_LoopField, "`aiSm)\s*(\b(?:.+?|\s?)\b)\s*=(.*)", Pair))
                {
                    If (!_PreserveSpace)
                    {
                        StringReplace, Pair1, Pair1, %A_Space%, , All
                        Pair2 = %Pair2% ; Trim spaces.
                        FirstChar := SubStr(Pair2, 1, 1)
                        If (FirstChar = """" AND SubStr(Pair2, 0, 1)= """"
                            OR FirstChar = "'" AND SubStr(Pair2, 0, 1)= "'")
                        {
                            StringTrimLeft, Pair2, Pair2, 1
                            StringTrimRight, Pair2, Pair2, 1
                        }
                    }
                    StringReplace, currSection, currSection, %A_Space%, %_SectionSpaces%, All
                    %_Prefix%%currSection%%_Seperator%%Pair1% := Pair2 ; ini_section_key := value
                    keyCount++
                    If (_CreateIndexVars)
                    {
                        %_Prefix%%currSection%0++
                        i := %_Prefix%%currSection%0
                        %_Prefix%%currSection%%i% := Pair1
                    }
                }
            }
            Else
            {
                currSection := Section1
                If (_CreateIndexVars)
                {
                    StringReplace, currSection, currSection, %A_Space%, %_SectionSpaces%, All
                    secCount++
                    %_Prefix%%secCount% := currSection
                }
            }
        }
        If (_CreateIndexVars)
        {
            %_Prefix%0 := secCount
        }
        If (secCount = 0 AND keyCount = 0)
        {
            ErrorLevel = 1
        }
        Else
        {
            ErrorLevel = 0
        }
        Return keyCount
    }
    
    
    /*
    _______________________________________________________________________________
    _______________________________________________________________________________
    Section: Aliases
    About: About
    Brief:
        Function wrappers to work with existing commands or functions via "Basic 
        ini string functions". They try to mimic the interface for look and feel of
        original. This can help to migrate others to this library with lesser
        possible work.
    _______________________________________________________________________________
    _______________________________________________________________________________
    */
    
    ; .............................................................................
    ; Group: AutoHotkey
    ;   Built-in Commands of AutoHotkey.
    ; .............................................................................
    
    /*
    Func: Ini_Read
        Reads a value. Alias of IniRead.
    Parameters:
        OutputVar       - *Variable* The name of the variable in which to store the retrieved 
                            value. If the value cannot be retrieved, the variable 
                            is set to the value indicated by the Default parameter 
                            (described below). 
        Content         - *Variable* Content of an ini file (also this can be one 
                            section only).
        Section         - Unique name of the section.
        Key             - Name of the variable under the section.
        Default         - *Optional* The value to store in OutputVar if the 
                            requested key is not found. If omitted, it defaults to 
                            the word ERROR.
    Returns:
        Does not return anything.
        
    Remarks:
        ErrorLevel is not set by this function (backed up and restored).
        In Ahk you had to specify the filename of the ini file. Here you need to 
        give the content, instead of.
        Compared to "Basic ini string functions" the parameter section is not 
        allowed to be set to an empty string anymore.
    Related:
        * IniRead: [https://www.autohotkey.com/docs/commands/IniRead.htm]
        
    Examples:
        > FileRead, ini, C:\Temp\myfile.ini
        > Ini_Read(OutputVar, ini, "section2", "key")
        > MsgBox %OutputVar%
    */
    Ini_Read(ByRef _OutputVar, ByRef _Content, _Section, _Key, _Default = "ERROR")
    {
        If (_Section != "")
        {
            BackupErrorLevel := ErrorLevel
            _OutputVar := ini_getValue(_Content, _Section, _Key)
            If ErrorLevel
            {
                _OutputVar := _Default
            }
            ErrorLevel := BackupErrorLevel
        }
        Else
        {
            _OutputVar := _Default
        }
        Return 
    }
    
    
    /*
    Func: Ini_Write
        Writes a value. Alias of IniWrite.
    Parameters:
        Value           - The string or number that will be written to the right 
                            of Key's equal sign (=).
        Content         - *Variable* Content of an ini file .
        Section         - Unique name of the section.
        Key             - Name of the variable under the section.
    Returns:
        Does not return anything.
        
    Remarks:
        ErrorLevel is set to 1 if there was a problem or 0 otherwise.
        In Ahk you had to specify the filename of the ini file. Here you need to 
        give the content, instead of.
        Compared to "Basic ini string functions" the parameter section is not 
        allowed to be set to an empty string anymore.
    Related:
        * IniWrite: [https://www.autohotkey.com/docs/commands/IniWrite.htm]
        
    Examples:
        > FileRead, ini, C:\Temp\myfile.ini
        > Ini_Write("this is a new value", ini, "section2", "key")
        > FileDelete, C:\Temp\myfile.ini
        > FileAppend, %ini%, C:\Temp\myfile.ini
    */
    Ini_Write(_Value, ByRef _Content, _Section, _Key)
    {
        If (_Section = "")
        {
            ErrorLevel = 1
        }
        Else
        {
            ini_replaceValue(_Content, _Section, _Key, _Value)
        }
        Return 
    }
    
    
    /*
    Func: Ini_Delete
        Deletes a value or section. Alias of IniDelete.
    Parameters:
        Content         - *Variable* Content of an ini file.
        Section         - Unique name of the section.
        Key             - *Optional* Name of the variable under the section.
    Returns:
        Does not return anything.
        
    Remarks:
        ErrorLevel is set to 1 if there was a problem or 0 otherwise.
        In Ahk you had to specify the filename of the ini file. Here you need to 
        give the content, instead of.
        Compared to "Basic ini string functions" the parameter section is not 
        allowed to be set to an empty string anymore.
    Related:
        * IniDelete: [https://www.autohotkey.com/docs/commands/IniDelete.htm]
        
    Examples:
        > FileRead, ini, C:\Temp\myfile.ini
        > Ini_Delete(ini, "section2", "key")
        > FileDelete, C:\Temp\myfile.ini
        > FileAppend, %ini%, C:\Temp\myfile.ini
    */
    Ini_Delete(ByRef _Content, _Section, _Key = "")
    {
        If (_Section = "")
        {
            ErrorLevel = 1
        }
        Else
        {
            If (_Key != "")
            {
                ini_replaceKey(_Content, _Section, _Key, "")
            }
            Else
            {
                ini_replaceSection(_Content, _Section, "")
            }
        }
        Return 
    }

    If there are ANY AHK users who know how to increase the Mouseclicks without BF4 skipping them, please enlighten me !
    Last edited by wyvern1990; 03-17-2015 at 12:29 PM. Reason: UPDATED!

  2. The Following 2 Users Say Thank You to wyvern1990 For This Useful Post:

    klausBrause (09-26-2020),lumpi999 (02-17-2016)

  3. #2
    Yellow 13's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    1,430
    Reputation
    96
    Thanks
    4,968
    You can't increase mouseclick without oversampling/jamming the weapon.

    Also, how did you manage to use AHK without being kicked?
    Rig | 5820K - GTX1080 AMP
    P870KM1 | 7700K - GTX1080N SLi

  4. #3
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    Quote Originally Posted by Yellow 13 View Post
    You can't increase mouseclick without oversampling/jamming the weapon.

    Also, how did you manage to use AHK without being kicked?
    That is what i was already afraid of.

    I use AHK for a long time and have had no problems what so ever.
    Never been kicked.
    AHK does not write to memory, it just simulates mouse and key events.

    You could also convert it to an .EXE

  5. #4
    haekaru's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    Are you gonna make any macros for BFH anytime soon? I can't pm you. :c

  6. #5
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    this is UNIVERSAL, so should work with BFH, just fiddle around with it.

  7. #6
    Yellow 13's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    1,430
    Reputation
    96
    Thanks
    4,968
    Quote Originally Posted by wyvern1990 View Post
    this is UNIVERSAL, so should work with BFH, just fiddle around with it.
    You gotta remember that most people here are lazy and always demand the creator to do work for them lol.
    Rig | 5820K - GTX1080 AMP
    P870KM1 | 7700K - GTX1080N SLi

  8. #7
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    I Know ,
    But as this script is not deliverd with Ready To Use setting, se they have to experiment with it themselves anyway

  9. #8
    x7gamingm's Avatar
    Join Date
    Nov 2014
    Gender
    male
    Location
    Georgia,USA
    Posts
    192
    Reputation
    10
    Thanks
    16
    My Mood
    Hot
    How could I convert it into an exe file ?

  10. #9
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    Quote Originally Posted by x7gamingm View Post
    How could I convert it into an exe file ?
    On my pc it works as folows:
    RightClick on "scriptname".ahk and then a have an option to compile it.
    it will compile it to an .EXE format.
    i use SciTE4autohotkey, Maybe the option came with that program.
    Google should sort it out

    Cheers.

  11. The Following User Says Thank You to wyvern1990 For This Useful Post:

    x7gamingm (03-17-2015)

  12. #10
    x7gamingm's Avatar
    Join Date
    Nov 2014
    Gender
    male
    Location
    Georgia,USA
    Posts
    192
    Reputation
    10
    Thanks
    16
    My Mood
    Hot
    kk thx bud

  13. #11
    autoauto's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    error in line 9 when i want to compile or try to start with doubleclick. IniLib1.0.ahk cannot be opened. Btw how can you use ahk with bf4? Anyway thx for sharing gj.

  14. #12
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    Quote Originally Posted by autoauto View Post
    error in line 9 when i want to compile or try to start with doubleclick. IniLib1.0.ahk cannot be opened. Btw how can you use ahk with bf4? Anyway thx for sharing gj.
    Sorry, the script indeed has an dependancy to that file, Ill upload it to OP ASAP.
    I Dont know what the problem is with ahk, i use it and it always all works fine.

    Never got banned.

  15. #13
    autoauto's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by wyvern1990 View Post
    Sorry, the script indeed has an dependancy to that file, Ill upload it to OP ASAP.
    I Dont know what the problem is with ahk, i use it and it always all works fine.

    Never got banned.

    thank you very mucho muchacho :-)


    Edit: hm it runs but does nothing
    Last edited by autoauto; 03-17-2015 at 03:46 PM.

  16. #14
    wyvern1990's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Posts
    137
    Reputation
    10
    Thanks
    2,817
    Quote Originally Posted by autoauto View Post
    thank you very mucho muchacho :-)


    Edit: hm it runs but does nothing
    Do you run BF4 in "Windowed Mode"?
    the script also has an overlay wich tells you what the sittings are when u push a button.

    And could you specify what does not work?

  17. #15
    autoauto's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by wyvern1990 View Post
    Do you run BF4 in "Windowed Mode"?
    the script also has an overlay wich tells you what the sittings are when u push a button.

    And could you specify what does not work?
    I tested your previous version too the same way and it works. Dunno why

Page 1 of 2 12 LastLast

Similar Threads

  1. [Release] UPDATE Universal Anti-Recoil / Spread Reducer V1.6
    By wyvern1990 in forum Battlefield 4 Hacks & Cheats
    Replies: 18
    Last Post: 05-21-2015, 06:29 AM
  2. [Release] Battlefield3 +4 Trainer (No Spread,Reduce Recoil,Hold Breath,Tags) Updated!
    By apocalypticx in forum Battlefield 3 (BF3) Hacks & Cheats
    Replies: 102
    Last Post: 12-24-2011, 10:03 AM
  3. [Release] Battlefield +4 Trainer (No Spread,Reduce Recoil,Hold Breath,Tags).
    By apocalypticx in forum Battlefield 3 (BF3) Hacks & Cheats
    Replies: 83
    Last Post: 12-06-2011, 01:20 PM
  4. [Request] Sudden attack anti spread,anti recoil and aimbot for SASEA.
    By 0125972799 in forum Sudden Attack General
    Replies: 1
    Last Post: 05-05-2011, 11:38 AM
  5. [USF] Anti-recoil and anti-spread
    By Xeg in forum Soldier Front Hacks
    Replies: 16
    Last Post: 08-23-2009, 09:18 AM