Sign in to follow this  
Followers 0
TheBlackGamer

Help With AutoSaver Code

6 posts in this topic

Hi i Have A Problem With My code .... I cant Arrange The Actions OF The Code !

I want to The Code to Do as the Following :

1- Check If the User Selected An Item From The List Box -- > If Yes move to step 2 -- > If not Send an Messagebox

2- Check If The Programer Is Running Or not --> If Running Start The TImer Code --> If not senda a messagebox to The USer

3 - The Timer Code Starts

 

Here Is The Whole (Sorry Its a Mess ) ;The Timer Code I Got from The Forums i Dont Have  The Author Name Right now ! 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form
$Form1 = GUICreate("TheBlackAutoSaver", 650, 372, 257, 171)
$Status = GUICtrlCreateLabel("Status", 184, 168, 34, 17)
GUICtrlSetTip(-1, "The Status ")
GUICtrlSetOnEvent(-1, "Label1Click")
$program = GUICtrlCreateLabel("program", 40, 40, 76, 17)
$Timer = GUICtrlCreateLabel("Timer",  256, 40, 76, 23)
;$Input1 = GUICtrlCreateInput("Input1", 120, 40, 161, 21)
$Input2 = GUICtrlCreateInput("", 320, 40, 161, 21)
$Start = GUICtrlCreateButton("Start", 8, 312, 121, 25)
GUICtrlSetOnEvent(-1, 'start')
$Pause = GUICtrlCreateButton("Pause", 152, 312, 75, 25)
GUICtrlSetOnEvent(-1, 'pause')
$Label1 = GUICtrlCreateLabel("TImer", 168, 192, 76, 17)
$Label2 = GUICtrlCreateLabel("Minutes Passed", 168, 216, 76, 17)
$Label3 = GUICtrlCreateLabel("seconds ", 168, 240, 76, 17)
$Add = GUICtrlCreateButton("Add", 520, 8, 49, 25)
GUICtrlSetOnEvent(-1, 'Add')
$Delete = GUICtrlCreateButton("Delete", 576, 8, 65, 25)
GUICtrlSetOnEvent(-1,'Delete')
;$List1 = GUICtrlCreateList("", 520, 40, 121, 279)
$Input1 = GUICtrlCreateInput("Input1", 208, 8, 161, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
$List1 = GUICtrlCreateList("", 520, 40, 121, 279)
FileOpen($file, 0)

For $i = 1 to _FileCountLines($file)
    $line = FileReadLine($file, $i)
GUICtrlSetData(-1, $line &"|")
Next
FileClose($file)
;------------------------------------------------------------------------------------------------- ==> Functions Starts Here !
Func Timer()

$Minutes = 1 ;will wait the time in The InputBox minutes
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)
 
If $Minutes = $60Count Then 

   Call("Autosave")
 
;*********************************************************************
; // This The Label Section \\ Start Here
;---------------------------------------------------------------------------------
$Label6 = GUICtrlCreateLabel($Minutes, 296, 192, 33, 17)
GUICtrlSetBkColor(-1, 0x00FF00)
$Label7 = GUICtrlCreateLabel($60Count, 296, 212, 89, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
$Label8 = GUICtrlCreateLabel($Count, 296, 236, 65, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
$Status2 = GUICtrlCreateLabel("Working", 224, 168, 36, 17)
GUICtrlSetBkColor(-1, 0x00FF00)
;---------------------------------------------------------------------------------
; // The Label section Ends Here \\ Ends Here 
;********************************************************************  
    Sleep(20)
   

Endif
WEnd
EndFunc

Func start()
HotKeySet("{ESC}", "_Terminate")

$x1 = GUICtrlRead($list1)


                
            If $x1 = "" Then
                MsgBox("" ,"" ,"Please Select an Item to start The Timer ")
           
            ElseIf ProcessExists ($x1) Then     
                  Msgbox ("" , "", "The Program is Running ... " & $x1 )
            Else 
                
                 MsgBox("" , "" , "This Program is not Running" )            
             Endif 
  


#cs
If $x1 = "" Then 

MsgBox("", "Please Select A Item" , "You Must Select a Program to Start The AutoSaver ! ")

ElseIf   WinExists("[CLASS:Notepad]") Then 
   
        Call("Timer")


Else  
    
    MsgBox("" ,"" , "[CLASS:" & $x1 & "]" )
    ;MsgBox("" ,"Error" ," This App is Not Running") 




Endif 
 #Ce

EndFunc

Func pause()

$App = GUICtrlRead($List1)


MsgBox("" , "The LIst Test" , $App)

EndFunc

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 , $hLine)
FileWrite($file ,  $Add & @CRLF)
FileClose($file)

GUICtrlSetData(-1, $Add & "|")




EndFunc
Func Delete()

$sName = GUICtrlRead($List1)   
_GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCaretIndex($List1))     

