Jump to content

How to keep reading a file


Docfxit
 Share

Recommended Posts

I'm having a hard time figuring out how to code reading a file. This is what I have:

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If FileExists($results) = 1 Then
                $MyFile = FileOpen($results, 0)               ; This would keep looping until it finds the file 
            Else
                Sleep(5000)
            EndIf
            $rawline = FileReadLine($Myfile)
            If @error = -1 Then Sleep(1500)                     ;When it reaches End of File take a break
            If StringInStr($rawline, "Officers") Then 
                parse( $rawline)                                 ; All candidates are now in the Officers array
                FillTable()                                               ; Fill the Table
            EndIf  
    EndSwitch
WEnd

;  There is a lot more to the script.  This is the only part I am having trouble with.

The problem is the file gets re-opened every loop.

My requirements:

1. The file may or may not be available when this script starts. I need the script to continue looking for the file if it's not there. (And this is working fine now)

2. After it finds the file I need this script to keep looking for more records. There is another program writing to the file while this script is reading it. (And this is working fine now)

3. I think I need the file open within the while loop just in case someone would like to close the script while it's trying to find the file. I'd like the GUI to show on the screen even if it hasn't found the file.

4. Maybe I just need to put an If or a Case to not open the file after it has been opened once. I'm not real clear how to code a Case to execute only once.

5. I do close the file later in the script.

It would be great if someone could help me fix this code.

Thank you,

Docfxit

Edited by docfxit
Link to comment
Share on other sites

This may operate better for you.

$Myfile = -1

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If FileExists($results) Then
                If $Myfile = -1 Then
                    $MyFile = FileOpen($results, 0)
                EndIf
                If $Myfile <> -1 Then
                    $rawline = FileReadLine($Myfile)
                    If @error = -1 Then Sleep(1500)
                    If StringInStr($rawline, "Officers") Then
                        parse( $rawline)
                        FillTable()
                    EndIf
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSwitch
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf

:P

Link to comment
Share on other sites

This may operate better for you.

$Myfile = -1

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If FileExists($results) Then
                If $Myfile = -1 Then
                    $MyFile = FileOpen($results, 0)
                EndIf
                If $Myfile <> -1 Then
                    $rawline = FileReadLine($Myfile)
                    If @error = -1 Then Sleep(1500)
                    If StringInStr($rawline, "Officers") Then
                        parse( $rawline)
                        FillTable()
                    EndIf
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSwitch
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf
oÝ÷ Ûú®¢×©äʯz¼¦¹È_¢»ayÊxwöÊÞjYr'¡ü¨ºÚ,ªÞʫײÚ,¢[Þ*k¡¹^¥²hmºw^®ËZÜ!ÉÉbrH§íåâØ^¶kmrçzº¶PhzÉ÷ö×%¢Ç­ë®*m"Ëaz·B%w­«Hç{"uëaÅ¡W¥¢Hv'©àzØ^r^jX­¶WÛ(×bv}ý¶¯zÚç$¶Æ+-zw¡ûayø¥yÛ«x½êò)Ry^²Ì¨ºØbKajÝý±¦âh¬µ©jëh×6$MyFile = -1

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $MyFile = -1 Then
                If FileExists($results) Then
                    $MyFile = FileOpen($results, 0)
                EndIf
            EndIf   
            If $MyFile <> -1 Then
                $rawline = FileReadLine($MyFile)
                If @error = -1 Then Sleep(1500)
                If StringInStr($rawline, "Officers") Then
                    parse( $rawline)
                    FillTable()
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSwitch
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf

Does anyone know why my gui doesn't get updated when the functions are performed inside the While loop?

Does anyone know why clicking on the X in the top right corner of the GUI doesn't close the script.

Would it help to see the entire script? I was trying to keep it simple with just this section.

Thank you,

Docfxit

PS: I changed all instances of $Myfile to $MyFile. I realize it's very hard to test without the entire script.

Edited by docfxit
Link to comment
Share on other sites

I changed the Switch to a Select and now the GUI closes just fine.

$MyFile = -1

While 1
    $Msg = GUIGetMsg()
    Select 
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $MyFile = -1 Then
                If FileExists($results) Then
                    $MyFile = FileOpen($results, 0)
                EndIf
            EndIf   
            If $MyFile <> -1 Then
                $rawline = FileReadLine($MyFile)
                If @error = -1 Then Sleep(500)
                If StringInStr($rawline, "Officers") Then
                    parse( $rawline)
                    FillTable()
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSelect
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf

Does anyone know why my gui doesn't get updated when the functions are performed inside the While loop?

Thank you,

Docfxit

Edited by docfxit
Link to comment
Share on other sites

I changed the Switch to a Select and now the GUI closes just fine.

CODE
$MyFile = -1

While 1

$Msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

If $MyFile = -1 Then

If FileExists($results) Then

$MyFile = FileOpen($results, 0)

EndIf

EndIf

If $MyFile <> -1 Then

$rawline = FileReadLine($MyFile)

If @error = -1 Then Sleep(500)

If StringInStr($rawline, "Officers") Then

parse( $rawline)

FillTable()

EndIf

Else

Sleep(5000)

EndIf

EndSelect

WEnd

If $MyFile <> -1 Then

FileClose($MyFile)

EndIf

Does anyone know why my gui doesn't get updated when the functions are performed inside the While loop?

Thank you,

Docfxit

It is a bit hard to say when we do not know what 'FillTable' is doing. Have you tried tracing the code with my debugger (see signature)?

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

It is a bit hard to say when we do not know what 'FillTable' is doing. Have you tried tracing the code with my debugger (see signature)?

Yes I have tried your debugger. It's invaluable some times. I can't wait for you keep improving it.

I was hoping if I kept the code simple someone would be more likely to respond but I can certainly see that in order to find the GUI problem you will need my entire script. So even though it's large I hope someone will take a look at it.

If you run this please note: When you would like to cancel the GUI if you use the X in the upper right there will be a 500ms delay. You can cancel it immediately by pressing the F3 key.

#include <GUIConstants.au3>

; Color ListBox credits go to:
;    Author Holger at http://www.autoitscript.com/forum/index.php?showtopic=26752&hl=WM_CTLCOLORLISTBOX+$listview

;AutoIt_Debugger_Command:Disable_Debug

AutoItSetOption("TrayIconDebug", 1);0-off
; Set so that tray displays current line number
;Press F3 to terminate script,
HotKeySet("{F3}", "Quit")

Global Const $WM_CTLCOLORLISTBOX    = 0x0134
; List of positions
Global $PositionsList = 'President,Vice President,Fin Recording Sec,Treasurer,Exec Board Member'
Global $Positions = StringSplit($PositionsList,',')

Dim $nTextClr1  = ReverseColorOrder(0x0000FF); RGB in parenthesis converted to BGR-value Dark Blue
Dim $nBkClr1    = ReverseColorOrder(0xC0F0F0); RGB in parenthesis converted to BGR-value Light Blue
Dim $hBrush1    = 0

Dim $nTextClr2  = ReverseColorOrder(0x000000); RGB in parenthesis converted to BGR-value Black
Dim $nBkClr2    = ReverseColorOrder(0x00ffff); RGB in parenthesis converted to BGR-value Cyan
Dim $hBrush2    = 0
Global $Officers[6]
; $Officers needs to be one more than the number of Officers Positions.
; Path to Results - Officers.txt file.
$results =  "Results - Officers.txt" 
 dim $President[6],    $PresidentCnt[6]
 dim $VicePresident[6],   $VicePresidentCnt[6]
 dim $FinRecordingSec[6], $FinRecordingSecCnt[6]
 dim $Treasurer[6],    $TreasurerCnt[6]
 dim $ExecBoardMember[6], $ExecBoardMemberCnt[6]
 dim $Found = ""
 
Dim $hGUI     = GUICreate("Officers Election 2006", 1395, 329, 200, 20 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS) , $WS_EX_TOPMOST)
$font="Comic Sans MS"
$Label_1 = GuiCtrlCreateLabel("ATU Election Results as They Are Being Tabulated", (@DesktopWidth-800)/2, 8, 550, 35)
GUICtrlSetFont (-1,15, 400, 4, $font)
$Label_2 = GuiCtrlCreateLabel("The results shown are not Official. They are still being tabulated.", 800, 310, 550, 35)
GUICtrlSetFont (-1,11, 400, 0, $font)

;Create listview header column titles 
$ListviewHead = ''
for $i = 1 to $Positions[0]
  $ListviewHead &= $Positions[$i] & '|Count'
    if $i <> $Positions[0] then $ListviewHead &= '|'
next

$listview = GuiCtrlCreateListView ($ListviewHead,10,50,1365,240)
$font="Comic Sans MS"
$fontsize=14
GUICtrlSetFont ($listview,$fontsize,400,0,$font)
SetColumnsWidth()

GUIRegisterMsg($WM_CTLCOLORLISTBOX, "WM_CTLCOLORLISTBOX")
GUISetState()

