Jump to content

A bit complex problem for my level


Recommended Posts

Hello everybody, I'm new to this forums, and hopefully will get better at AutoIT because it seems amazing and simple !

I'm trying to code a small tool which will help me count my number of tasks and keeping a track of it without having to write into a txt file manually, but I'm running into my first problem, I'm trying to write automatically the task name with the number of times I'm doing it, but I have no clue on how to NOT duplicate line of the similar task, and add counts on an already existing one, my code so far :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

#Region (=== GUI generated by GuiBuilderPlus 1.0.0-beta3 ===)
Global $hGUI = GUICreate("Task Count Manager", 290, 104, 1080, 545)

Global $Label_1 = GUICtrlCreateLabel("Task actuelle:", 30, 20, 71, 11)
Global $Button_10 = GUICtrlCreateButton("10", 30, 60, 21, 21)
Global $Button_20 = GUICtrlCreateButton("20", 60, 60, 21, 21)
Global $Button_25 = GUICtrlCreateButton("25", 90, 60, 21, 21)
Global $Button_30 = GUICtrlCreateButton("30", 120, 60, 21, 21)
Global $Button_50 = GUICtrlCreateButton("50", 150, 60, 21, 21)
Global $Button_70 = GUICtrlCreateButton("70", 180, 60, 21, 21)
Global $Button_75 = GUICtrlCreateButton("75", 210, 60, 21, 21)
Global $Button_100 = GUICtrlCreateButton("100", 240, 60, 21, 21)
Global $Label_2 = GUICtrlCreateLabel("", 95, 20, 291, 25)
#EndRegion (=== GUI generated by GuiBuilderPlus 1.0.0-beta3 ===)

_main()

;------------------------------------------------------------------------------
; Title...........: _main
; Description.....: run the main program loop
;------------------------------------------------------------------------------
Func _main()
    GUISetState(@SW_SHOWNORMAL)
$MY_TITLE_REGEX = "(?:localhost)"
Opt("WinTitleMatchMode", 4)
$handle = WinGetHandle("[REGEXPTITLE:" & $MY_TITLE_REGEX & "]")
$taskname = WinGetTitle($handle)
$taskname_t = StringTrimRight($taskname, 27)
GUICTRLSetData($Label_2, $taskname_t)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_10
                FileWrite("C:\Streaming\dettes.txt", $taskname_t & ":" & "10" & @CRLF)
            Case Else
                ;
        EndSwitch
    WEnd
EndFunc   ;==>_main

Any help would be greatly appreciated, thanks !

Link to post
Share on other sites

Maybe consider using an .ini file instead of .txt file.  You can read the actual value of an entry with an .ini file, add a value and rewrite the new added value to the .ini file.

Link to post
Share on other sites
36 minutes ago, Nine said:

Maybe consider using an .ini file instead of .txt file.  You can read the actual value of an entry with an .ini file, add a value and rewrite the new added value to the .ini file.

Thought about it, but for formatting and appealing purposes, it won't suit my needs as I'm reading the txt file through my desktop overlay.

Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...