Jump to content

How to Run Multiple Functios


Recommended Posts

Hey , I Have A Problem In Running Multiple Functions At The Time ,, Like If The Timer IS on Then I cant Press on Any Button or Close The Gui or Select anyThing from A Contex Menu For an Example , But the HotKey Works O.o Here My Code if U need it :D

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TheBlackAutoSaver", 651, 373, 257, 171)
$program = GUICtrlCreateLabel("program:", 230, 166, 88, 23)
$Timer = GUICtrlCreateLabel("Timer", 96, 56, 44, 23)
$Input1 = GUICtrlCreateInput("", 552, 8, 81, 21)
$Input2 = GUICtrlCreateInput("", 144, 56, 97, 21)
$Start = GUICtrlCreateButton("Start", 176, 320, 121, 25)
GUICtrlSetOnEvent(-1, 'start')
$Add = GUICtrlCreateButton("Add", 496, 8, 49, 25)
GUICtrlSetOnEvent(-1, 'add')
$Delete = GUICtrlCreateButton("Delete", 496, 40, 137, 25)
GUICtrlSetOnEvent(-1, 'Delete')
$Group1 = GUICtrlCreateGroup("Timer", 96, 152, 281, 145, BitOR($GUI_SS_DEFAULT_GROUP, $WS_BORDER))
GUICtrlSetBkColor(-1, 0x008080)
$Status = GUICtrlCreateLabel("Status:", 120, 168, 40, 17)
GUICtrlSetTip(-1, "The Status")
$Label1 = GUICtrlCreateLabel("TImer", 120, 216, 76, 17)
$Label2 = GUICtrlCreateLabel("Minutes Passed", 120, 248, 76, 17)
$Label3 = GUICtrlCreateLabel("seconds", 120, 272, 76, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton(" Add From ProccessList ", 504, 344, 121, 25)
GUICtrlSetOnEvent(-1, 'hPList')
$Label9 = GUICtrlCreateLabel("Times Saved : ", 8, 344, 75, 17)
GUISetState(@SW_SHOW)
$Contex1 = GUICtrlCreateContextMenu()
Local $Chide = GUICtrlCreateMenuItem("Hide", $Contex1)
GUICtrlSetOnEvent(-1, 'Hide')
Local $idMenuOpen = GUICtrlCreateMenuItem("Exit", $Contex1)
GUICtrlSetOnEvent(-1, '_Exit')
GUICtrlCreateMenuItem("", $Contex1)
Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $Contex1)
GUICtrlSetOnEvent(-1, 'Info')
TraySetIcon("C:\Users\SuPeRBiGMaC\Downloads\1406157282_27876.ico", -1)
Local $TrayExit = TrayCreateItem("Show")
TrayItemSetOnEvent(-1, '_Show')
Local $TrayShow = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, 'Exit1')
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
#endregion ### END Koda GUI section ###
; -------------------\\  Loader // ---------------------------- |  Starts  |
Global $File = @WorkingDir & "\App.txt"
Local $iFileExists = FileExists($File)
Global $List1 = GUICtrlCreateList("", 488, 72, 145, 266)

If $iFileExists Then
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    FileOpen($File, 0)
    ;$List1 = GUICtrlCreateList("", 496, 72, 145, 279)
    For $i = 1 To _FileCountLines($File)
        $line = FileReadLine($File, $i)
        GUICtrlSetData($List1, $line & "|")
    Next
    FileClose($File)
Else
    _FileCreate($File)

EndIf
HotKeySet("{ESC}", "_Terminate")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

; ------------------------- \\ List Loader // --------------------- |  Ends  |
Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Show()
    GUISetState(@SW_SHOW)
EndFunc   ;==>_Show

Func Hide()
    GUISetState(@SW_HIDE)
    TrayTip("AutoSaver", "Dont Worry , Iam Still Here :D ", 10)