$listtop = 80
$nList1 = GUICtrlCreateList("", 10, $listtop, 185, 200)
GUICtrlSetData(-1, $President[1]&"|"&$President[2]&"|"&$President[3]&"|"&$President[4]&"|"&$President[5])
$nList2 = GUICtrlCreateList("", 190, $listtop, 90, 200)
GUICtrlSetData(-1, $PresidentCnt[1]&"|"&$PresidentCnt[2]&"|"&$PresidentCnt[3]&"|"&$PresidentCnt[4]&"|"&$PresidentCnt[5])
$nList3 = GUICtrlCreateList("", 276, $listtop, 185, 200)
GUICtrlSetData(-1, $VicePresident[1] & "|" & $VicePresident[2] & "|" & $VicePresident[3] & "|" & $VicePresident[4] & "|" & $VicePresident[5])
$nList4 = GUICtrlCreateList("", 457, $listtop, 90, 200)
GUICtrlSetData(-1, $VicePresidentCnt[1] & "|" & $VicePresidentCnt[2] & "|" & $VicePresidentCnt[3] & "|" & $VicePresidentCnt[4] & "|" & $VicePresidentCnt[5])
$nList5 = GUICtrlCreateList("", 543, $listtop, 185, 200)
GUICtrlSetData(-1, $FinRecordingSec[1] & "|" & $FinRecordingSec[2] & "|" & $FinRecordingSec[3] & "|" & $FinRecordingSec[4] & "|" & $FinRecordingSec[5])
$nList6 = GUICtrlCreateList("", 724, $listtop, 90, 200)
GUICtrlSetData(-1,  $FinRecordingSecCnt[1] & "|" &  $FinRecordingSecCnt[2] & "|" &  $FinRecordingSecCnt[3] & "|" &  $FinRecordingSecCnt[4] & "|" &  $FinRecordingSecCnt[5])
$nList7 = GUICtrlCreateList("", 810, $listtop, 185, 200)
GUICtrlSetData(-1, $Treasurer[1] & "|" & $Treasurer[2] & "|" & $Treasurer[3] & "|" & $Treasurer[4] & "|" & $Treasurer[5])
$nList8 = GUICtrlCreateList("", 991, $listtop, 90, 200)
GUICtrlSetData(-1, $TreasurerCnt[1] & "|" & $TreasurerCnt[2] & "|" & $TreasurerCnt[3] & "|" & $TreasurerCnt[4] & "|" & $TreasurerCnt[5])
$nList9 = GUICtrlCreateList("", 1077, $listtop, 210, 200)
GUICtrlSetData(-1, $ExecBoardMember[1] & "|" & $ExecBoardMember[2] & "|" & $ExecBoardMember[3] & "|" & $ExecBoardMember[4] & "|" & $ExecBoardMember[5])
$nList10 = GUICtrlCreateList("", 1283, $listtop, 90, 200)
GUICtrlSetData(-1, $ExecBoardMemberCnt[1] & "|" & $ExecBoardMemberCnt[2] & "|" & $ExecBoardMemberCnt[3] & "|" & $ExecBoardMemberCnt[4] & "|" & $ExecBoardMemberCnt[5])

;AutoIt_Debugger_Command:Enable_Debug

$MyFile = -1

While 1
    $Msg = GUIGetMsg()
    Select 
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $MyFile = -1 Then
                If FileExists($results) Then
                    $MyFile = FileOpen($results, 0)
                EndIf
            EndIf   
            If $MyFile <> -1 Then
                $rawline = FileReadLine($MyFile)
                If @error = -1 Then Sleep(500)
                If StringInStr($rawline, "Officers") Then
                    parse( $rawline)
                    FillTable()
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSelect
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf
DeleteObject($hBrush1)
DeleteObject($hBrush2)

Quit()


Func Parse($StringToParce)
;AutoIt_Debugger_Command:Disable_Debug
$ParsedString = 0
 $PartialString = ""
 $Check = ""
 
; Clear out the array $Officers Dim 6
 FOR $x = 1 to 5
  $Officers [$x] = ""
 NEXT
$Length = stringlen($StringToParce) + 1
 For $i = 11 to $Length
    $Character = StringMid ( $StringToParce, $i ,1)
    if $Character  = ","  then                  ;End of first field
      $i = $i + 1                                   ;Skip "
      For $i = $i + 1 to $Length                     ;Reading Name
        $Character = StringMid ( $StringToParce, $i ,1)
           If $Character <> '"' Then
              $PartialString = $PartialString & $Character 
           Else
              ExitLoop 
           EndIf
       $ParcingString = "Yes"
      next
    endif
    if $ParsedString < "5" then
            $ParsedString = $ParsedString + 1
            $Officers [$ParsedString] = $PartialString
            $PartialString = ""
            $ParcingString = "Finished"
            $msg = "ParsedString,$Officers " & $ParsedString & "   *" &  $Officers[$ParsedString] & "*"
    endif
 NEXT
return
;AutoIt_Debugger_Command:Enable_Debug
endfunc
Func FillTable()
;;AutoIt_Debugger_Command:Disable_Debug
$Found = ""

 If $Officers[1] <> "" Then
    For $i = 1 to 5
         If $Officers[1] = $President[$i] Then
           $PresidentCnt[$i] = $PresidentCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[1] <> "BLANK" Then
           For $i = 1 to 6
             If $President[$i] = "" Then
                 $President[$i] = $Officers[1]
                 $PresidentCnt[$i] = $PresidentCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf
        $msg = "President Votes  " & $President[1] & " " & $PresidentCnt[1] & @CRLF & _
                                     $President[2] & " " & $PresidentCnt[2]
$Found = ""
 If $Officers[2] <> "" Then
    For $i = 1 to 5
         If $Officers[2] = $VicePresident[$i] Then
           $VicePresidentCnt[$i] = $VicePresidentCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[2] <> "BLANK" Then
           For $i = 1 to 6
             If $VicePresident[$i] = "" Then
                 $VicePresident[$i] = $Officers[2]
                 $VicePresidentCnt[$i] = $VicePresidentCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "VicePresident Votes  " & $VicePresident[1] & " " & $VicePresidentCnt[1] & @CRLF & $VicePresident[2] & " " & $VicePresidentCnt[2] & @CRLF & $VicePresident[3] & " " & $VicePresidentCnt[3]
$Found = ""
 If $Officers[3] <> "" Then
    For $i = 1 to 5
         If $Officers[3] = $FinRecordingSec[$i] Then
           $FinRecordingSecCnt[$i] = $FinRecordingSecCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[3] <> "BLANK" Then
           For $i = 1 to 6
             If $FinRecordingSec[$i] = "" Then
                 $FinRecordingSec[$i] = $Officers[3]
                 $FinRecordingSecCnt[$i] = $FinRecordingSecCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "FinRecordingSec Votes  " & $FinRecordingSec[1] & " " & $FinRecordingSecCnt[1] & @CRLF & $FinRecordingSec[2] & " " & $FinRecordingSecCnt[2]
$Found = ""
 If $Officers[4] <> "" Then
    For $i = 1 to 5
         If $Officers[4] = $Treasurer[$i] Then
           $TreasurerCnt[$i] = $TreasurerCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[4] <> "BLANK" Then
           For $i = 1 to 6
             If $Treasurer[$i] = "" Then
                 $Treasurer[$i] = $Officers[4]
                 $TreasurerCnt[$i] = $TreasurerCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "Treasurer Votes  " & $Treasurer[1] & " " & $TreasurerCnt[1] & @CRLF & $Treasurer[2] & " " & $TreasurerCnt[2] & @CRLF & $Treasurer[3] & " " & $TreasurerCnt[3]
$Found = ""
 If $Officers[5] <> "" Then
    For $i = 1 to 5
         If $Officers[5] = $ExecBoardMember[$i] Then
           $ExecBoardMemberCnt[$i] = $ExecBoardMemberCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[5] <> "BLANK" Then
           For $i = 1 to 6
             If $ExecBoardMember[$i] = "" Then
                 $ExecBoardMember[$i] = $Officers[5]
                 $ExecBoardMemberCnt[$i] = $ExecBoardMemberCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "ExecBoardMember Votes  " & $ExecBoardMember[1] & " " & $ExecBoardMemberCnt[1] & @CRLF & $ExecBoardMember[2] & " " & $ExecBoardMemberCnt[2] & @CRLF & $ExecBoardMember[3] & " " & $ExecBoardMemberCnt[3] & @CRLF & $ExecBoardMember[4] & " " & $ExecBoardMemberCnt[4] & @CRLF & $ExecBoardMember[5] & " " & $ExecBoardMemberCnt[5]
;;AutoIt_Debugger_Command:Enable_Debug
endfunc

Func WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam)
;AutoIt_Debugger_Command:Disable_Debug  
    If $lParam = GUICtrlGetHandle($nList1) Then
        Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
    ElseIf $lParam = GUICtrlGetHandle($nList2) Then
        Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
    Else
        If  $lParam = GUICtrlGetHandle($nList3) Then
            Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
        ElseIf $lParam = GUICtrlGetHandle($nList4) Then
            Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
        Else
            If  $lParam = GUICtrlGetHandle($nList5) Then
                Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
            ElseIf $lParam = GUICtrlGetHandle($nList6) Then
                Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
            Else
                If  $lParam = GUICtrlGetHandle($nList7) Then
                    Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
                ElseIf $lParam = GUICtrlGetHandle($nList8) Then
                    Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
                Else
                    If  $lParam = GUICtrlGetHandle($nList9) Then
                        Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
                    ElseIf $lParam = GUICtrlGetHandle($nList10) Then
                        Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetListBoxColor($hDC, $nTextClr, $nBkColor, ByRef $hBrush)
;AutoIt_Debugger_Command:Disable_Debug  
    SetTextColor($hDC, $nTextClr)
    SetBkColor($hDC, $nBkColor)
   
    If $hBrush = 0 Then $hBrush = CreateSolidBrush($nBkColor)
    Return $hBrush
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetTextColor($hDC, $nColor)
;AutoIt_Debugger_Command:Disable_Debug  
    Local $nLastColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)
    Return $nLastColor[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetBkColor($hDC, $nColor)
;AutoIt_Debugger_Command:Disable_Debug
    Local $nLastColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)
    Return $nLastColor[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func CreateSolidBrush($nColor)
;AutoIt_Debugger_Command:Disable_Debug  
    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    Return $hBrush[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func DeleteObject($hObj)
;AutoIt_Debugger_Command:Disable_Debug  
    DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hObj)
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc
Func Quit()
; Close file.
FileClose($MyFile)
    Exit 0
EndFunc
Func SetColumnsWidth()
;AutoIt_Debugger_Command:Disable_Debug  
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, 180) ;President
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, 87)
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 2, 180) ;Vice President
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 3, 87)
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 4, 180) ;Fin Recording Sec
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 5, 87)
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 6, 180) ;Treasurer
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 7, 87)
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 8, 205) ;Exec Board Member
    GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 9, 87)
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc
Func ReverseColorOrder($v_color)
;AutoIt_Debugger_Command:Disable_Debug  
    Dim $tc = Hex(String($v_color), 6)
    Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc;==>ReverseColorOder