EndFunc



Func AutoSave()

$x1 = GUICtrlRead($list1)

If $x1 = 0 Then 

MsgBox("", "Please Select A Item" , "You Must Select a Program to Start The AutoSaver ! ")

Else

Call("Checker")


Endif 

EndFunc


Func Checker()
$x1 = GuiCtrlRead($list1)
if ProcessExists($x1) Then 
    WinWait("[CLASS:" & $x1 & "]", "", 0)
    Send("^s")
Else
    MsgBox("" ,"Error" ," This App is Not Running ")
EndIf


EndFunc
While 1
    Sleep(100)
WEnd

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

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

Here is The Three Codes I want to Combine Them !

-------------------- Function Of The Timer -----------------------------

Func Timer()

$Minutes = 1 ;will wait the time in The InputBox minutes
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)
 
If $Minutes = $60Count Then 

   Call("Autosave")
 
;*********************************************************************
; // This The Label Section \\ Start Here
;---------------------------------------------------------------------------------
$Label6 = GUICtrlCreateLabel($Minutes, 296, 192, 33, 17)
GUICtrlSetBkColor(-1, 0x00FF00)
$Label7 = GUICtrlCreateLabel($60Count, 296, 212, 89, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
$Label8 = GUICtrlCreateLabel($Count, 296, 236, 65, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
$Status2 = GUICtrlCreateLabel("Working", 224, 168, 36, 17)
GUICtrlSetBkColor(-1, 0x00FF00)
;---------------------------------------------------------------------------------
; // The Label section Ends Here \\ Ends Here 
;********************************************************************  
    Sleep(20)
   

Endif
WEnd
EndFunc
Func AutoSave()

$x1 = GUICtrlRead($list1)

If $x1 = 0 Then 

MsgBox("", "Please Select A Item" , "You Must Select a Program to Start The AutoSaver ! ")

Else

Call("Checker")


Endif 

EndFunc


Func Checker()
$x1 = GuiCtrlRead($list1)
if ProcessExists($x1) Then 
    WinWait("[CLASS:" & $x1 & "]", "", 0)
    Send("^s")
Else
    MsgBox("" ,"Error" ," This App is Not Running ")
EndIf


EndFunc

Share this post


Link to post
Share on other sites



Iam Trying to make an Autosaver ....

Its Autosaves Every 5 min my work on (NotePad ,  NotePad++ , Dreamweaver )

As someTimes The Program may Crash or The Electricty Blocks Out So it Autosaves For me My Work :D

I Tried A timer and When The timer Finishes It Sends "Ctrl + s " To The When Its Active so it Doesnt Distrub The USer if He is doing someThing Else ! :D

Share this post


Link to post
Share on other sites

Anyone Help Please :D

Share this post


Link to post
Share on other sites

Better to get into the habit of saving your work regularly. I do it instinctively after almost every edit.

Auto-saving is usually just a PITA!

;o) Cor


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

The Problem is I dont Remember to Save As I translate or something and Alot of People DO that so ...  I wanted to Make My own Tool For AutoSaving ? Can u help Please ?

Share this post


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
Sign in to follow this  
Followers 0