EndFunc   ;==>Hide

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func Info()
    Opt("GUIOnEventMode", 1)
    $About = GUICreate("About", 321, 243, 302, 218)
    $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 201)
    $Image1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157275_Save.jpg", 112, 24, 105, 73)
    $name = GUICtrlCreateLabel("The BLackAutoSaver", 112, 104, 107, 17)
    $Version = GUICtrlCreateLabel("1.00", 152, 128, 25, 17)
    $Rights = GUICtrlCreateLabel("All The CopyRights Are Reserved To TheBlacKCoder @2014", 16, 144, 294, 17)
    $Pic1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157497_46-facebook.jpg", 104, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'fb')
    $Pic2 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157783_43-twitter.jpg", 152, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'twit')
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("&OK", 116, 208, 75, 25, 0)
    GUICtrlSetOnEvent(-1, 'ok')
    GUISetState(@SW_SHOW)


EndFunc   ;==>Info

Func ok()
    GUIDelete()
EndFunc   ;==>ok

Func AddP()
    $Plist = GUICtrlRead($list2)
    $x1 = StringTrimRight($Plist, 4)
    GUICtrlSetData($List1, $x1 & "|")
    GUIDelete()
    FileOpen($File, 0)
    FileWrite($File, $x1)
    FileClose($File)
EndFunc   ;==>AddP

Func fb()
    ShellExecute("https://www.facebook.com/Super.Mas.7")
EndFunc   ;==>fb

Func twit()
    ShellExecute("https://twitter.com/AnwerMac")
EndFunc   ;==>twit
Func hPlist()
    $Form2 = GUICreate("Form1", 266, 455, 446, 218)
    Global $List2 = GUICtrlCreateList("", 56, 24, 145, 370)
    $ButtonP = GUICtrlCreateButton("Button1", 56, 416, 129, 25)
    GUICtrlSetOnEvent(-1, 'AddP')
    GUISetState(@SW_SHOW)

    $hPlist = ProcessList()

    For $i = 1 To $hPlist[0][0]
        GUICtrlSetData($List2, $hPlist[$i][0])
    Next

    If $hPlist[0][0] = 0 Then MsgBox("", "", "Proccess List equal 0 ")
EndFunc   ;==>hPlist
;                                                                                                                   ------------------- \\ Functions Area // ------------------------

; ----------------------Timer Function Starts Here \\ Start  //-----------------
Func Add()
    $Add = GUICtrlRead($Input1)
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    $hFileWrite = _FileCountLines($File)
    $hLine = $hFileWrite + 1
    FileWrite($File, $Add & @CRLF)
    FileClose($File)
    GUICtrlSetData(-1, $Add & "|")
EndFunc   ;==>Add
; ------------------------------------------------------------------
Func Delete()
    $x1 = GUICtrlRead($List1)
    _GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCaretIndex($List1))
    Dim $aRecords
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    _FileReadToArray($File, $aRecords)
    For $x = 1 To $aRecords[0]
        If StringInStr($aRecords[$x], $x1) Then
            _FileWriteToLine($File, $x, "", 1)
        EndIf
    Next
    FileClose($File)
EndFunc   ;==>Delete