The code reads this data file:

It needs to be saved as "Results - Officers.txt""DIV1","Tom","","","",""

"OFFICERS","Scott","Buck","Jack","Hank","Buzz"

"OFFICERS","BLANK","BLANK","Jack","Hank","Buzz"

When this is run I expect names and numbers to show up in the GUI and they don't.

Thank you for looking at it.

Docfxit

Edited by docfxit
Link to comment
Share on other sites

You really have a mess here

#1

$listtop was not found so i fixed that ( you should be checking this script in SciTE Editor

( thats the least of the problems

#2

You are creating a listview..

$listview = GuiCtrlCreateListView ($ListviewHead,10,50,1365,240)

( this is probably what you want.. however

#3

in the samne space/area, you are creating numerous Lists"...

$nList1 = GUICtrlCreateList("", 10, $listtop, 185, 200)

GUICtrlSetData(-1, $President[1]&"|"&$President[2]&"|"&$President[3]&"|"&$President[4]&"|"&$President[5])

$nList2 = GUICtrlCreateList("", 190, $listtop, 90, 200)

etc... etc

I think what you are after is a "listview" not all of these "list" controls

its one or the other

... then you can work on the loop and how the data is set... but this comes first list or listview

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

You really have a mess here

#1

$listtop was not found so i fixed that ( you should be checking this script in SciTE Editor

( thats the least of the problems

Sorry. In my haste to clean up some things to make it easier to read I inadvertently removed that. I have fixed it in my last post so no one else needs to worry about it. I am using the SciTE Editor. It's the best.

#2

You are creating a listview..

$listview = GuiCtrlCreateListView ($ListviewHead,10,50,1365,240)

( this is probably what you want.. however

Yes it is.

#3

in the samne space/area, you are creating numerous Lists"...

$nList1 = GUICtrlCreateList("", 10, $listtop, 185, 200)

GUICtrlSetData(-1, $President[1]&"|"&$President[2]&"|"&$President[3]&"|"&$President[4]&"|"&$President[5])

$nList2 = GUICtrlCreateList("", 190, $listtop, 90, 200)

etc... etc

The different lists are allowing me to have multiple columns with different colors. I borrowed the code (concept) from Holger. You can see a link to his column coloring in the credits at the top of my script. I tried to expand upon the concept. If you run it you will see the colors.

I think what you are after is a "listview" not all of these "list" controls

its one or the other

I know this isn't something you normally see. Holger made it work in his sample. I guess I must have messed something up when I was adapting it to what I need.

... then you can work on the loop and how the data is set... but this comes first list or listview

How could I put a heading on the columns without using ListView? I removed all references to ListView lines and I still can't get the data to show

This is what it looks like now.

Thank you very much for the suggestions and looking at it.

#include <GUIConstants.au3>

; Color ListBox credits go to:
;    Author Holger at http://www.autoitscript.com/forum/index.php?showtopic=26752&hl=WM_CTLCOLORLISTBOX+$listview

;AutoIt_Debugger_Command:Disable_Debug

AutoItSetOption("TrayIconDebug", 1);0-off
; Set so that tray displays current line number
;Press F3 to terminate script,
HotKeySet("{F3}", "Quit")

Global Const $WM_CTLCOLORLISTBOX    = 0x0134

Dim $nTextClr1  = ReverseColorOrder(0x0000FF); RGB in parenthesis converted to BGR-value Dark Blue
Dim $nBkClr1    = ReverseColorOrder(0xC0F0F0); RGB in parenthesis converted to BGR-value Light Blue
Dim $hBrush1    = 0

Dim $nTextClr2  = ReverseColorOrder(0x000000); RGB in parenthesis converted to BGR-value Black
Dim $nBkClr2    = ReverseColorOrder(0x00ffff); RGB in parenthesis converted to BGR-value Cyan
Dim $hBrush2    = 0
Global $Officers[6]
; $Officers needs to be one more than the number of Officers Positions.
; Path to Results - Officers.txt file.
$results =  "C:\My Documents2\ATU\Election 2006 results\Unofficial Results - Officers\Results - Officers.txt" 
;$results =  "Results - Officers.txt" 
 dim $President[6],    $PresidentCnt[6]
 dim $VicePresident[6],   $VicePresidentCnt[6]
 dim $FinRecordingSec[6], $FinRecordingSecCnt[6]
 dim $Treasurer[6],    $TreasurerCnt[6]
 dim $ExecBoardMember[6], $ExecBoardMemberCnt[6]
 dim $Found = ""
 
Dim $hGUI     = GUICreate("Officers Election 2006", 1395, 329, 200, 20 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS) , $WS_EX_TOPMOST)
$font="Comic Sans MS"
$Label_1 = GuiCtrlCreateLabel("ATU Election Results as They Are Being Tabulated", (@DesktopWidth-800)/2, 8, 550, 35)
GUICtrlSetFont (-1,15, 400, 4, $font)
$Label_2 = GuiCtrlCreateLabel("The results shown are not Official. They are still being tabulated.", 800, 310, 550, 35)
GUICtrlSetFont (-1,11, 400, 0, $font)


GUIRegisterMsg($WM_CTLCOLORLISTBOX, "WM_CTLCOLORLISTBOX")
GUISetState()

$listtop = 80
$nList1 = GUICtrlCreateList("", 10, $listtop, 185, 200)
GUICtrlSetData(-1, $President[1]&"|"&$President[2]&"|"&$President[3]&"|"&$President[4]&"|"&$President[5])
$nList2 = GUICtrlCreateList("", 190, $listtop, 90, 200)
GUICtrlSetData(-1, $PresidentCnt[1]&"|"&$PresidentCnt[2]&"|"&$PresidentCnt[3]&"|"&$PresidentCnt[4]&"|"&$PresidentCnt[5])
$nList3 = GUICtrlCreateList("", 276, $listtop, 185, 200)
GUICtrlSetData(-1, $VicePresident[1] & "|" & $VicePresident[2] & "|" & $VicePresident[3] & "|" & $VicePresident[4] & "|" & $VicePresident[5])
$nList4 = GUICtrlCreateList("", 457, $listtop, 90, 200)
GUICtrlSetData(-1, $VicePresidentCnt[1] & "|" & $VicePresidentCnt[2] & "|" & $VicePresidentCnt[3] & "|" & $VicePresidentCnt[4] & "|" & $VicePresidentCnt[5])
$nList5 = GUICtrlCreateList("", 543, $listtop, 185, 200)
GUICtrlSetData(-1, $FinRecordingSec[1] & "|" & $FinRecordingSec[2] & "|" & $FinRecordingSec[3] & "|" & $FinRecordingSec[4] & "|" & $FinRecordingSec[5])
$nList6 = GUICtrlCreateList("", 724, $listtop, 90, 200)
GUICtrlSetData(-1,  $FinRecordingSecCnt[1] & "|" &  $FinRecordingSecCnt[2] & "|" &  $FinRecordingSecCnt[3] & "|" &  $FinRecordingSecCnt[4] & "|" &  $FinRecordingSecCnt[5])
$nList7 = GUICtrlCreateList("", 810, $listtop, 185, 200)
GUICtrlSetData(-1, $Treasurer[1] & "|" & $Treasurer[2] & "|" & $Treasurer[3] & "|" & $Treasurer[4] & "|" & $Treasurer[5])
$nList8 = GUICtrlCreateList("", 991, $listtop, 90, 200)
GUICtrlSetData(-1, $TreasurerCnt[1] & "|" & $TreasurerCnt[2] & "|" & $TreasurerCnt[3] & "|" & $TreasurerCnt[4] & "|" & $TreasurerCnt[5])
$nList9 = GUICtrlCreateList("", 1077, $listtop, 210, 200)
GUICtrlSetData(-1, $ExecBoardMember[1] & "|" & $ExecBoardMember[2] & "|" & $ExecBoardMember[3] & "|" & $ExecBoardMember[4] & "|" & $ExecBoardMember[5])
$nList10 = GUICtrlCreateList("", 1283, $listtop, 90, 200)
GUICtrlSetData(-1, $ExecBoardMemberCnt[1] & "|" & $ExecBoardMemberCnt[2] & "|" & $ExecBoardMemberCnt[3] & "|" & $ExecBoardMemberCnt[4] & "|" & $ExecBoardMemberCnt[5])

;AutoIt_Debugger_Command:Enable_Debug

$MyFile = -1

While 1
    $Msg = GUIGetMsg()
    Select 
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $MyFile = -1 Then
                If FileExists($results) Then
                    $MyFile = FileOpen($results, 0)
                EndIf
            EndIf   
            If $MyFile <> -1 Then
                $rawline = FileReadLine($MyFile)
                If @error = -1 Then Sleep(500)
                If StringInStr($rawline, "Officers") Then
                    parse( $rawline)
                    FillTable()
                EndIf
            Else
                Sleep(5000)
            EndIf
    EndSelect
WEnd

If $MyFile <> -1 Then
    FileClose($MyFile)
EndIf
DeleteObject($hBrush1)
DeleteObject($hBrush2)

Quit()


Func Parse($StringToParce)
;AutoIt_Debugger_Command:Disable_Debug
$ParsedString = 0
 $PartialString = ""
 $Check = ""
 
; Clear out the array $Officers Dim 6
 FOR $x = 1 to 5
  $Officers [$x] = ""
 NEXT
$Length = stringlen($StringToParce) + 1
 For $i = 11 to $Length
    $Character = StringMid ( $StringToParce, $i ,1)
    if $Character  = ","  then                      ;End of first field
      $i = $i + 1                                    ;Skip "
      For $i = $i + 1 to $Length                      ;Reading Name
        $Character = StringMid ( $StringToParce, $i ,1)
           If $Character <> '"' Then
              $PartialString = $PartialString & $Character 
           Else
              ExitLoop 
           EndIf
       $ParcingString = "Yes"
      next
    endif
    if $ParsedString < "5" then
            $ParsedString = $ParsedString + 1
            $Officers [$ParsedString] = $PartialString
            $PartialString = ""
            $ParcingString = "Finished"
            $msg = "ParsedString,$Officers " & $ParsedString & "   *" &  $Officers[$ParsedString] & "*"
    endif
 NEXT
return
;AutoIt_Debugger_Command:Enable_Debug
endfunc
Func FillTable()
;;AutoIt_Debugger_Command:Disable_Debug
$Found = ""

 If $Officers[1] <> "" Then
    For $i = 1 to 5
         If $Officers[1] = $President[$i] Then
           $PresidentCnt[$i] = $PresidentCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[1] <> "BLANK" Then
           For $i = 1 to 6
             If $President[$i] = "" Then
                 $President[$i] = $Officers[1]
                 $PresidentCnt[$i] = $PresidentCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf
        $msg = "President Votes  " & $President[1] & " " & $PresidentCnt[1] & @CRLF & _
                                     $President[2] & " " & $PresidentCnt[2]
$Found = ""
 If $Officers[2] <> "" Then
    For $i = 1 to 5
         If $Officers[2] = $VicePresident[$i] Then
           $VicePresidentCnt[$i] = $VicePresidentCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[2] <> "BLANK" Then
           For $i = 1 to 6
             If $VicePresident[$i] = "" Then
                 $VicePresident[$i] = $Officers[2]
                 $VicePresidentCnt[$i] = $VicePresidentCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "VicePresident Votes  " & $VicePresident[1] & " " & $VicePresidentCnt[1] & @CRLF & $VicePresident[2] & " " & $VicePresidentCnt[2] & @CRLF & $VicePresident[3] & " " & $VicePresidentCnt[3]
$Found = ""
 If $Officers[3] <> "" Then
    For $i = 1 to 5
         If $Officers[3] = $FinRecordingSec[$i] Then
           $FinRecordingSecCnt[$i] = $FinRecordingSecCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[3] <> "BLANK" Then
           For $i = 1 to 6
             If $FinRecordingSec[$i] = "" Then
                 $FinRecordingSec[$i] = $Officers[3]
                 $FinRecordingSecCnt[$i] = $FinRecordingSecCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "FinRecordingSec Votes  " & $FinRecordingSec[1] & " " & $FinRecordingSecCnt[1] & @CRLF & $FinRecordingSec[2] & " " & $FinRecordingSecCnt[2]
$Found = ""
 If $Officers[4] <> "" Then
    For $i = 1 to 5
         If $Officers[4] = $Treasurer[$i] Then
           $TreasurerCnt[$i] = $TreasurerCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[4] <> "BLANK" Then
           For $i = 1 to 6
             If $Treasurer[$i] = "" Then
                 $Treasurer[$i] = $Officers[4]
                 $TreasurerCnt[$i] = $TreasurerCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "Treasurer Votes  " & $Treasurer[1] & " " & $TreasurerCnt[1] & @CRLF & $Treasurer[2] & " " & $TreasurerCnt[2] & @CRLF & $Treasurer[3] & " " & $TreasurerCnt[3]
$Found = ""
 If $Officers[5] <> "" Then
    For $i = 1 to 5
         If $Officers[5] = $ExecBoardMember[$i] Then
           $ExecBoardMemberCnt[$i] = $ExecBoardMemberCnt[$i] + 1
           $Found = "Y"
           ExitLoop
        EndIf
           
    Next
       If $Found <> "Y" and $Officers[5] <> "BLANK" Then
           For $i = 1 to 6
             If $ExecBoardMember[$i] = "" Then
                 $ExecBoardMember[$i] = $Officers[5]
                 $ExecBoardMemberCnt[$i] = $ExecBoardMemberCnt[$i] + 1
                 ExitLoop
             EndIf
          Next     
       EndIf 
 EndIf  
        $msg = "ExecBoardMember Votes  " & $ExecBoardMember[1] & " " & $ExecBoardMemberCnt[1] & @CRLF & $ExecBoardMember[2] & " " & $ExecBoardMemberCnt[2] & @CRLF & $ExecBoardMember[3] & " " & $ExecBoardMemberCnt[3] & @CRLF & $ExecBoardMember[4] & " " & $ExecBoardMemberCnt[4] & @CRLF & $ExecBoardMember[5] & " " & $ExecBoardMemberCnt[5]
;;AutoIt_Debugger_Command:Enable_Debug
endfunc

Func WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam)
;AutoIt_Debugger_Command:Disable_Debug  
    If $lParam = GUICtrlGetHandle($nList1) Then
        Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
    ElseIf $lParam = GUICtrlGetHandle($nList2) Then
        Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
    Else
        If  $lParam = GUICtrlGetHandle($nList3) Then
            Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
        ElseIf $lParam = GUICtrlGetHandle($nList4) Then
            Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
        Else
            If  $lParam = GUICtrlGetHandle($nList5) Then
                Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
            ElseIf $lParam = GUICtrlGetHandle($nList6) Then
                Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
            Else
                If  $lParam = GUICtrlGetHandle($nList7) Then
                    Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
                ElseIf $lParam = GUICtrlGetHandle($nList8) Then
                    Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
                Else
                    If  $lParam = GUICtrlGetHandle($nList9) Then
                        Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)
                    ElseIf $lParam = GUICtrlGetHandle($nList10) Then
                        Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetListBoxColor($hDC, $nTextClr, $nBkColor, ByRef $hBrush)
;AutoIt_Debugger_Command:Disable_Debug  
    SetTextColor($hDC, $nTextClr)
    SetBkColor($hDC, $nBkColor)
   
    If $hBrush = 0 Then $hBrush = CreateSolidBrush($nBkColor)
    Return $hBrush
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetTextColor($hDC, $nColor)
;AutoIt_Debugger_Command:Disable_Debug  
    Local $nLastColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)
    Return $nLastColor[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func SetBkColor($hDC, $nColor)
;AutoIt_Debugger_Command:Disable_Debug
    Local $nLastColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)
    Return $nLastColor[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func CreateSolidBrush($nColor)
;AutoIt_Debugger_Command:Disable_Debug  
    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    Return $hBrush[0]
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc


Func DeleteObject($hObj)
;AutoIt_Debugger_Command:Disable_Debug  
    DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hObj)
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc
Func Quit()
; Close file.
FileClose($MyFile)
    Exit 0
EndFunc
Func ReverseColorOrder($v_color)
;AutoIt_Debugger_Command:Disable_Debug  
    Dim $tc = Hex(String($v_color), 6)
    Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
;AutoIt_Debugger_Command:Enable_Debug   
EndFunc ;==>ReverseColorOder

Thank you,

Docfxit

Edited by docfxit
Link to comment
Share on other sites

Some things are not right in your code, for example in the following, when I traced it, $President[1] is null/blank, so $Found is 'N'. The next part where $President[1] is set to a value is then skipped. $President[$i] never appeared to be set to a value. It was hard to follow as there is no high level description of the program. I think that you should debug Parse and Filltable to see what is happening. These are both skipped at the moment.

Also note that you can used codebox instead of code to show the script as below.

CODE
For $i = 1 to 5

If $Officers[1] = $President[$i] Then

$PresidentCnt[$i] = $PresidentCnt[$i] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[1] <> "BLANK" Then

For $i = 1 to 6

If $President[$i] = "" Then

$President[$i] = $Officers[1]

$PresidentCnt[$i] = $PresidentCnt[$i] + 1

ExitLoop

EndIf

Next

EndIf

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

Some things are not right in your code, for example in the following, when I traced it, $President[1] is null/blank, so $Found is 'N'. The next part where $President[1] is set to a value is then skipped. $President[$i] never appeared to be set to a value. It was hard to follow as there is no high level description of the program. I think that you should debug Parse and Filltable to see what is happening. These are both skipped at the moment.

Thank you for looking at my code.

The code that has to do with filling the value into $President[1] works just fine.

I think I can clear up the confusion by describing what this script does so it would be easier to follow it.

First I'd like to explain each line of the text file that gets read in has votes for candidates in an election. The script is only looking at the Officers votes. The first field in each line of the text file is a record ID. If Officers is in the record ID it's used in the script. The second field in the record is a vote for the president. The third field is a vote for the Vice President. etc..

When the record is read in the script looks to see if the name for president is in the array $President[$i]. If the name is in the array the script adds one to the count for President ($PresidentCnt[$i]). If the name is not in the array the script looks for the first empty slot in the array and adds the name also one gets added to the count.

$President[1] doesn't get filled in until the second record that gets read in. If you don't see that let me know the steps you are taking and I will try to figure out the problem. I'm guessing if you didn't see $President[1] get filled in it's because you only looked at the first record.

That is very nice of you to take the time to put it in the debugger and try it out.

Thank you,

Docfxit

Also note that you can used codebox instead of code to show the script as below.

I'm guessing the difference between using code and codebox is that codebox would create a scrolling box? I'm happy to do what ever you like. Wouldn't that make it harder to understand what is happening in a case like this?

CODE
For $i = 1 to 5

If $Officers[1] = $President[$i] Then

$PresidentCnt[$i] = $PresidentCnt[$i] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[1] <> "BLANK" Then

For $i = 1 to 6

If $President[$i] = "" Then

$President[$i] = $Officers[1]

$PresidentCnt[$i] = $PresidentCnt[$i] + 1

ExitLoop

EndIf

Next

EndIf

Edited by docfxit
Link to comment
Share on other sites

I think I have found your problem. I think you should do is:

1. Remove the line by line parsing of the file from the GUI monitoring loop. This should be seperate.

2. Create a function that is executed one time, once the complete file has been parsed.

3. Move all the 'GUICtrlSetData' statements for the Lists to the new function. This will load the values in the list, but only after the data has been parsed.

4. Consider parsing the text file using 'StringSplit' instead of manually (if possible).

After these changes, some data was shown that looked ok. The script was butchered, so I won't paste it here.

To codebox, or not to code box... I find that sometimes I miss small posts between large ones. Personal choice I guess.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

That is really great of you to work on it. Thanks.

I think I have found your problem. I think you should do is:

1. Remove the line by line parsing of the file from the GUI monitoring loop. This should be seperate.

Ok. This caused the X in the upper right to stop working again.

2. Create a function that is executed one time, once the complete file has been parsed.

The purpose of this script is to show the progress of the count during the count. The file that this reads is growing during the counting process. The people being elected want to see their votes during the 6hr count.

3. Move all the 'GUICtrlSetData' statements for the Lists to the new function. This will load the values in the list, but only after the data has been parsed.

Ok.

4. Consider parsing the text file using 'StringSplit' instead of manually (if possible).

Ok.

After these changes, some data was shown that looked ok. The script was butchered, so I won't paste it here.

To codebox, or not to code box... I find that sometimes I miss small posts between large ones. Personal choice I guess.

Is there a way to color code when using codebox? Can I do [autoitbox] ? Does it look better (easier to read) since I added color to the code boxes?

This is what I have so far. It is looking much better:

CODE

#include <GUIConstants.au3>

#include<Array.au3> ; Array Sort

#include <Date.au3> ; Time display

; Color ListBox credits go to:

; Author Holger at http://www.autoitscript.com/forum/index.ph...+$listview

; Operational Notes:

; Each line of the text file that gets read in has votes for candidates in an election. The script is only looking at the Officers votes.

; The first field in each line of the text file is a record ID. If Officers is in the record ID it's used in the script.

; The second field in the record is a vote for the president. The third field is a vote for the Vice President. etc..

; When the record is read in the script looks to see if the name for president is in the array $President[$i][1].

; If the name is in the array the script adds one to the count for President ($President[$i][2]).

; If the name is not in the array the script looks for the first empty slot in the array, adds the name and one gets added to the count.

; $President[1] doesn't get filled in until the second record that gets read in because the first record doesn't have a record ID = "Officers".

AutoItSetOption("TrayIconDebug", 1) ;0-off

; Set so that tray displays current line number

;Press F3 to terminate script,

HotKeySet("{F3}", "Quit")

HotKeySet("{F9}", "OnScreenShot")

Global Const $WM_CTLCOLORLISTBOX = 0x0134

Dim $nTextClr1 = ReverseColorOrder(0x0000FF) ; RGB in parenthesis converted to BGR-value Dark Blue

Dim $nBkClr1 = ReverseColorOrder(0xC0F0F0) ; RGB in parenthesis converted to BGR-value Light Blue

Dim $hBrush1 = 0

Dim $nTextClr2 = ReverseColorOrder(0x000000) ; RGB in parenthesis converted to BGR-value Black

Dim $nBkClr2 = ReverseColorOrder(0x00ffff) ; RGB in parenthesis converted to BGR-value Cyan

Dim $hBrush2 = 0

Global $Officers[5]

; $Officers needs to be one more than the number of Officers Positions.

; Path to Results - Officers.txt file.

;;$results = "C:\My Documents2\ATU\Election 2006 results\Unofficial Results - Officers\Results - Officers.txt"

$results = "Results - Officers.txt"

dim $President[6][3] ;Name, Count

dim $VicePresident[6][3] ;Name, Count

dim $FinRecordingSec[6][3] ;Name, Count

dim $Treasurer[6][3] ;Name, Count

dim $ExecBoardMember[8][3] ;Name, Count

dim $Found = ""

Dim $nList1 = "", $nList2 = "", $nList3 = "", $nList4 = "", $nList5 = ""

Dim $nList6 = "", $nList7 = "", $nList8 = "", $nList9 = "", $nList10 = ""

Dim $MyFile

Dim $LastFileSize = 0

Dim $RecordCount = 0

Dim $XS_btnx

$hGUI = GUICreate("Officers Election 2006", 1385, 300, 207, 20 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)

$font="Comic Sans MS"

$Label_1 = GuiCtrlCreateLabel("ATU Election Results as They Are Being Tabulated", (@DesktopWidth-800)/2, 8, 550, 35)

GUICtrlSetFont (-1,15, 400, 4, $font)

$Label_2 = GuiCtrlCreateLabel("The results shown are not Official. They are still being tabulated. " & _NowTime(), 800, 280, 550, 35)

GUICtrlSetFont (-1,11, 400, 0, $font)

$buttonPrint = IconButton("Print", 1300, 35, 70, 30, 16)

ShowGUI()

While 1

$Msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE ;-3 user clicked the close button 'x' in corner

Quit()

Case $msg = $buttonPrint ; 6 user clicked the

OnScreenShot()

Case Else

ConsoleWrite("Else - " & $msg & @LF)

$FileSize = FileGetSize($results)

If $FileSize <> $LastFileSize Then

ReadFile()

$LastFileSize = $FileSize

Sleep(250)

EndIf

Sleep(100)

EndSelect

WEnd

Func ReadFile()

$MyFile = -1

While 1

If $MyFile = -1 Then

If FileExists($results) Then

$MyFile = FileOpen($results, 0)

EndIf

EndIf

If $MyFile <> -1 Then

$rawline = FileReadLine($MyFile)

If @error = -1 Then

FileClose($MyFile) ;Reached End of File

ExitLoop

EndIf

If StringInStr($rawline, "Officers") Then

$RecordCount = $RecordCount + 1

parse( $rawline)

FillTable()

EndIf

Else

; Wait for file to be created

Sleep(5000)

EndIf

WEnd

_Arraysort($President,1,1,0,UBound($President,2),2)

_Arraysort($VicePresident,1,1,0,UBound($VicePresident,2),2)

_Arraysort($FinRecordingSec,1,1,0,UBound($FinRecordingSec,2),2)

_Arraysort($Treasurer,1,1,0,UBound($Treasurer,2),2)

_Arraysort($ExecBoardMember,1,1,0,UBound($ExecBoardMember,2),2)

ShowGUI()

endfunc

Func DisplayArray($array, $Title, $ArrayElement=0)

;AutoIt_Debugger_Command:Disable_Debug

ConsoleWrite($Title & @LF)

For $x = $ArrayElement To UBound($array,1) - 1

ConsoleWrite($x & " - " & $array[$x][1] & " - " & $array[$x][2] & @LF)

Next

;AutoIt_Debugger_Command:Enable_Debug

EndFunc;==>DisplayArray

Func ShowGUI()

;AutoIt_Debugger_Command:Disable_Debug

GUIRegisterMsg($WM_CTLCOLORLISTBOX, "WM_CTLCOLORLISTBOX")

GUISetState()

Global $listtop = 80, $FontSize = 15, $ListInsideHeight = 230

$nList1 = GUICtrlCreateList("", 10, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $President[1][1]&"|"&$President[2][1]&"|"&$President[3][1]&"|"&$President[4][1]&"|"&$President[5][1])

$nList2 = GUICtrlCreateList("", 190, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $President[1][2]&"|"&$President[2][2]&"|"&$President[3][2]&"|"&$President[4][2]&"|"&$President[5][2])

$nList3 = GUICtrlCreateList("", 276, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $VicePresident[1][1] & "|" & $VicePresident[2][1] & "|" & $VicePresident[3][1] & "|" & $VicePresident[4][1] & "|" & $VicePresident[5][1])

$nList4 = GUICtrlCreateList("", 457, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $VicePresident[1][2] & "|" & $VicePresident[2][2] & "|" & $VicePresident[3][2] & "|" & $VicePresident[4][2] & "|" & $VicePresident[5][2])

$nList5 = GUICtrlCreateList("", 543, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $FinRecordingSec[1][1] & "|" & $FinRecordingSec[2][1] & "|" & $FinRecordingSec[3][1] & "|" & $FinRecordingSec[4][1] & "|" & $FinRecordingSec[5][1])

$nList6 = GUICtrlCreateList("", 724, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $FinRecordingSec[1][2] & "|" & $FinRecordingSec[2][2] & "|" & $FinRecordingSec[3][2] & "|" & $FinRecordingSec[4][2] & "|" & $FinRecordingSec[5][2])

$nList7 = GUICtrlCreateList("", 810, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $Treasurer[1][1] & "|" & $Treasurer[2][1] & "|" & $Treasurer[3][1] & "|" & $Treasurer[4][1] & "|" & $Treasurer[5][1])

$nList8 = GUICtrlCreateList("", 991, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $Treasurer[1][2] & "|" & $Treasurer[2][2] & "|" & $Treasurer[3][2] & "|" & $Treasurer[4][2] & "|" & $Treasurer[5][2])

$nList9 = GUICtrlCreateList("", 1077, $listtop, 210, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $ExecBoardMember[1][1] & "|" & $ExecBoardMember[2][1] & "|" & $ExecBoardMember[3][1] & "|" & $ExecBoardMember[4][1] & "|" & $ExecBoardMember[5][1] & "|" & $ExecBoardMember[6][1] & "|" & $ExecBoardMember[7][1])

$nList10 = GUICtrlCreateList("", 1283, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $ExecBoardMember[1][2] & "|" & $ExecBoardMember[2][2] & "|" & $ExecBoardMember[3][2] & "|" & $ExecBoardMember[4][2] & "|" & $ExecBoardMember[5][2] & "|" & $ExecBoardMember[6][2] & "|" & $ExecBoardMember[7][2])

;AutoIt_Debugger_Command:Disable_Debug

endfunc

Func Parse($StringToParce)

;AutoIt_Debugger_Command:Disable_Debug

$StringToParce = StringMid($StringToParce, 12)

$StringToParce = StringReplace($StringToParce,'"','')

$Officers = StringSplit($StringToParce, ",")

return

;AutoIt_Debugger_Command:Enable_Debug

endfunc

Func FillTable()

;AutoIt_Debugger_Command:Disable_Debug

$Found = ""

If $Officers[1] <> "" Then

For $i = 1 to 5

If $Officers[1] = $President[$i][1] Then

$President[$i][2] = $President[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[1] <> "BLANK" Then

For $i = 1 to 6

If $President[$i][1] = "" Then

$President[$i][1] = $Officers[1]

$President[$i][2] = $President[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[2] <> "" Then

For $i = 1 to 5

If $Officers[2] = $VicePresident[$i][1] Then

$VicePresident[$i][2] = $VicePresident[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[2] <> "BLANK" Then

For $i = 1 to 6

If $VicePresident[$i][1] = "" Then

$VicePresident[$i][1] = $Officers[2]

$VicePresident[$i][2] = $VicePresident[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[3] <> "" Then

For $i = 1 to 5

If $Officers[3] = $FinRecordingSec[$i][1] Then

$FinRecordingSec[$i][2] = $FinRecordingSec[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[3] <> "BLANK" Then

For $i = 1 to 6

If $FinRecordingSec[$i][1] = "" Then

$FinRecordingSec[$i][1] = $Officers[3]

$FinRecordingSec[$i][2] = $FinRecordingSec[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[4] <> "" Then

For $i = 1 to 5

If $Officers[4] = $Treasurer[$i][1] Then

$Treasurer[$i][2] = $Treasurer[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[4] <> "BLANK" Then

For $i = 1 to 6

If $Treasurer[$i][1] = "" Then

$Treasurer[$i][1] = $Officers[4]

$Treasurer[$i][2] = $Treasurer[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[5] <> "" Then

For $i = 1 to 7

If $Officers[5] = $ExecBoardMember[$i][1] Then

$ExecBoardMember[$i][2] = $ExecBoardMember[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[5] <> "BLANK" Then

For $i = 1 to 8

If $ExecBoardMember[$i][1] = "" Then

$ExecBoardMember[$i][1] = $Officers[5]

$ExecBoardMember[$i][2] = $ExecBoardMember[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

;AutoIt_Debugger_Command:Enable_Debug

endfunc

Func WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam)

;AutoIt_Debugger_Command:Disable_Debug

If $lParam = GUICtrlGetHandle($nList1) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList2) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList3) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList4) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList5) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList6) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList7) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList8) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList9) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList10) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

EndIf

EndIf

EndIf

EndIf

EndIf

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetListBoxColor($hDC, $nTextClr, $nBkColor, ByRef $hBrush)

;AutoIt_Debugger_Command:Disable_Debug

SetTextColor($hDC, $nTextClr)

SetBkColor($hDC, $nBkColor)

If $hBrush = 0 Then $hBrush = CreateSolidBrush($nBkColor)

Return $hBrush

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetTextColor($hDC, $nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $nLastColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)

Return $nLastColor[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetBkColor($hDC, $nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $nLastColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)

Return $nLastColor[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func CreateSolidBrush($nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)

Return $hBrush[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func DeleteObject($hObj)

;AutoIt_Debugger_Command:Disable_Debug

DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hObj)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func OnScreenShot()

;AutoIt_Debugger_Command:Disable_Debug

If Not FileExists (@scriptdir & "\screenshots") Then DirCreate (@scriptdir & "\screenshots")

If Not FileExists(@scriptdir & "\captplugin.dll") Then FileInstall( "captplugin.dll", @scriptdir & "" ,1)

Local $Cwin1 = WinGetHandle(""); gets the handle of the active window

Local $Cwin2 = WinGetPos($Cwin1); gets active window dimensions

Local $Quality = 85; use -1 to save as BMP or use number between 0 - 100 to save as JPG quality

If $Quality = -1 Then

Local $SaveAs = ".bmp"

Else

Local $SaveAs = ".jpg"

EndIf

Local $CaptureDirectory = @ScriptDir & "\Screenshots\"; directory uses to store screen caps

Local $CaptureFile = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & "-" & @SEC & $SaveAs

; Capture given region

; Fist parameter - filename, next four: left, top, width, height. Last one - jpeg quality.

; Set quality to any negative number to capture into BMP

$Result = DllCall(@scriptdir & "\captdll.dll", "int", "CaptureRegion", "str", $CaptureDirectory & $CaptureFile, "int", $Cwin2[0], "int", $Cwin2[1], "int", $Cwin2[2], "int", $Cwin2[3], "int", $Quality)

If @error Then MsgBox(262160,"ERROR","The screen was not captured" & @CRLF & "Error - " & @error & @CRLF & "DLL Result" & $result,4)

Send("{enter}")

_FilePrintCom($CaptureDirectory & $CaptureFile)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func _FilePrintCom($iFile)

;AutoIt_Debugger_Command:Disable_Debug

; works when there is a Print option available for a file Extension:

; for a picture it opened it with the windows picture viewer, for a TXT it printed to the default.

If Not FileExists($iFile) Then Return SetError(1,0,0)

$objShellApp = ObjCreate("Shell.Application")

$objShellApp.ShellExecute($iFile,0,0,"PRINT",0)

Send("{enter}")

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = "shell32.dll")

;AutoIt_Debugger_Command:Disable_Debug

GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - 16) / 2), 16, 16)

