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 :)

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.

thanks :) And how to make loop?

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

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

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 :)

sipmly, I want to repeat

Call SendKeys("TAB", True)
Call SendKeys("{ENTER}", True)
Wait 20
Call SendKeys("{F5}", True)
Wait 660
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

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

or don't use a button, use a timer control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.