Jump to content

Recommended Posts

  • Moderators
Posted

Jaenchen,

It is really easy: :(

You take this script:

#region ; ----- Directives ---

#AutoIt3Wrapper_Res_File_Add=fxddb_Splash_1.jpg, RT_RCDATA, SPLASH_1
#AutoIt3Wrapper_Res_File_Add=fxddb_Splash_2.jpg, RT_RCDATA, SPLASH_2
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0

#endregion
#region ; ----- Includes -----

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include "resources.au3"

#endregion ; ----- Includes -----
; ############# fxddb #############
;
; Reading from the FX daily deal blotter
;
; Initial release
;
; Script Version: 1.0.0.0
;   As at 23 Mar 10
;
#region ; ----- Get App handle -----

; Get handle of app window
Global $iOldMode = Opt("WinTitleMatchMode", 2)
Global $hGUI = WinGetHandle("FX daily deal blotter")
If @error Then
    MsgBox(16, "fxddb Disaster!", "Cannot find the window!")
    Exit
EndIf
Opt("WinTitleMatchMode", $iOldMode)

#endregion ; ----- Get App handle -----
#region ; ----- Declarations -----

; Array of digit and sign codes
Global $aChecks[12] = [ _
        "011110100001100001100001100001100001100001100001100001011110", _
        "000100001100010100000100000100000100000100000100000100000100", _
        "011110100001000001000001000001000010000100001000010000111111", _
        "011110100001000001000001001110000001000001000001100001011110", _
        "000010000110000110001010001010010010010010111111000010000010", _
        "011111010000010000100000111110100001000001000001100001011110", _
        "011110100001100000100000101110110001100001100001100001011110", _
        "111111000010000010000100000100001000001000010000010000010000", _
        "011110100001100001100001011110100001100001100001100001011110", _
        "011110100001100001100001100011011101000001000001100010011100", _
        "000000000000000100000100000100111111000100000100000100000000", _
        "000000000000000000000000000000000000000111000000000000000000"]

; Array of Curr.1 letter edges (D, G, T, U)
Global $aCurr[4] = [ _
        "1111111111", _
        "0011111100", _
        "1000000000", _
        "1111111100"]

; Array to hold numbers read from app
Global $aCurrArray[15][3], $aOldArray[15][3]

; Find position of the app window
Global $aAppPos = WinGetPos($hGUI)

; Coords of the 2 points user will mark
Global $iX_Cross_1, $iY_Cross_1, $iX_Cross_2, $iY_Cross_2, $iX_Colon = -1, $iX_3Letter

; Checksum of top line
Global $iChecksum

; Struct for window visible check
Global $tPOINT = DllStructCreate("int X;int Y")

; Conversion from kilos to ounces
Global $nConvFactor = 32.1507425

#endregion ; ----- Declarations -----
#region ; ----- Determine ini path

Global $sIniFile

; Determine location for ini file
If @ScriptDir = @ProgramFilesDir Then
    ; If app in C:\Program Files need to save elsewhere
    If Not FileExists(@AppDataDir & "\fxddb") Then DirCreate(@AppDataDir & "\fxddb")
    $sIniFile = @AppDataDir & "\fxddb\fxddb.ini"
Else
    ; Can use app folder
    $sIniFile = @ScriptDir & "\fxddb.ini"
EndIf

IniReadSection($sIniFile, "Limits")
If @error Then
    MsgBox(48, "fxddb Alert", "No transaction limits have been set" & @CRLF & "Please set them now")
    On_Limits()
EndIf

#endregion ; ----- Determine ini path
#region ; ----- Tray menu -----

Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown.

; Create tray menu
TrayCreateItem("Set Limits")
TrayItemSetOnEvent(-1, "On_Limits")
TrayCreateItem("")
TrayCreateItem("About")
TrayItemSetOnEvent(-1, "On_About")
TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "On_Exit")

#endregion ; ----- Tray menu -----
#region ; ----- Initialisation -----