Func _Timer()


    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    $Minutes = GUICtrlRead($Input2)
    Local $60Count = 0, $begin = TimerInit()


    While $Minutes > $60Count


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
        $Label6 = GUICtrlCreateLabel($Minutes, 280, 216, 33, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel($60Count, 280, 244, 89, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel($Count, 288, 268, 65, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("Working", 168, 168, 45, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel($x1, 296, 167, 45, 17)
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************

        Sleep(200)
        
    WEnd
    If $Minutes = $60Count Then Call("_Save")
EndFunc   ;==>_Timer
;-----------------------------\\ Timer Ends Here // ------------------------------


Func _Terminate()
    Exit
EndFunc   ;==>_Terminate
; --------------------

Func Start()

    $x1 = GUICtrlRead($List1)
    $x2 = GUICtrlRead($Input2)

    If $List1 = "" Or $x2 = "" Then
        MsgBox("", "", "Error , Please Check That U Enter A value In The Timer InputBox  , Or That u have Selected  a Program ! ")
    ElseIf ProcessExists($x1 & ".exe") Then
        ;GUISetState(@SW_HIDE)
        Call("_Timer")
        
    Else
        MsgBox("", "", "The Program must Be Runnig for The Autosaver to work ")
    EndIf

EndFunc   ;==>Start



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")
    
    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")
        
    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save
Link to comment
Share on other sites

Take a look at my attempt below, i did not test it, but using AdlibRegister should make the _timer() function not lock up your script anymore (if i implemented it correct :) )

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TheBlackAutoSaver", 651, 373, 257, 171)
$program = GUICtrlCreateLabel("program:", 230, 166, 88, 23)
$Timer = GUICtrlCreateLabel("Timer", 96, 56, 44, 23)
$Input1 = GUICtrlCreateInput("", 552, 8, 81, 21)
$Input2 = GUICtrlCreateInput("", 144, 56, 97, 21)
$Start = GUICtrlCreateButton("Start", 176, 320, 121, 25)
GUICtrlSetOnEvent(-1, 'start')
$Add = GUICtrlCreateButton("Add", 496, 8, 49, 25)
GUICtrlSetOnEvent(-1, 'add')
$Delete = GUICtrlCreateButton("Delete", 496, 40, 137, 25)
GUICtrlSetOnEvent(-1, 'Delete')
$Group1 = GUICtrlCreateGroup("Timer", 96, 152, 281, 145, BitOR($GUI_SS_DEFAULT_GROUP, $WS_BORDER))
GUICtrlSetBkColor(-1, 0x008080)
$Status = GUICtrlCreateLabel("Status:", 120, 168, 40, 17)
GUICtrlSetTip(-1, "The Status")
$Label1 = GUICtrlCreateLabel("TImer", 120, 216, 76, 17)
$Label2 = GUICtrlCreateLabel("Minutes Passed", 120, 248, 76, 17)
$Label3 = GUICtrlCreateLabel("seconds", 120, 272, 76, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton(" Add From ProccessList ", 504, 344, 121, 25)
GUICtrlSetOnEvent(-1, 'hPList')
$Label9 = GUICtrlCreateLabel("Times Saved : ", 8, 344, 75, 17)
GUISetState(@SW_SHOW)
$Contex1 = GUICtrlCreateContextMenu()
Local $Chide = GUICtrlCreateMenuItem("Hide", $Contex1)
GUICtrlSetOnEvent(-1, 'Hide')
Local $idMenuOpen = GUICtrlCreateMenuItem("Exit", $Contex1)
GUICtrlSetOnEvent(-1, '_Exit')
GUICtrlCreateMenuItem("", $Contex1)
Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $Contex1)
GUICtrlSetOnEvent(-1, 'Info')
TraySetIcon("C:\Users\SuPeRBiGMaC\Downloads\1406157282_27876.ico", -1)
Local $TrayExit = TrayCreateItem("Show")
TrayItemSetOnEvent(-1, '_Show')
Local $TrayShow = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, 'Exit1')
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
#endregion ### END Koda GUI section ###
; -------------------\\  Loader // ---------------------------- |  Starts  |
Global $File = @WorkingDir & "\App.txt"
Local $iFileExists = FileExists($File)
Global $List1 = GUICtrlCreateList("", 488, 72, 145, 266)

If $iFileExists Then
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    FileOpen($File, 0)
    ;$List1 = GUICtrlCreateList("", 496, 72, 145, 279)
    For $i = 1 To _FileCountLines($File)
        $line = FileReadLine($File, $i)
        GUICtrlSetData($List1, $line & "|")
    Next
    FileClose($File)
Else
    _FileCreate($File)

EndIf
HotKeySet("{ESC}", "_Terminate")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

; ------------------------- \\ List Loader // --------------------- |  Ends  |
Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Show()
    GUISetState(@SW_SHOW)
EndFunc   ;==>_Show

Func Hide()
    GUISetState(@SW_HIDE)
    TrayTip("AutoSaver", "Dont Worry , Iam Still Here :D ", 10)
EndFunc   ;==>Hide

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func Info()
    Opt("GUIOnEventMode", 1)
    $About = GUICreate("About", 321, 243, 302, 218)
    $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 201)
    $Image1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157275_Save.jpg", 112, 24, 105, 73)
    $name = GUICtrlCreateLabel("The BLackAutoSaver", 112, 104, 107, 17)
    $Version = GUICtrlCreateLabel("1.00", 152, 128, 25, 17)
    $Rights = GUICtrlCreateLabel("All The CopyRights Are Reserved To TheBlacKCoder @2014", 16, 144, 294, 17)
    $Pic1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157497_46-facebook.jpg", 104, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'fb')
    $Pic2 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157783_43-twitter.jpg", 152, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'twit')
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("&OK", 116, 208, 75, 25, 0)
    GUICtrlSetOnEvent(-1, 'ok')
    GUISetState(@SW_SHOW)


EndFunc   ;==>Info

Func ok()
    GUIDelete()
EndFunc   ;==>ok

Func AddP()
    $Plist = GUICtrlRead($list2)
    $x1 = StringTrimRight($Plist, 4)
    GUICtrlSetData($List1, $x1 & "|")
    GUIDelete()
    FileOpen($File, 0)
    FileWrite($File, $x1)
    FileClose($File)
EndFunc   ;==>AddP

Func fb()
    ShellExecute("https://www.facebook.com/Super.Mas.7")
EndFunc   ;==>fb

Func twit()
    ShellExecute("https://twitter.com/AnwerMac")
EndFunc   ;==>twit
Func hPlist()
    $Form2 = GUICreate("Form1", 266, 455, 446, 218)
    Global $List2 = GUICtrlCreateList("", 56, 24, 145, 370)
    $ButtonP = GUICtrlCreateButton("Button1", 56, 416, 129, 25)
    GUICtrlSetOnEvent(-1, 'AddP')
    GUISetState(@SW_SHOW)

    $hPlist = ProcessList()

    For $i = 1 To $hPlist[0][0]
        GUICtrlSetData($List2, $hPlist[$i][0])
    Next

    If $hPlist[0][0] = 0 Then MsgBox("", "", "Proccess List equal 0 ")
EndFunc   ;==>hPlist
;                                                                                                                   ------------------- \\ Functions Area // ------------------------

; ----------------------Timer Function Starts Here \\ Start  //-----------------
Func Add()
    $Add = GUICtrlRead($Input1)
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    $hFileWrite = _FileCountLines($File)
    $hLine = $hFileWrite + 1
    FileWrite($File, $Add & @CRLF)
    FileClose($File)
    GUICtrlSetData(-1, $Add & "|")
EndFunc   ;==>Add
; ------------------------------------------------------------------
Func Delete()
    $x1 = GUICtrlRead($List1)
    _GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCaretIndex($List1))
    Dim $aRecords
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    _FileReadToArray($File, $aRecords)
    For $x = 1 To $aRecords[0]
        If StringInStr($aRecords[$x], $x1) Then
            _FileWriteToLine($File, $x, "", 1)
        EndIf
    Next
    FileClose($File)