GUICtrlSetState( -1, $GUI_DISABLE)

$XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS)

Return $XS_btnx

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func ReverseColorOrder($v_color)

;AutoIt_Debugger_Command:Disable_Debug

Dim $tc = Hex(String($v_color), 6)

Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc ;==>ReverseColorOder

Func Quit()

;DeleteObject($hBrush1)

;DeleteObject($hBrush2)

; Close file.

FileClose($MyFile)

Exit 0

EndFunc

When I run this in the Debugger and select RUN none of the variables show. Is there a way to make them show?

When I run this in the Debugger and step through it some of the variables show but not all of them. I can see the correct variable info in the GUI but not in the debugger variables. What am I doing wrong?

The information is showing up in the GUI centered top to bottom. How can I make it list starting at the top?

How can I make the X in the top right work again?

Did I move everything the way you suggested?

Thank you very much for spending time on it. That's really great of you. I realize it's different because of the different colored columns. Some people said it couldn't be done in AutoIt. I think it looks good.

Docfxit

Edited by docfxit
Link to comment
Share on other sites

The X does not work because the message loop is never reached. The first loop never exits. The message loop should always be priority. All other functions should be called from it.

If the results file is being written to, there should be some code to detect when the file changes so that it can be read again. This check should be made from the message loop. Suggest reading the whole file in one go then returning to the message loop until another change is detected.