; Get user to mark the points
Mark_Cross()

; Get base window handle
DllStructSetData($tPOINT, "X", $aAppPos[0] + $iX_Cross_1)
DllStructSetData($tPOINT, "Y", $aAppPos[1] + $iY_Cross_1)
$hHandle = _WinAPI_WindowFromPoint($tPOINT)

; Read the numbers in GMT, Curr.1 and Amount1 columns to set the base array
Read_Values()
$aOldArray = $aCurrArray

; Set the original checksum for the top line
Global $iCurrChecksum = PixelChecksum($aAppPos[0], $iY_Cross_1 + 3, $aAppPos[0] + $aAppPos[2], $iY_Cross_1 + 13)

#endregion ; ----- Initialisation -----
#region ; ----- Main loop -----

; Now start infinite loop
While 1

    ; Check position of the app
    $aAppPos = WinGetPos($hGUI)

    ; Check if app is visible
    DllStructSetData($tPOINT, "X", $aAppPos[0] + $iX_Cross_1)
    DllStructSetData($tPOINT, "Y", $aAppPos[1] + $iY_Cross_1)
    If _WinAPI_WindowFromPoint($tPOINT) = $hHandle Then

        ; Check if the top line has changed
        $iChecksum = PixelChecksum($aAppPos[0], $aAppPos[1] + $iY_Cross_1 + 3, $aAppPos[0] + $aAppPos[2], $aAppPos[1] + $iY_Cross_1 + 13)
        If $iChecksum <> $iCurrChecksum Then

            ; Retain new checksum for future checks
            $iCurrChecksum = $iChecksum

            ; Read the values in GMT, Curr.1 and Amount1 columns
            Read_Values()

            ; Check the new values and send any necessary alerts
            Check_Values()

            ; All warnings sent so replace $aOldArray
            $aOldArray = $aCurrArray

        EndIf
    EndIf

    ; Idle 10 Secs before relooping
    Sleep(10000)

WEnd

; ~~~~~ Functions ~~~~~

#endregion ; ----- Main loop -----
#region ; ----- Read_Values -----

