0

Hey, I need to write program, which will do some action after 11 minutes.
I have that action done, but I dont know how to write to wait 11 minutes, and how to write to wait 20 secs after 1 action.

Private Sub Command1_Click()
Dim hWnd As Long

  hWnd = FindWindowByCaption("welcome to mia's website  - Mozilla Firefox")
    If hWnd = 0 Then
      MsgBox "Window not found", vbCritical, "Fehler"
    Else
      
      Call BringWindowToTop(hWnd):
      Call SendKeys("TAB", True)
      Call SendKeys("{ENTER}", True)
      Call SendKeys("{F5}", True)
    
    End If
End Sub

It need to wait 20 secs after Call SendKeys("{ENTER}", True) and it need to wait 11 minutes after F5 then it need to do the same action (TAB > 20 secs, ENTER). Thanks :)

3
Contributors
9
Replies
10
Views
10 Years
Discussion Span
Last Post by Comatose
0
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
 
 
Public Sub Wait(Seconds As Single)
 Dim lMilliSeconds As Long
 lMilliSeconds = Seconds * 1000
 Sleep lMilliSeconds
End Sub

wait 660
this will wait for 11 minutes.

0

how to make loop? It need to do that action all the time

0
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub Command1_Click()
Dim hWnd As Long

  hWnd = FindWindowByCaption("welcome to mia's website  - Mozilla Firefox")
    If hWnd = 0 Then
      MsgBox "Window not found", vbCritical, "Fehler"
    Else
      
      Call BringWindowToTop(hWnd):
      Call SendKeys("TAB", True)
      Call SendKeys("{ENTER}", True)
      Wait 20
      Call SendKeys("{F5}", True)
      Wait 660

    End If
End Sub





Public Sub Wait(Seconds As Single)
     Dim lMilliSeconds As Long
     lMilliSeconds = Seconds * 1000
     Sleep lMilliSeconds
End Sub

Not sure what you mean about looping?
Do you want to repeat

Call SendKeys("TAB", True)
      Call SendKeys("{ENTER}", True)
      Wait 20
      Call SendKeys("{F5}", True)
      Wait 660

A set number of times?
If so you could wrap it in a for..Next loop


pG

0

I want to make something, what can repeat that program action all the time. I dont want want to copy and paste that code 1000 times :)

0

sipmly, I want to repeat

Call SendKeys("TAB", True)
Call SendKeys("{ENTER}", True)
Wait 20
Call SendKeys("{F5}", True)
Wait 660
0
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub Command1_Click()
Dim hWnd As Long
Dim iCounter as Integer

  hWnd = FindWindowByCaption("welcome to mia's website  - Mozilla Firefox")
    If hWnd = 0 Then
      MsgBox "Window not found", vbCritical, "Fehler"
    Else
      
      For iCounter = 1 to 1000
          Call BringWindowToTop(hWnd):
          Call SendKeys("TAB", True)
          Call SendKeys("{ENTER}", True)
          Wait 20
          Call SendKeys("{F5}", True)
          Wait 660
    Next iCounter

    End If
End Sub

This will repeat 1000 times.

pG

0

Thanks alot :) You are very helpful :) There should be more ppl like you on our planet ;]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.