Script to auto tab between 2 differnet screen ever 2 mins

Hello I have a single monitor that needs to display 2 different screens at 2 min intervals
screen 1 needs to be maximised and displaying the internet explorer screen for 2 min then minimise or close then screen 2 needs to be maximised and displaying some real time data from a program for 2 mins then minimise or close for 2 mins , this action needs to continually loop ,
Maybe even alt+tab commands could be used to switch between each open screen ever 2 mins

Any help would be appreciated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, transpennine.

Here's how to do this.
Private lngWnd1 As Long, lngWnd2 As Long, bolWnd1 As Boolean, bolWnd2 As Boolean, intPass As Integer
Private Sub Command1_Click()
    'Change the window title on the following line to one of the two windows'
    lngWnd1 = FindWindow(vbNullString, "Untitled - Notepad")
    bolWnd1 = True
    'Change the window title on the following line to the other of the two windows'
    lngWnd2 = FindWindow(vbNullString, "Google - Windows Internet Explorer")
    bolWnd2 = False
    Timer1.Interval = 60000
    Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
    Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
    intPass = intPass + 1
    If intPass = 2 Then
        If bolWnd1 Then
            SendMessage lngWnd1, WM_SYSCOMMAND, SC_MAXIMIZE, NIL
            BringWindowToTop lngWnd1
            SendMessage lngWnd2, WM_SYSCOMMAND, SC_MINIMIZE, NIL
            SendMessage lngWnd2, WM_SYSCOMMAND, SC_MAXIMIZE, NIL
            BringWindowToTop lngWnd2
            SendMessage lngWnd1, WM_SYSCOMMAND, SC_MINIMIZE, NIL
        End If
        bolWnd1 = Not bolWnd1
        bolWnd2 = Not bolWnd2
        intPass = 0
    End If
End Sub
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Public Const SC_MAXIMIZE = &HF030&
Public Const SC_MINIMIZE = &HF020&
Public Const WM_SYSCOMMAND = &H112
Public Const NILL = 0&

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
transpennineAuthor Commented:
Thanks Bluedevilfan this code has been most useful and I have managed using it to do what was required thanks for the time taken to help

Regards Transpennine
David LeeCommented:
You're welcome.  Glad I could help.  Please don't forget to close the question if you're happy with the answer.
transpennineAuthor Commented:
thanks for all your help sorry for the delay
David LeeCommented:
No problem on the delay.  Please don't forget to close the question if you're satisfied with the solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.