Func Read_Values()

    ; Coords of zones to check for digit/sign
    Local $aX_Coords_1[4] = [-15, -8, 3, 10]
    Local $aX_Coords_2[9] = [65, 58, 51, 47, 40, 33, 26, 15, 8]
    Local $iY_Coord = $aAppPos[1] + $iY_Cross_1 + 3

    ; Reset array
    Global $aCurrArray[15][3]

    ; Find colon if not yet set
    If $iX_Colon = -1 Then Find_Colon($iY_Coord)

    ; Move down line by line
    For $iY_Index = 0 To 14

        Local $iBackgroundColour = Hex(PixelGetColor($aAppPos[0] + $iX_Cross_1 - 1, $iY_Coord + ($iY_Index * 16) + 1), 6)

        ; Start in the GMT column

        ; Zero the code
        Local $sCode = ""

        ; Set the x-coord for this column
        Local $iX_Coord = $aAppPos[0] + $iX_Colon

        ; Move through the digit/sign spaces from left
        For $iX_Index = 0 To 3

            ; Move through the space to build the code
            Local $sString = ""
            For $y = 0 To 9
                For $x = 0 To 5
                    $sString &= Read_Pixel($iX_Coord + $aX_Coords_1[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
                Next
            Next

            ; Check in the index for a match
            Local $iIndex = _ArraySearch($aChecks, $sString)

            ; Add the correct digit/sign to the list
            Switch $iIndex
                Case 0 To 9
                    $sCode &= $iIndex
            EndSwitch

            ; Add colon in correct place
            If $iX_Index = 1 Then $sCode &= ":"

        Next

        ; Check if we have reached the end of entries
        If $sCode = ":" Then ExitLoop

        ; Store the GMT
        $aCurrArray[$iY_Index][0] = $sCode

        ; Now move on to Curr.1 column

        ; Determine the first letter and the X-Coord for the third letter
        Local $aLetters = Find_Letters($iY_Coord, $iY_Index, $iBackgroundColour)
        $iX_3Letter = $aLetters[1]

        ; To distinguish between the possible values, we need only look at the left edge of the 3rd letter
        Local $iX_Curr = $aAppPos[0] + $iX_Cross_1 + $iX_3Letter

        ; Read the edge line
        $sString = ""
        For $y = 0 To 9
            $sString &= Read_Pixel($iX_Curr, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
        Next

        ; Check in the index for a match and write to the array
        $iIndex = _ArraySearch($aCurr, $sString)
        Switch $iIndex
            Case 0
                $aCurrArray[$iY_Index][1] = $aLetters[0] & "PD"
            Case 1
                $aCurrArray[$iY_Index][1] = $aLetters[0] & "AG"
            Case 2
                $aCurrArray[$iY_Index][1] = $aLetters[0] & "PT"
            Case 3
                $aCurrArray[$iY_Index][1] = $aLetters[0] & "AU"
        EndSwitch

        ; Now move on to the Amount1 column

        ; Set base x-coord
        $iX_Coord = $aAppPos[0] + $iX_Cross_2

        ; Zero the code
        $sCode = ""

        ; Move through the digit/sign spaces from left
        For $iX_Index = 0 To 8

            ; Move through the space
            $sString = ""
            For $y = 0 To 9
                For $x = 0 To 5
                    $sString &= Read_Pixel($iX_Coord - $aX_Coords_2[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
                Next
            Next

            ; Check in the index for a match
            $iIndex = _ArraySearch($aChecks, $sString)

            ; Add the correct digit/sign to the list
            Switch $iIndex
                Case 0 To 9
                    $sCode &= $iIndex
                Case 10
                    $sCode &= "+"
                Case 11
                    $sCode &= "-"
            EndSwitch

            If $iX_Index = 2 Then
                ; If we did not find a digit at the thousands point, check for a sign
                ; If we did, add a comma
                If $iIndex > 0 Then
                    $iX_Index = 3
                    $sCode &= ","
                EndIf
            EndIf

            ; Add the decimal at the correct point
            If $iX_Index = 6 Then $sCode &= "."

        Next

        ; Store the Amount 1
        $aCurrArray[$iY_Index][2] = $sCode

    Next

EndFunc   ;==>Read_Values

#endregion ; ----- Read_Values -----
#region ; ----- Find_Colon -----

Func Find_Colon($iY_Coord)

    ; Check colour of background
    Local $iBackgroundColour = Hex(PixelGetColor($aAppPos[0] + $iX_Cross_1 - 1, $iY_Coord), 6)

    ; Move across app window to find colon
    For $x = $aAppPos[0] + $iX_Cross_1 To $aAppPos[0] Step -1
        Local $sString = ""
        For $y = 0 To 9
            $sString &= Read_Pixel($x, $iY_Coord + $y, $iBackgroundColour)
        Next
        ; Found it
        If $sString = "0001000001" Then ExitLoop
    Next

    ; Set the coordinate to the colon
    $iX_Colon = $x - $aAppPos[0]

EndFunc   ;==>Find_Colon

#endregion ; ----- Find_Colon -----
#region ; ----- Find Letter -----

Func Find_Letters($iY_Coord, $iY_Index, $iBackgroundColour)

    ; Move across app to ID first letter
    Local $aRet[2]
    For $x = 2 To 10
        Local $sString = ""
        For $y = 0 To 9
            $sString &= Read_Pixel($aAppPos[0] + $iX_Cross_1 + $x, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
        Next
        Switch $sString
            ; If blank keep going to find start of letter
            Case "0000000000"
                ContinueLoop
                ; If X Then ExitLoop to find 3rd letter
            Case "1000000001"
                $aRet[0] = "X"
                ExitLoop
            Case Else
                $aRet[0] = "K"
                ExitLoop
        EndSwitch
    Next

    Local $fBlank = False
    ; Move across app window to find third letter
    For $x = 15 To 30
        $sString = ""
        For $y = 0 To 9
            $sString &= Read_Pixel($aAppPos[0] + $iX_Cross_1 + $x, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
        Next
        Switch $fBlank
            Case False
                ; Check for blank line
                If $sString = "0000000000" Then $fBlank = True
            Case True
                ; Check for beginning of letter
                If $sString <> "0000000000" Then ExitLoop
        EndSwitch
    Next

    ; We now have the cordinate to the left edge of the third letter
    $aRet[1] = $x
    Return $aRet

EndFunc   ;==>Find_Letters

#endregion ; ----- Find Letter -----
#region ; ----- Read_ Pixel -----

Func Read_Pixel($iX_Pixel, $iY_Pixel, $iBackgroundColour)

    Local $sColour = Hex(PixelGetColor($iX_Pixel, $iY_Pixel), 6)
    ; If pixel colour is not the background colour - set the code
    If $sColour <> $iBackgroundColour Then
        Return "1"
    Else
        Return "0"
    EndIf

EndFunc   ;==>Read_Pixel

#endregion ; ----- Read_ Pixel -----
#region ; ----- Mark_Cross -----

Func Mark_Cross()

    ; Open dll for _IsPressed
    Local $UserDLL = DllOpen("user32.dll")

    For $i = 1 To 3

        ; Read ini values for GMT cross intial position
        Local $iX_Start = IniRead($sIniFile, "GMT Cross", "X-Coord", 45) + $aAppPos[0]
        Local $iY_Start = IniRead($sIniFile, "GMT Cross", "Y-Coord", 100) + $aAppPos[1]

        ; Set GMT cross
        Local $aRet = Move_Cross($iX_Start, $iY_Start, "SPLASH_1", $UserDLL)
        $iX_Cross_1 = $aRet[0]
        $iY_Cross_1 = $aRet[1]

        Local $iCheckSum_1 = PixelChecksum($iX_Cross_1 - 1, $iY_Cross_1 - 1, $iX_Cross_1 + 1, $iY_Cross_1)

        ; Read ini values for Amount1 cross intial position
        $iX_Start = IniRead($sIniFile, "Amount1 Cross", "X-Coord", 200) + $aAppPos[0]
        $iY_Start = IniRead($sIniFile, "Amount1 Cross", "Y-Coord", 100) + $aAppPos[1]

        ; Set Amount1 cross
        $aRet = Move_Cross($iX_Start, $iY_Start, "SPLASH_2", $UserDLL)
        $iX_Cross_2 = $aRet[0]
        $iY_Cross_2 = $aRet[1]

        Local $iCheckSum_2 = PixelChecksum($iX_Cross_2 - 1, $iY_Cross_2 - 1, $iX_Cross_2 + 1, $iY_Cross_2)

        ; Check for confirmation of correct positioning
        If $iY_Cross_1 <> $iY_Start And $iY_Cross_1 = $iY_Cross_2 Then

            ; Set coords relative to the app window
            $iX_Cross_1 -= $aAppPos[0]
            $iY_Cross_1 -= $aAppPos[1]
            $iX_Cross_2 -= $aAppPos[0]
            $iY_Cross_2 -= $aAppPos[1]

            ; Save values 1 pixel off
            IniWrite($sIniFile, "GMT Cross", "X-Coord", $iX_Cross_1 - 1)
            IniWrite($sIniFile, "GMT Cross", "Y-Coord", $iY_Cross_1 - 1)
            IniWrite($sIniFile, "Amount1 Cross", "X-Coord", $iX_Cross_2 - 1)
            IniWrite($sIniFile, "Amount1 Cross", "Y-Coord", $iY_Cross_2 - 1)
            ; Close dll
            DllClose($UserDLL)
            Return
        Else
            If $i = 3 Then
                MsgBox(16, "fxddb Error", "If you do not want to set me up properly then I am not going to play!")
                Exit
            Else
                MsgBox(48, "fxddb Error", "The crosses were not properly positioned" & @CRLF & "Please try again")
            EndIf
        EndIf

        While _IsPressed("0D", $UserDLL)
            Sleep(10)
        WEnd

    Next

EndFunc   ;==>Mark_Cross

#endregion ; ----- Mark_Cross -----
#region ; ----- Move_Cross -----

Func Move_Cross($iX_Mark, $iY_Mark, $sImage, $UserDLL)

    Local $aRet[2]

    ; Determine location of example GUI
    Local $iX_Loc = $aAppPos[0] - 250
    If $aAppPos[0] < 300 Then $iX_Loc = $aAppPos[0] + $aAppPos[2]
    Local $iY_Loc = $aAppPos[1] + 100

    ; Create example GUI
    Local $hExampleGUI = GUICreate("Place the cross here", 250, 96, $iX_Loc, $iY_Loc, $WS_POPUPWINDOW, -1, WinGetHandle(AutoItWinGetTitle()))
    GUICtrlCreateLabel("Place cross on intersection in centre of circle", 0, 0, 250, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, 0xFFFF00)
    Local $hPic = GUICtrlCreatePic("", 0, 20, 250, 76)
    _ResourceSetImageToCtrl($hPic, $sImage)
    GUISetState()

    ; Create transparent GUI over the app with Cross cursor
    Local $hCross_GUI = GUICreate("Test", $aAppPos[2], $aAppPos[3], $aAppPos[0], $aAppPos[1], $WS_POPUP, $WS_EX_TOPMOST)
    WinSetTrans($hCross_GUI, "", 8)
    GUISetState(@SW_SHOW, $hCross_GUI)
    GUISetCursor(3, 1, $hCross_GUI)

    MouseMove($iX_Mark, $iY_Mark, 0)

    ; Wait for adjustments or confirmation
    While 1
        If _IsPressed("25", $UserDLL) Then
            $iX_Mark -= 1
            While _IsPressed("25", $UserDLL)
                Sleep(10)
            WEnd
        EndIf
        If _IsPressed("26", $UserDLL) Then
            $iY_Mark -= 1
            While _IsPressed("26", $UserDLL)
                Sleep(10)
            WEnd
        EndIf
        If _IsPressed("27", $UserDLL) Then
            While _IsPressed("27", $UserDLL)
                Sleep(10)
            WEnd
            $iX_Mark += 1
        EndIf
        If _IsPressed("28", $UserDLL) Then
            While _IsPressed("28", $UserDLL)
                Sleep(10)
            WEnd
            $iY_Mark += 1
        EndIf
        If _IsPressed("0D", $UserDLL) Then
            While _IsPressed("0D", $UserDLL)
                Sleep(10)
            WEnd
            $aRet[0] = $iX_Mark
            $aRet[1] = $iY_Mark
            GUIDelete($hCross_GUI)
            GUIDelete($hExampleGUI)
            Return $aRet
        EndIf

        MouseMove($iX_Mark, $iY_Mark)

    WEnd

EndFunc   ;==>Move_Cross

#endregion ; ----- Move_Cross -----
#region ; ----- Check values -----

Func Check_Values()

    Local $iThreshold

    For $i = 0 To 14

        Local $sNewLine = $aCurrArray[$i][0] & $aCurrArray[$i][1] & $aCurrArray[$i][2]
        Local $sOldTopLine = $aOldArray[0][0] & $aOldArray[0][1] & $aOldArray[0][2]

        If $sNewLine <> $sOldTopLine Then
            ; New line so get code
            If $aCurrArray[$i][1] = "Other" Then
                Show_Alert("ALERT", $i, 0x80FF80)
            Else
                Local $nNumber = Number(StringReplace($aCurrArray[$i][2], ",", ""))
                ; Convert to ounces if necessary
                If StringLeft($aCurrArray[$i][1], 1) = "K" Then $nNumber *= $nConvFactor
                ; Set Threshold value
                Switch StringRight($aCurrArray[$i][1], 2)
                    Case "AG"
                        $iThreshold = IniRead($sIniFile, "Limits", "AG", "Error")
                    Case "AU"
                        $iThreshold = IniRead($sIniFile, "Limits", "AU", "Error")
                    Case "PD"
                        $iThreshold = IniRead($sIniFile, "Limits", "PD", "Error")
                    Case "PT"
                        $iThreshold = IniRead($sIniFile, "Limits", "PT", "Error")
                EndSwitch
                ; Check we have valid limits
                If $iThreshold = "Error" Then
                    MsgBox(16, "fxddb Error", "Limits are invalid" & @CRLF & "Please reset the limit values and restart!")
                    On_Limits()
                    Exit
                EndIf
                ; Check if limit exceeded
                If Abs($nNumber) >= $iThreshold Then
                    Local $sAction = "BUY"
                    Local $iColour = 0xFF8000
                    If StringLeft($aCurrArray[$i][2], 1) = "-" Then
                        $sAction = "SELL"
                        $iColour = 0xFFFF00
                    EndIf
                    Show_Alert($sAction, $i, $iColour)
                EndIf
            EndIf
        Else
            ; We have reached the top line of the last array so stop checking
            ExitLoop
        EndIf

    Next

EndFunc   ;==>Check_Values

#endregion ; ----- Check values -----
#region ; ----- Show_Alert -----

Func Show_Alert($sAction, $iIndex, $iColour)

    ; Create Alert GUI
    Local $hAlert = GUICreate("New Trade at " & $aCurrArray[$iIndex][0], 500, 160, Default, Default, BitOR($WS_POPUPWINDOW, $WS_CAPTION), $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()))
    GUISetBkColor($iColour, $hAlert)
    GUICtrlCreateLabel("", 10, 10, 480, 100, $SS_CENTER)
    GUICtrlSetBkColor(-1, $iColour)
    GUICtrlSetFont(-1, 24)
    GUICtrlSetData(-1, "NEW TRADE" & @CRLF & "YOU " & $sAction & " " & $aCurrArray[$iIndex][1] & " : " & $aCurrArray[$iIndex][2])
    Local $hButton = GUICtrlCreateButton("OK", 210, 120, 80, 30, $BS_DEFPUSHBUTTON)
    GUISetState()

    Beep(500, 500)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $hButton
                GUIDelete($hAlert)
                Return
        EndSwitch
    WEnd

EndFunc   ;==>Show_Alert

#endregion ; ----- Show_Alert -----
#region ; ----- On Limits -----

Func On_Limits()

    Local $aLimits[4][3]

    ; Read current limits
    $aLimits[0][1] = IniRead($sIniFile, "Limits", "AG", "Not Set")
    $aLimits[1][1] = IniRead($sIniFile, "Limits", "AU", "Not Set")
    $aLimits[2][1] = IniRead($sIniFile, "Limits", "PD", "Not Set")
    $aLimits[3][1] = IniRead($sIniFile, "Limits", "PT", "Not Set")

    ; Create GUI
    Local $hLimits = GUICreate("Set Limits", 220, 190)
    GUICtrlCreateLabel("Metal" & @TAB & "Ounces" & @TAB & @TAB & "Kilos", 10, 10, 280, 20)
    GUICtrlCreateLabel("AG", 10, 30, 30, 20)
    GUICtrlCreateLabel("AU", 10, 60, 30, 20)
    GUICtrlCreateLabel("PD", 10, 90, 30, 20)
    GUICtrlCreateLabel("PT", 10, 120, 30, 20)
    ; Create inputs
    $aLimits[0][0] = GUICtrlCreateInput($aLimits[0][1], 50, 30, 70, 20)
    $aLimits[1][0] = GUICtrlCreateInput($aLimits[1][1], 50, 60, 70, 20)
    $aLimits[2][0] = GUICtrlCreateInput($aLimits[2][1], 50, 90, 70, 20)
    $aLimits[3][0] = GUICtrlCreateInput($aLimits[3][1], 50, 120, 70, 20)
    ; Show kilo equivalents
    For $i = 0 To 3
        If $aLimits[$i][1] = "Not Set" Then
            $aLimits[$i][2] = GUICtrlCreateLabel("Not Set", 130, 30 * ($i + 1), 70, 20)
        Else
            $aLimits[$i][2] = GUICtrlCreateLabel(Round($aLimits[$i][0] / $nConvFactor, 7), 130, 30 * ($i + 1), 70, 20)
        EndIf
    Next
    Local $hAccept_Button = GUICtrlCreateButton("Accept", 130, 150, 80, 30)
    Local $hCancel_Button = GUICtrlCreateButton("Cancel", 10, 150, 80, 30)

    GUISetState(@SW_SHOW, $hLimits)

    While 1

        Switch GUIGetMsg()
            Case $hAccept_Button
                ; Read required limits
                For $i = 0 To 3
                    $aLimits[$i][1] = GUICtrlRead($aLimits[$i][0])
                Next
                ; Write limits to ini file
                IniWrite($sIniFile, "Limits", "AG", $aLimits[0][1])
                IniWrite($sIniFile, "Limits", "AU", $aLimits[1][1])
                IniWrite($sIniFile, "Limits", "PD", $aLimits[2][1])
                IniWrite($sIniFile, "Limits", "PT", $aLimits[3][1])
                ContinueCase
            Case $GUI_EVENT_CLOSE, $hCancel_Button
                GUIDelete($hLimits)
                Return
        EndSwitch

        ; Keep kilo values synchronised with ounce inputs
        For $i = 0 To 3
            Local $nKVal = Round(GUICtrlRead($aLimits[$i][0]) / $nConvFactor, 7)
            If GUICtrlRead($aLimits[$i][2]) <> $nKVal Then GUICtrlSetData($aLimits[$i][2], $nKVal)
        Next

    WEnd

EndFunc   ;==>On_Limits

#endregion ; ----- On Limits -----
#region ; ----- On_About -----

Func On_About()

    Local $sMsg = "fxddb v1.0" & @CRLF & "(c) Melba23 UK 2010" & @CRLF & @CRLF & _
            "This software is released as Freeware.  It is provided 'as-is', without any express or implied warranty.  " & _
            "In no event shall the author be held liable for any damages arising from the use of this software." & @CRLF & @CRLF & _
            "fxddb built using AutoIt v" & @AutoItVersion & @CRLF & "(www.autoitscript.com/autoit3)"
    MsgBox(64, "About fxddb", $sMsg)

EndFunc   ;==>On_About

#endregion ; ----- On_About -----
#region ; ----- On_Exit -----

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

#endregion ; ----- On_Exit -----

and make sure that Zedna's resources.au3 UDF is in the same folder - you can download it from here.

Then you compile the script using the full version of SciTE4AutoIt3 which you can download from here.

And you will have a nice little 320k exe with the images stored inside it. :) Everthing will still work as before, but you will not need any other files to run it - no images, no AutoIt, just the exe file.

Have fun - and come back if you run into any problems! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

Hi M23

Everything works absolutely as desired and the users are really happy with it. Compiling worked also without any kind of problem.

You are a truely great AutoIt Mentor and I've learnt a lot from you.

Of course I have to spend more time with the code to get everything in detail.

I'm allready thinking of how this app can be derived for something else. Will see. Hopefully other Boardmembers can do.

If I have a prob or maybe somehting else to do, I'll immediately will revert to you. :(

Many Thanks for all.

Take care!

Best Regards

Jan

M23: YES YOU! YES YOU! YES YOU! YES YOU! YES YOU! YES YOU! YES YOU! YES YOU! YES YOU!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...