Results 1 to 4 of 4

Thread: wait function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    Oslo, Norway
    Posts
    22
    Does it excist a nice little wait function that makes the program wait for a desired amount of time?

    like:

    SendKeys "{TAB}"
    wait(20000) 'or something like that
    SendKeys "{TAB}"

    Or do I have to use the timer.

    Lars

    Lars Jarle Mæhlum
    http://www.touch-it.no

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    You can use the :
    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    'usage
    SendKeys "{TAB}" 
    Sleep 2000 '2 seconds
    SendKeys "{TAB}"
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    There's an api called sleep, which waits the amount of time, also freezing your app from handling all events. If you don't want that you could make a loop with a doevents that exits when a certain amount of time has passed, using either timer function or gettickcount api.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Yes, Kedaman is right Sleep will cause your entire application stop processing any message, So normally I'll do it with the GetTickCount API function call...

    Code:
    Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private t1 As Long
    Private t2 As Long
    
    Private Sub Command1_Click()
    'usage
    SendKeys "{TAB}"
    'Delay 2 seconds
    t1 = GetTickCount
    t2 = 0
    Do While t2 - t1 < 2000
        t2 = GetTickCount
        DoEvents
    Loop
    SendKeys "{TAB}"
    End Sub

    [Edited by Chris on 11-27-2000 at 06:32 AM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width