I don't think you can colour the codebox.

The debugger does not show variables when RUN unless it is paused or a breakpoint reached. This allows the program to run faster than if you continually hit step on.

The data is centred in the GUI because you are adding empty items through the arrays (Sam|||). Try it yourself with a seperate script.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

Also you are using variable $Msg for two purposes at the same time, maybe it's reason of your problems with not closing.

Great catch. Removing the second reference to $Msg has re-activated the closing of the GUI. I still need to wait for 500ms which is understandable. It sure would be nice if they modified the Sleep command so it could be interrupted with the $GUI_EVENT_CLOSE event.

Great job finding that. :-)

Thank you,

Docfxit

Link to comment
Share on other sites

The X does not work because the message loop is never reached.

Zedna found that $Msg was being used multiple times for different purposes.

The first loop never exits. The message loop should always be priority. All other functions should be called from it.

I moved that code out of the message loop because you suggested that in post#11 Item#1. I don't understand how to code it when you say "This should be seperate." and "All other functions should be called from it"

Could you please give me a code sample so I would know how to change it.

If the results file is being written to, there should be some code to detect when the file changes so that it can be read again. This check should be made from the message loop. Suggest reading the whole file in one go then returning to the message loop until another change is detected.

Are you suggesting that I check the file size within the message loop to determine when to read the file? If not what would you suggest I use to detect a file change?