EndFunc   ;==>Delete

Func _Timer()

    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    $Minutes = GUICtrlRead($Input2)
    Static $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value


    IF  $Minutes > $60Count Then    ;No loop until timer completes


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
        $Label6 = GUICtrlCreateLabel($Minutes, 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel($60Count, 280, 244, 89, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel($Count, 288, 268, 65, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("Working", 168, 168, 45, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel($x1, 296, 167, 45, 17)
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************

        ;Sleep(200)

    EndIf
    If $Minutes = $60Count Then
        Call("_Save")
        AdlibUnRegister(_Timer) ;Stop calling the function
    EndIf

EndFunc   ;==>_Timer
;-----------------------------\\ Timer Ends Here // ------------------------------


Func _Terminate()
    Exit
EndFunc   ;==>_Terminate
; --------------------

Func Start()

    $x1 = GUICtrlRead($List1)
    $x2 = GUICtrlRead($Input2)

    If $List1 = "" Or $x2 = "" Then
        MsgBox("", "", "Error , Please Check That U Enter A value In The Timer InputBox  , Or That u have Selected  a Program ! ")
    ElseIf ProcessExists($x1 & ".exe") Then
        ;GUISetState(@SW_HIDE)
        Call("_Timer")

    Else
        MsgBox("", "", "The Program must Be Runnig for The Autosaver to work ")
    EndIf

EndFunc   ;==>Start



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")

    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")

    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save
Link to comment
Share on other sites

 

Take a look at my attempt below, i did not test it, but using AdlibRegister should make the _timer() function not lock up your script anymore (if i implemented it correct :) )

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TheBlackAutoSaver", 651, 373, 257, 171)
$program = GUICtrlCreateLabel("program:", 230, 166, 88, 23)
$Timer = GUICtrlCreateLabel("Timer", 96, 56, 44, 23)
$Input1 = GUICtrlCreateInput("", 552, 8, 81, 21)
$Input2 = GUICtrlCreateInput("", 144, 56, 97, 21)
$Start = GUICtrlCreateButton("Start", 176, 320, 121, 25)
GUICtrlSetOnEvent(-1, 'start')
$Add = GUICtrlCreateButton("Add", 496, 8, 49, 25)
GUICtrlSetOnEvent(-1, 'add')
$Delete = GUICtrlCreateButton("Delete", 496, 40, 137, 25)
GUICtrlSetOnEvent(-1, 'Delete')
$Group1 = GUICtrlCreateGroup("Timer", 96, 152, 281, 145, BitOR($GUI_SS_DEFAULT_GROUP, $WS_BORDER))
GUICtrlSetBkColor(-1, 0x008080)
$Status = GUICtrlCreateLabel("Status:", 120, 168, 40, 17)
GUICtrlSetTip(-1, "The Status")
$Label1 = GUICtrlCreateLabel("TImer", 120, 216, 76, 17)
$Label2 = GUICtrlCreateLabel("Minutes Passed", 120, 248, 76, 17)
$Label3 = GUICtrlCreateLabel("seconds", 120, 272, 76, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton(" Add From ProccessList ", 504, 344, 121, 25)
GUICtrlSetOnEvent(-1, 'hPList')
$Label9 = GUICtrlCreateLabel("Times Saved : ", 8, 344, 75, 17)
GUISetState(@SW_SHOW)
$Contex1 = GUICtrlCreateContextMenu()
Local $Chide = GUICtrlCreateMenuItem("Hide", $Contex1)
GUICtrlSetOnEvent(-1, 'Hide')
Local $idMenuOpen = GUICtrlCreateMenuItem("Exit", $Contex1)
GUICtrlSetOnEvent(-1, '_Exit')
GUICtrlCreateMenuItem("", $Contex1)
Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $Contex1)
GUICtrlSetOnEvent(-1, 'Info')
TraySetIcon("C:\Users\SuPeRBiGMaC\Downloads\1406157282_27876.ico", -1)
Local $TrayExit = TrayCreateItem("Show")
TrayItemSetOnEvent(-1, '_Show')
Local $TrayShow = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, 'Exit1')
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
#endregion ### END Koda GUI section ###
; -------------------\\  Loader // ---------------------------- |  Starts  |
Global $File = @WorkingDir & "\App.txt"
Local $iFileExists = FileExists($File)
Global $List1 = GUICtrlCreateList("", 488, 72, 145, 266)

If $iFileExists Then
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    FileOpen($File, 0)
    ;$List1 = GUICtrlCreateList("", 496, 72, 145, 279)
    For $i = 1 To _FileCountLines($File)
        $line = FileReadLine($File, $i)
        GUICtrlSetData($List1, $line & "|")
    Next
    FileClose($File)
Else
    _FileCreate($File)

EndIf
HotKeySet("{ESC}", "_Terminate")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

; ------------------------- \\ List Loader // --------------------- |  Ends  |
Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Show()
    GUISetState(@SW_SHOW)
EndFunc   ;==>_Show

Func Hide()
    GUISetState(@SW_HIDE)
    TrayTip("AutoSaver", "Dont Worry , Iam Still Here :D ", 10)
EndFunc   ;==>Hide

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func Info()
    Opt("GUIOnEventMode", 1)
    $About = GUICreate("About", 321, 243, 302, 218)
    $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 201)
    $Image1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157275_Save.jpg", 112, 24, 105, 73)
    $name = GUICtrlCreateLabel("The BLackAutoSaver", 112, 104, 107, 17)
    $Version = GUICtrlCreateLabel("1.00", 152, 128, 25, 17)
    $Rights = GUICtrlCreateLabel("All The CopyRights Are Reserved To TheBlacKCoder @2014", 16, 144, 294, 17)
    $Pic1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157497_46-facebook.jpg", 104, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'fb')
    $Pic2 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157783_43-twitter.jpg", 152, 160, 41, 41)
    GUICtrlSetOnEvent(-1, 'twit')
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("&OK", 116, 208, 75, 25, 0)
    GUICtrlSetOnEvent(-1, 'ok')
    GUISetState(@SW_SHOW)


EndFunc   ;==>Info

Func ok()
    GUIDelete()
EndFunc   ;==>ok

Func AddP()
    $Plist = GUICtrlRead($list2)
    $x1 = StringTrimRight($Plist, 4)
    GUICtrlSetData($List1, $x1 & "|")
    GUIDelete()
    FileOpen($File, 0)
    FileWrite($File, $x1)
    FileClose($File)
EndFunc   ;==>AddP

Func fb()
    ShellExecute("https://www.facebook.com/Super.Mas.7")
EndFunc   ;==>fb

Func twit()
    ShellExecute("https://twitter.com/AnwerMac")
EndFunc   ;==>twit
Func hPlist()
    $Form2 = GUICreate("Form1", 266, 455, 446, 218)
    Global $List2 = GUICtrlCreateList("", 56, 24, 145, 370)
    $ButtonP = GUICtrlCreateButton("Button1", 56, 416, 129, 25)
    GUICtrlSetOnEvent(-1, 'AddP')
    GUISetState(@SW_SHOW)

    $hPlist = ProcessList()

    For $i = 1 To $hPlist[0][0]
        GUICtrlSetData($List2, $hPlist[$i][0])
    Next

    If $hPlist[0][0] = 0 Then MsgBox("", "", "Proccess List equal 0 ")
EndFunc   ;==>hPlist
;                                                                                                                   ------------------- \\ Functions Area // ------------------------

; ----------------------Timer Function Starts Here \\ Start  //-----------------
Func Add()
    $Add = GUICtrlRead($Input1)
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    $hFileWrite = _FileCountLines($File)
    $hLine = $hFileWrite + 1
    FileWrite($File, $Add & @CRLF)
    FileClose($File)
    GUICtrlSetData(-1, $Add & "|")
EndFunc   ;==>Add
; ------------------------------------------------------------------
Func Delete()
    $x1 = GUICtrlRead($List1)
    _GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCaretIndex($List1))
    Dim $aRecords
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    _FileReadToArray($File, $aRecords)
    For $x = 1 To $aRecords[0]
        If StringInStr($aRecords[$x], $x1) Then
            _FileWriteToLine($File, $x, "", 1)
        EndIf
    Next
    FileClose($File)
