Sign in to follow this  
Followers 0
Solomon

Could I make this code "neater"?

12 posts in this topic

I have some code that I need to have run every 5 seconds, to check to see if a file and process exist, and exit if they dont.

If ProcessExists("Backup.exe") Then
FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz")
EndIf
If Not ProcessExists("Backup.exe") Then Exit
Sleep(5000)

Is it possible to use something other than a combination of Sleep(5000) and repeating the above code millions of times? I mean, its working, and working fine, so perhaps I should just live with it, but I was thinking that the code would look nicer if it did [something] until [something else].

Share this post


Link to post
Share on other sites



AdlibEnable('_CheckForProcess', 5000); will check process every 5 seconds or so

While 1
    Sleep(1000)
WEnd

Func _CheckForProcess()
    If ProcessExists("Backup.exe") Then
        FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz")
    Else
        Exit
    Exit
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

maybe

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    If $Paused Then AdlibEnable("myadlib", 5000)
    While $Paused
        Sleep(100)
        ToolTip('Script is "Running"', 0, 0)
    WEnd
    ToolTip("")
    AdlibDisable ( )
EndFunc  ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc  ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc  ;==>ShowMessage

Func myadlib()
    If ProcessExists("Backup.exe") Then
        FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz")
    EndIf
EndFunc  ;==>myadlib

********** not tested

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

While ProcessExists('Backup.exe')
    FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz")
    Sleep(5000)
WEnd

Share this post


Link to post
Share on other sites

While ProcessExists('Backup.exe')
    FileMove("G:\Backup\*.jaz", "C:\Backup HQ\*.jaz")
    Sleep(5000)
WEnd

sometimes.... "Less is Better"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

sometimes.... "Less is Better"

8)

I keep trying to tell my wife that :):mellow::)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Blimey, that was quick! :)

Thanks very much, guys!

Share this post


Link to post
Share on other sites

Blimey, that was quick! :)

Thanks very much, guys!

Yeah... some of these guys have nothing better to do other than sit around and help :) (or we have better things to do... but our priorities are screwed)... so you gotta check frequently :mellow:.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I keep trying to tell my wife that :o:mellow::)

While you are using it in a loop, your wife will be happy. :)

Share this post


Link to post
Share on other sites

While you are using it in a loop, your wife will be happy. :)

unless every iteration is executing on the girlfriend.... speaking of... what an awesome weekend.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

unless every iteration is executing on the girlfriend.... speaking of... what an awesome weekend.

Ha!!... I'll have to remember to ask about it... (The weekend that is) ... I don't have a girlfriend to tell her about... but I love hearing about hers!! :mellow::)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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