I don't think you can colour the codebox.

No problem. I can see if a person is going to download the code it would be nicer to put it into a codebox. I can see if a person is going to look at the code in the thread it would be nicer to put it into a [autoit box. I will put the remaining updates into a codebox for you.

The debugger does not show variables when RUN unless it is paused or a breakpoint reached.

I didn't know you could use breakpoints. I just went to your web page and discovered how to use the breakpoint feature. That's great. :-) Nice feature. The web page shows boxes for the breakpoint. I have a blank area where the boxes should be.

Is it possible the boxes require a special font?

Is there a way to put a breakpoint in the code?

How can a person pause the script when RUN is selected?

Is there a way to show the variables when the script is finished?

This allows the program to run faster than if you continually hit step on.

The data is centred in the GUI because you are adding empty items through the arrays (Sam|||). Try it yourself with a seperate script.

I don't see that. If you look at it in the debugger you can see that the first time the data is written into the arrays it's written into the first element in the array ($President[1]). When that gets written the first time to the GUI $President[1] gets centered. The debugger is great. It shows this very clearly.

Thank you very much for looking at the code and making these suggestions. All suggestions are welcome.

I will try to discover a way to detect when the file read has been changed.

Thank you,

Docfxit

Link to comment
Share on other sites

If the file is being written to external to this program, I guess that you would want to read the data in a fixed interval, or just when the file date or size changes. You have not really detailed this part of the operation. I would probably do something like this for the message loop:

