Jump to content

run program in assign time


Recommended Posts

I suggest reading the help file

Check out the following topics:

@HOUR

@SEC

@MIN

I red this :

#include <Date.au3>

Global $Sec, $Min, $Hour, $Time

; 计算当前时间

$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)

; 计算 45 分钟后的时间

$EndTicks = $StartTicks + 45 * 60 * 1000

_TicksToTime($EndTicks,$Hour,$Min,$Sec)

MsgBox(262144,'' , 'New Time:' & $Hour & ":" & $Min & ":" & $Sec)

above . I thik "$Sec, $Min, $Hour, $Time" is not for me question

Link to comment
Share on other sites

I think the more appropriate way would be to use the IE udf:

#include <IE.au3>
$ieObj = _IECreate("www.google.com", 0, 1, 0)

_IELoadWait($ieObj, 0, 3000)

If @error Then
    MsgBox(0, "Error", "The page was not loaded in 3 seconds, exiting")
    Exit
EndIf
:)

thank you very much!

but you answer is only for IE.

how about for program?

(like this ? Run("Notepad.exe", "", @SW_MAXIMIZE,3000) ??? hehe I not find this in help file....)

Link to comment
Share on other sites

Well I guess it depends on what you want to call "Loaded" in that case, you could just check if the window is visible:

Opt("WinTitleMatchMode", 4)

Run("notepad")

$LoadTime = _LoadWaitApp("[CLASS:Notepad]", "", 3000)
If @error Then
    MsgBox(0, "Error", "The program was not loaded in 3 seconds, exiting")
    Exit
EndIf

MsgBox(0, "Program loaded", "Program was loaded in " & Round($LoadTime/1000, 2) & " seconds")

Func _LoadWaitApp($s_wTitle, $s_wText = "", $i_TimeOut = 15000)
    
    Local $i_tHandle = TimerInit(), $i_tDiff = 0
    
    Do
        Sleep(250)
        $i_tDiff = TimerDiff($i_tHandle)
    Until BitAND(WinGetState($s_wTitle, $s_wText), 2) Or $i_tDiff > $i_TimeOut ; Wait untill the window is visible, or the timer runs out
    
    If TimerDiff($i_tHandle) > $i_TimeOut Then
        SetError(1)
        Return 0 ; Timeout was hit
    Else
        SetError(0)
        Return $i_tDiff ; Returns the time it took for the app to launch
    EndIf   
    
EndFunc
Edited by FreeFry
Link to comment
Share on other sites

YES!

Grate!,thank you very much!

I will learn you post script :)

thanks

Well I guess it depends on what you want to call "Loaded" in that case, you could just check if the window is visible:

Opt("WinTitleMatchMode", 4)

Run("notepad")

$LoadTime = _LoadWaitApp("[CLASS:Notepad]", "", 3000)
If @error Then
    MsgBox(0, "Error", "The program was not loaded in 3 seconds, exiting")
    Exit
EndIf

MsgBox(0, "Program loaded", "Program was loaded in " & Round($LoadTime/1000, 2) & " seconds")

Func _LoadWaitApp($s_wTitle, $s_wText = "", $i_TimeOut = 15000)
    
    Local $i_tHandle = TimerInit(), $i_tDiff = 0
    
    Do
        Sleep(250)
        $i_tDiff = TimerDiff($i_tHandle)
    Until BitAND(WinGetState($s_wTitle, $s_wText), 2) Or $i_tDiff > $i_TimeOut ; Wait untill the window is visible, or the timer runs out
    
    If TimerDiff($i_tHandle) > $i_TimeOut Then
        SetError(1)
        Return 0 ; Timeout was hit
    Else
        SetError(0)
        Return $i_tDiff ; Returns the time it took for the app to launch
    EndIf   
    
EndFunc
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...