EndFunc   ;==>Delete

Func _Timer()

    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    $Minutes = GUICtrlRead($Input2)
    Static $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value


    IF  $Minutes > $60Count Then    ;No loop until timer completes


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
        $Label6 = GUICtrlCreateLabel($Minutes, 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel($60Count, 280, 244, 89, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel($Count, 288, 268, 65, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("Working", 168, 168, 45, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel($x1, 296, 167, 45, 17)
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************

        ;Sleep(200)

    EndIf
    If $Minutes = $60Count Then
        Call("_Save")
        AdlibUnRegister(_Timer) ;Stop calling the function
    EndIf

EndFunc   ;==>_Timer
;-----------------------------\\ Timer Ends Here // ------------------------------


Func _Terminate()
    Exit
EndFunc   ;==>_Terminate
; --------------------

Func Start()

    $x1 = GUICtrlRead($List1)
    $x2 = GUICtrlRead($Input2)

    If $List1 = "" Or $x2 = "" Then
        MsgBox("", "", "Error , Please Check That U Enter A value In The Timer InputBox  , Or That u have Selected  a Program ! ")
    ElseIf ProcessExists($x1 & ".exe") Then
        ;GUISetState(@SW_HIDE)
        Call("_Timer")

    Else
        MsgBox("", "", "The Program must Be Runnig for The Autosaver to work ")
    EndIf

EndFunc   ;==>Start



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")

    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")

    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save

Thanx It Did The Trick :D .... One More Thing Do u Know How to Make A Counter :D Each TIme The Timer Finishes Its loop It Add 1 to A label so I Can track How many Times The Timer Worked ?

Link to comment
Share on other sites

Do u Know How to Make A Counter  :D Each TIme The Timer Finishes Its loop It Add 1 to A label so I Can track How many Times The Timer Worked ?

 

 

Local $VariableForTimer = 0

Do something

$variableForTimer = $variableForTimer +1

ToolTip($variableForTimer, 0,0)

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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...