[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Script to auto tab between 2 differnet screen ever 2 mins

Posted on 2008-11-14
6
Medium Priority
?
382 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:transpennine
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 1000 total points
ID: 22964644
Hi, transpennine.

Here's how to do this.
'FORM CODE'
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
        Else
            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
 
'MODULE CODE'
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

0
 

Author Comment

by:transpennine
ID: 22974499
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
0
 
LVL 76

Expert Comment

by:David Lee
ID: 22981636
You're welcome.  Glad I could help.  Please don't forget to close the question if you're happy with the answer.
0
 

Author Comment

by:transpennine
ID: 24814984
thanks for all your help sorry for the delay
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24815308
No problem on the delay.  Please don't forget to close the question if you're satisfied with the solution.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question