Results 1 to 2 of 2

Thread: [RESOLVED] Timer Problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Resolved [RESOLVED] Timer Problem

    Hey, I've just finished creating a program which searches for an instance of IE, and if it's found, to close IE, and open that same URL in firefox (Because I use windowsKey-e to open the browser usually =D )

    All's working great, but i've just now added a timer so that the loop which watches for IE doesn't hog all the CPU.

    Basically, the timer checks every two seconds for either an IE window or a directory browser window (My Computer, etc). If found, it then opens up the loop which waits for the directory browers window to visit a website, and then closes IE when that happens.

    If while in the loop the windows are no longer found, the loop exits and (should) go back to the timer, but it doesnt

    The code im using is:
    VB Code:
    1. Private Sub loopingIt()
    2. Dim foundUrl As String, counter As Integer
    3. counter = 0
    4.  
    5. While IEHndl <> 0
    6.     counter = counter + 1
    7.     If counter > 1000 Then
    8.         foundUrl = ""
    9.         foundUrl = findIEUrl
    10.         DoEvents
    11.         Debug.Print "LOOPING"
    12.         If Trim(foundUrl) <> "" And Left(Trim(foundUrl), 4) = "http" Then
    13.             PostMessage IEHndl, WM_CLOSE, 0, 0&
    14.             DoEvents
    15.             Shell "C:\Program Files\Mozilla Firefox\firefox.exe " + foundUrl, vbNormalFocus
    16.         End If
    17.         counter = 0
    18.     End If
    19. Wend
    20. tmrCheckWindow.Interval = 2000
    21. tmrCheckWindow.Enabled = True '<<<<<<<<<<<<<<<<<<<<< Here
    22. End Sub
    23.  
    24. Private Sub Form_Load()
    25. App.TaskVisible = False
    26. End Sub
    27.  
    28. Private Sub tmrCheckWindow_Timer()
    29. findIEUrl
    30. Debug.Print "JuST CHECKING"
    31. If IEHndl <> 0 Then
    32.     loopingIt
    33.     tmrCheckWindow.Enabled = False
    34. End If
    35. End Sub
    The timer never starts up again. I've breakpointed the .enabled = true line, and it's triggering, but the timer never restarts

    Any ideas?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Timer Problem

    Never mind, stupid mistake

    loopingIt
    tmrCheckWindow.Enabled = False

    Was turning the timer off as soon as it was turned back on =(

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