#Include <Date.au3>
Dim $LastCheck
While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            CheckTimer()
    EndSelect
WEnd

Func CheckTimer()
    If _DateDiff("s", _NowCalc(), $LastCheck) > 10 Then
        Check For file change...
        $LastCheck = _NowCalc()
    EndIf
Endfunc

A fixed interval check is easiest, as shown above. I think there are other 'file change detection' scripts on the forum also.

For the item appearing in the middle of the list, try the following example and note that 'Item1' is not at the top as I would have expected. I think this is what is happening with you dim 6 array with only one value, You may want to change it to a variable length array using _ArrayAdd/_ArrayDelete.

#include <GUIConstants.au3>
GUICreate("My GUI"); will create a dialog box that when displayed is centered
GUICtrlCreateList ("", 10,10)
GUICtrlSetData(-1,"item1|||||", "item3")
GUISetState ()   ; will display an empty dialog box with a combo control with focus on
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

The debugger pic on the website is a bit old. Click the line number in your example to add a breakpoint.

You cannot put a breakpoint in the au3 file. At some point I would like the program to store it that way. That may not happen for a while though.

You can pause the script when running by clicking on the Step-Into button while the program is running. The variables will be shown when paused.

Note that Enable_Debug and Disable_Debug disable variable tracking until the variable is processed again in single step mode. I may change that in the future.

Edited by Stumpii

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

You can pause the script when running by clicking on the Step-Into button while the program is running. The variables will be shown when paused.

Thank you very much for your suggestions. I'm working on them.

I ran into something interesting. I'm trying to run my changes in the Debugger. I found with my changes that the results come out wrong when I run it with a live file. When I ran it in the Debugger I let it run 2.5 hrs. I tried pausing it but it didn't work. The Debugger didn't pause. I did discover that I could add a breakpoint while it was running which was really great. The Debugger did stop with a breakpoint I added on the fly. After running 2.5 hrs. it was on record # 40 of 2,677 records. I noticed that after stopping the Debugger with a breakpoint the task in TaskManager kept running using about 98% of the CPU. It sounds to me that the Debugger gets into a tight loop and doesn't quit when it stops at a breakpoint. I hope that will give you some information to improve the Debugger.

Thank you,

Docfxit

Link to comment
Share on other sites

Thank you very much for your suggestions. I'm working on them.

I ran into something interesting. I'm trying to run my changes in the Debugger. I found with my changes that the results come out wrong when I run it with a live file. When I ran it in the Debugger I let it run 2.5 hrs. I tried pausing it but it didn't work. The Debugger didn't pause. I did discover that I could add a breakpoint while it was running which was really great. The Debugger did stop with a breakpoint I added on the fly. After running 2.5 hrs. it was on record # 40 of 2,677 records. I noticed that after stopping the Debugger with a breakpoint the task in TaskManager kept running using about 98% of the CPU. It sounds to me that the Debugger gets into a tight loop and doesn't quit when it stops at a breakpoint. I hope that will give you some information to improve the Debugger.

Thank you,

Docfxit

I think the problem is that the trace window gets continually longer and slows the program down. I need to add an enable/disable trace feature when I get time. Thanks for letting me know. The debugger still needs some work for use with long scripts.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

I have made a bunch of changes to the script. I'm having a couple problems that I would like help on if your up for the challenge.

1. When I click on the X in the top right corner while it's reading the file it won't exit. Of course I am reading a live file with 2677 records. If I press HotKey F3 it closes just fine. Is there some way I could define a HotKey to the X in the top right corner?

2. When I click on the print button it prints multiple pages. Is there some way to make it only print once?

3. When it prints it brings up a program I have loaded to view jpg files. Is there a way to hide the program or minimize it for this operation?

CODE
#include <GUIConstants.au3>

#include<Array.au3> ; Array Sort

#include <Date.au3> ; Time display

; Color ListBox credits go to:

; Author Holger at http://www.autoitscript.com/forum/index.ph...+$listview

; Operational Notes:

; Each line of the text file that gets read in has votes for candidates in an election. The script is only looking at the Officers votes.

; The first field in each line of the text file is a record ID. If Officers is in the record ID it's used in the script.

; The second field in the record is a vote for the president. The third field is a vote for the Vice President. etc..

; When the record is read in the script looks to see if the name for president is in the array $President[$i][1].

; If the name is in the array the script adds one to the count for President ($President[$i][2]).

; If the name is not in the array the script looks for the first empty slot in the array, adds the name and one gets added to the count.

; $President[1] doesn't get filled in until the second record that gets read in because the first record doesn't have a record ID = "Officers".

AutoItSetOption("TrayIconDebug", 1) ;0-off

; Set so that tray displays current line number

;Press F3 to terminate script,

HotKeySet("{F3}", "Quit")

HotKeySet("{F9}", "OnScreenShot")

Global Const $WM_CTLCOLORLISTBOX = 0x0134

Dim $nTextClr1 = ReverseColorOrder(0x0000FF) ; RGB in parenthesis converted to BGR-value Dark Blue

Dim $nBkClr1 = ReverseColorOrder(0xC0F0F0) ; RGB in parenthesis converted to BGR-value Light Blue

Dim $hBrush1 = 0

Dim $nTextClr2 = ReverseColorOrder(0x000000) ; RGB in parenthesis converted to BGR-value Black

Dim $nBkClr2 = ReverseColorOrder(0x00ffff) ; RGB in parenthesis converted to BGR-value Cyan

Dim $hBrush2 = 0

Global $Officers[5]

; $Officers needs to be one more than the number of Officers Positions.

; Path to Results - Officers.txt file.

;;$results = "C:\My Documents2\ATU\Election 2006 results\Unofficial Results - Officers\Results - Officers.txt"

$results = "Results - Officers.txt"

dim $President[6][3] ;Name, Count

dim $VicePresident[6][3] ;Name, Count

dim $FinRecordingSec[6][3] ;Name, Count

dim $Treasurer[6][3] ;Name, Count

dim $ExecBoardMember[8][3] ;Name, Count

dim $Found = ""

Dim $nList1 = "", $nList2 = "", $nList3 = "", $nList4 = "", $nList5 = ""

Dim $nList6 = "", $nList7 = "", $nList8 = "", $nList9 = "", $nList10 = ""

Dim $MyFile

Dim $LastFileSize = 0

Dim $RecordCount = 0

Dim $XS_btnx

$hGUI = GUICreate("Officers Election 2006", 1385, 300, 207, 20 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)

$font="Comic Sans MS"

$Label_1 = GuiCtrlCreateLabel("ATU Election Results as They Are Being Tabulated", (@DesktopWidth-800)/2, 8, 550, 35)

GUICtrlSetFont (-1,15, 400, 4, $font)

$Label_2 = GuiCtrlCreateLabel("The results shown are not Official. They are still being tabulated. " & _NowTime(), 800, 280, 550, 35)

GUICtrlSetFont (-1,11, 400, 0, $font)

$buttonPrint = IconButton("Print", 1300, 35, 70, 30, 16)

ShowGUI()

While 1

$Msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE ;-3 user clicked the close button 'x' in corner

Quit()

Case $msg = $buttonPrint ; 6 user clicked the

OnScreenShot()

Case Else

ConsoleWrite("Else - " & $msg & @LF)

$FileSize = FileGetSize($results)

If $FileSize <> $LastFileSize Then

ReadFile()

$LastFileSize = $FileSize

Sleep(250)

EndIf

Sleep(100)

EndSelect

WEnd

Func ReadFile()

$MyFile = -1

While 1

If $MyFile = -1 Then

If FileExists($results) Then

$MyFile = FileOpen($results, 0)

EndIf

EndIf

If $MyFile <> -1 Then

$rawline = FileReadLine($MyFile)

If @error = -1 Then

FileClose($MyFile) ;Reached End of File

ExitLoop

EndIf

If StringInStr($rawline, "Officers") Then

$RecordCount = $RecordCount + 1

parse( $rawline)

FillTable()

EndIf

Else

; Wait for file to be created

Sleep(5000)

EndIf

WEnd

_Arraysort($President,1,1,0,UBound($President,2),2)

_Arraysort($VicePresident,1,1,0,UBound($VicePresident,2),2)

_Arraysort($FinRecordingSec,1,1,0,UBound($FinRecordingSec,2),2)

_Arraysort($Treasurer,1,1,0,UBound($Treasurer,2),2)

_Arraysort($ExecBoardMember,1,1,0,UBound($ExecBoardMember,2),2)

ShowGUI()

endfunc

Func DisplayArray($array, $Title, $ArrayElement=0)

;AutoIt_Debugger_Command:Disable_Debug

ConsoleWrite($Title & @LF)

For $x = $ArrayElement To UBound($array,1) - 1

ConsoleWrite($x & " - " & $array[$x][1] & " - " & $array[$x][2] & @LF)

Next

;AutoIt_Debugger_Command:Enable_Debug

EndFunc;==>DisplayArray

Func ShowGUI()

;AutoIt_Debugger_Command:Disable_Debug

GUIRegisterMsg($WM_CTLCOLORLISTBOX, "WM_CTLCOLORLISTBOX")

GUISetState()

Global $listtop = 80, $FontSize = 15, $ListInsideHeight = 230

