Jump to content
Sign in to follow this  
Blue_Drache

Logic Test

Recommended Posts

Blue_Drache

Here's what I want it to do:

  • If this file exists and is running, check the file date. If it's greater than the value I set, close the running window and re-install the file, and then start it running.
  • If the file exists, and is not running, re-install if it's older than a date I set, otherwise just run the file.
  • If the file doesn't exist, then install the file and start it running.
This is the code I came up with:

If FileExists(@ScriptDir & "\ClaimTally.exe") = 1 Then
   $atime = FileGetTime(@ScriptDir & "\ClaimTally.exe", 1, 0)
   $ftime = $atime[0] & "/" & $atime[1] & "/" & $atime[2]
   $tallycreate = "2005" & "/" & "03" & "/" & "28"
   $fdiff = _DateDiff("d", $ftime, $tallycreate)
EndIf

If FileExists(@ScriptDir & "\ClaimTally.exe") = 1 And WinExists("Claim Tally", "Add Cbis") = 1 Then
   If $fdiff > 0 Then
      WinClose("Claim Tally", "Add Cbis")
      Do
         Sleep(10)
         If WinWaitClose("Claim Tally", "Add Cbis", 10) = 0 Then
            MsgBox("Error", "Please close the Claim Tally window", 5)
         Else
            ExitLoop
         EndIf
      Until WinExists("Claim Tally", "Add Cbis") = 0
      FileInstall("C:\Documents and Settings\U256655\Desktop\AutoIt\User Scripts\Compiled Scripts\ClaimTally.exe", @ScriptDir & "\", 1)
      Sleep(125)
   EndIf
   Run(@ScriptDir & "\ClaimTally.exe", "", @SW_MINIMIZE)
   While 1
      Sleep(10)
      If WinExists("Claim Tally", "Add Cbis") = 1 Then ExitLoop
   WEnd
   WinSetState("Claim Tally", "Add Cbis", @SW_MINIMIZE)
ElseIf FileExists(@ScriptDir & "\ClaimTally.exe") = 1 And WinExists("Claim Tally", "Add Cbis") = 0 Then
   If $fdiff > 0 Then
      FileInstall("C:\Documents and Settings\U256655\Desktop\AutoIt\User Scripts\Compiled Scripts\ClaimTally.exe", @ScriptDir & "\", 1)
      Sleep(125)
   EndIf
   Run(@ScriptDir & "\ClaimTally.exe", "", @SW_MINIMIZE)
   While 1
      Sleep(10)
      If WinExists("Claim Tally", "Add Cbis") = 1 Then ExitLoop
   WEnd
   WinSetState("Claim Tally", "Add Cbis", @SW_MINIMIZE)
ElseIf FileExists(@ScriptDir & "\ClaimTally.exe") = 0 Then
   FileInstall("C:\Documents and Settings\U256655\Desktop\AutoIt\User Scripts\Compiled Scripts\ClaimTally.exe", @ScriptDir & "\", 0)
   While 1
      If FileExists(@ScriptDir & "\ClaimTally.exe") = 1 Then ExitLoop
      Sleep(10)
   WEnd
   Run(@ScriptDir & "\ClaimTally.exe", "", @SW_MINIMIZE)
   While 1
      Sleep(10)
      If WinExists("Claim Tally", "Add Cbis") = 1 Then ExitLoop
   WEnd
   WinSetState("Claim Tally", "Add Cbis", @SW_MINIMIZE)
EndIf

Any other suggestions to maybe optimize it?

WinSetState("Claim Tally", "Add Cbis", @SW_MINIMIZE) this is there to minimize the window as it's not obeying the Run("","",@SW_MINIMIZE) command.

Edit: Came up with putting the date check outside of the If test so I don't have as many places to change the set date in the code....posted modified code.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
Ejoc

While 1
      Sleep(10)
      If WinExists("Claim Tally", "Add Cbis") = 1 Then ExitLoop
   WEnd

Same as

WinWait("Claim Tally","Add Cbis")

Shouldn't need the while loop:

FileInstall("C:\Documents and Settings\U256655\Desktop\AutoIt\User Scripts\Compiled Scripts\ClaimTally.exe", @ScriptDir & "\", 0)
   While 1
      If FileExists(@ScriptDir & "\ClaimTally.exe") = 1 Then ExitLoop
      Sleep(10)
   WEnd

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

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  

×