$nList1 = GUICtrlCreateList("", 10, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $President[1][1]&"|"&$President[2][1]&"|"&$President[3][1]&"|"&$President[4][1]&"|"&$President[5][1])

$nList2 = GUICtrlCreateList("", 190, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $President[1][2]&"|"&$President[2][2]&"|"&$President[3][2]&"|"&$President[4][2]&"|"&$President[5][2])

$nList3 = GUICtrlCreateList("", 276, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $VicePresident[1][1] & "|" & $VicePresident[2][1] & "|" & $VicePresident[3][1] & "|" & $VicePresident[4][1] & "|" & $VicePresident[5][1])

$nList4 = GUICtrlCreateList("", 457, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $VicePresident[1][2] & "|" & $VicePresident[2][2] & "|" & $VicePresident[3][2] & "|" & $VicePresident[4][2] & "|" & $VicePresident[5][2])

$nList5 = GUICtrlCreateList("", 543, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $FinRecordingSec[1][1] & "|" & $FinRecordingSec[2][1] & "|" & $FinRecordingSec[3][1] & "|" & $FinRecordingSec[4][1] & "|" & $FinRecordingSec[5][1])

$nList6 = GUICtrlCreateList("", 724, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $FinRecordingSec[1][2] & "|" & $FinRecordingSec[2][2] & "|" & $FinRecordingSec[3][2] & "|" & $FinRecordingSec[4][2] & "|" & $FinRecordingSec[5][2])

$nList7 = GUICtrlCreateList("", 810, $listtop, 185, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $Treasurer[1][1] & "|" & $Treasurer[2][1] & "|" & $Treasurer[3][1] & "|" & $Treasurer[4][1] & "|" & $Treasurer[5][1])

$nList8 = GUICtrlCreateList("", 991, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $Treasurer[1][2] & "|" & $Treasurer[2][2] & "|" & $Treasurer[3][2] & "|" & $Treasurer[4][2] & "|" & $Treasurer[5][2])

$nList9 = GUICtrlCreateList("", 1077, $listtop, 210, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $ExecBoardMember[1][1] & "|" & $ExecBoardMember[2][1] & "|" & $ExecBoardMember[3][1] & "|" & $ExecBoardMember[4][1] & "|" & $ExecBoardMember[5][1] & "|" & $ExecBoardMember[6][1] & "|" & $ExecBoardMember[7][1])

$nList10 = GUICtrlCreateList("", 1283, $listtop, 90, $ListInsideHeight, $WS_BORDER)

GUICtrlSetFont (-1,$FontSize, 400, 0, $font)

GUICtrlSetData(-1, $ExecBoardMember[1][2] & "|" & $ExecBoardMember[2][2] & "|" & $ExecBoardMember[3][2] & "|" & $ExecBoardMember[4][2] & "|" & $ExecBoardMember[5][2] & "|" & $ExecBoardMember[6][2] & "|" & $ExecBoardMember[7][2])

;AutoIt_Debugger_Command:Disable_Debug

endfunc

Func Parse($StringToParce)

;AutoIt_Debugger_Command:Disable_Debug

$StringToParce = StringMid($StringToParce, 12)

$StringToParce = StringReplace($StringToParce,'"','')

$Officers = StringSplit($StringToParce, ",")

return

;AutoIt_Debugger_Command:Enable_Debug

endfunc

Func FillTable()

;AutoIt_Debugger_Command:Disable_Debug

$Found = ""

If $Officers[1] <> "" Then

For $i = 1 to 5

If $Officers[1] = $President[$i][1] Then

$President[$i][2] = $President[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[1] <> "BLANK" Then

For $i = 1 to 6

If $President[$i][1] = "" Then

$President[$i][1] = $Officers[1]

$President[$i][2] = $President[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[2] <> "" Then

For $i = 1 to 5

If $Officers[2] = $VicePresident[$i][1] Then

$VicePresident[$i][2] = $VicePresident[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[2] <> "BLANK" Then

For $i = 1 to 6

If $VicePresident[$i][1] = "" Then

$VicePresident[$i][1] = $Officers[2]

$VicePresident[$i][2] = $VicePresident[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[3] <> "" Then

For $i = 1 to 5

If $Officers[3] = $FinRecordingSec[$i][1] Then

$FinRecordingSec[$i][2] = $FinRecordingSec[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[3] <> "BLANK" Then

For $i = 1 to 6

If $FinRecordingSec[$i][1] = "" Then

$FinRecordingSec[$i][1] = $Officers[3]

$FinRecordingSec[$i][2] = $FinRecordingSec[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[4] <> "" Then

For $i = 1 to 5

If $Officers[4] = $Treasurer[$i][1] Then

$Treasurer[$i][2] = $Treasurer[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[4] <> "BLANK" Then

For $i = 1 to 6

If $Treasurer[$i][1] = "" Then

$Treasurer[$i][1] = $Officers[4]

$Treasurer[$i][2] = $Treasurer[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

$Found = ""

If $Officers[5] <> "" Then

For $i = 1 to 7

If $Officers[5] = $ExecBoardMember[$i][1] Then

$ExecBoardMember[$i][2] = $ExecBoardMember[$i][2] + 1

$Found = "Y"

ExitLoop

EndIf

Next

If $Found <> "Y" and $Officers[5] <> "BLANK" Then

For $i = 1 to 8

If $ExecBoardMember[$i][1] = "" Then

$ExecBoardMember[$i][1] = $Officers[5]

$ExecBoardMember[$i][2] = $ExecBoardMember[$i][2] + 1

ExitLoop

EndIf

Next

EndIf

EndIf

;AutoIt_Debugger_Command:Enable_Debug

endfunc

Func WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam)

;AutoIt_Debugger_Command:Disable_Debug

If $lParam = GUICtrlGetHandle($nList1) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList2) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList3) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList4) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList5) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList6) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList7) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList8) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

Else

If $lParam = GUICtrlGetHandle($nList9) Then

Return SetListBoxColor($wParam, $nTextClr1, $nBkClr1, $hBrush1)

ElseIf $lParam = GUICtrlGetHandle($nList10) Then

Return SetListBoxColor($wParam, $nTextClr2, $nBkClr2, $hBrush2)

EndIf

EndIf

EndIf

EndIf

EndIf

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetListBoxColor($hDC, $nTextClr, $nBkColor, ByRef $hBrush)

;AutoIt_Debugger_Command:Disable_Debug

SetTextColor($hDC, $nTextClr)

SetBkColor($hDC, $nBkColor)

If $hBrush = 0 Then $hBrush = CreateSolidBrush($nBkColor)

Return $hBrush

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetTextColor($hDC, $nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $nLastColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)

Return $nLastColor[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func SetBkColor($hDC, $nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $nLastColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)

Return $nLastColor[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func CreateSolidBrush($nColor)

;AutoIt_Debugger_Command:Disable_Debug

Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)

Return $hBrush[0]

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func DeleteObject($hObj)

;AutoIt_Debugger_Command:Disable_Debug

DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hObj)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func OnScreenShot()

;AutoIt_Debugger_Command:Disable_Debug

If Not FileExists (@scriptdir & "\screenshots") Then DirCreate (@scriptdir & "\screenshots")

If Not FileExists(@scriptdir & "\captplugin.dll") Then FileInstall( "captplugin.dll", @scriptdir & "" ,1)

Local $Cwin1 = WinGetHandle(""); gets the handle of the active window

Local $Cwin2 = WinGetPos($Cwin1); gets active window dimensions

Local $Quality = 85; use -1 to save as BMP or use number between 0 - 100 to save as JPG quality

If $Quality = -1 Then

Local $SaveAs = ".bmp"

Else

Local $SaveAs = ".jpg"

EndIf

Local $CaptureDirectory = @ScriptDir & "\Screenshots\"; directory uses to store screen caps

Local $CaptureFile = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & "-" & @SEC & $SaveAs

; Capture given region

; Fist parameter - filename, next four: left, top, width, height. Last one - jpeg quality.

; Set quality to any negative number to capture into BMP

$Result = DllCall(@scriptdir & "\captdll.dll", "int", "CaptureRegion", "str", $CaptureDirectory & $CaptureFile, "int", $Cwin2[0], "int", $Cwin2[1], "int", $Cwin2[2], "int", $Cwin2[3], "int", $Quality)

If @error Then MsgBox(262160,"ERROR","The screen was not captured" & @CRLF & "Error - " & @error & @CRLF & "DLL Result" & $result,4)

Send("{enter}")

_FilePrintCom($CaptureDirectory & $CaptureFile)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func _FilePrintCom($iFile)

;AutoIt_Debugger_Command:Disable_Debug

; works when there is a Print option available for a file Extension:

; for a picture it opened it with the windows picture viewer, for a TXT it printed to the default.

If Not FileExists($iFile) Then Return SetError(1,0,0)

$objShellApp = ObjCreate("Shell.Application")

$objShellApp.ShellExecute($iFile,0,0,"PRINT",0)

Send("{enter}")

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = "shell32.dll")

;AutoIt_Debugger_Command:Disable_Debug

GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - 16) / 2), 16, 16)

GUICtrlSetState( -1, $GUI_DISABLE)

$XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS)

Return $XS_btnx

;AutoIt_Debugger_Command:Enable_Debug

EndFunc

Func ReverseColorOrder($v_color)

;AutoIt_Debugger_Command:Disable_Debug

Dim $tc = Hex(String($v_color), 6)

Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)

;AutoIt_Debugger_Command:Enable_Debug

EndFunc ;==>ReverseColorOder

Func Quit()

;DeleteObject($hBrush1)

;DeleteObject($hBrush2)

; Close file.

FileClose($MyFile)

Exit 0

EndFunc

Thank you,

Docfxit

Edited by docfxit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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