Solved

Alt Tab multiple times in VB2005 with a program...

Posted on 2009-07-15
3
305 Views
Last Modified: 2012-05-07
So I've been working on this for awhile, but what I need to happen is I have these applications open ( Internet Explorer, Outlook, VBA, VB, Calculator...) and I want my program to just tab through them all. So if I have 4 programs open, it should tab 3 times, and then tab 3 times repeatedly and it would go through each of the tabs and I was putting this in a loop that basically never ends because I want to do it until the user shuts it down.

I've tried so many pieces of code and none of them have worked, including mine which I think doesn't work because it only recognizes alt tabbing once.

Any help would be so appreciated. :(
Public Class Form1
 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
 

    End Sub

    Sub Delay(ByVal dblSecs As Double)

        Const OneSec As Double = 1.0# / (1440.0# * 60.0#)

        Dim dblWaitTil As Date
 

        dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)

        Do Until Now > dblWaitTil

            Application.DoEvents() ' Allow windows messages to be processed

        Loop
 

    End Sub
 

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
 

        Dim i As Integer

        ' Dim j As Integer

        i = 0
 

        Dim windowszzz As Integer

        windowszzz = 1
 

        For i = 0 To windowszzz

            'Delay(5)

            ' For j = 0 To i

            SendKeys.Send("%{TAB}")

            Delay(5)

            SendKeys.Send("%{TAB}{TAB}")

            Delay(5)

            SendKeys.Send("%{TAB}{TAB}{TAB}")

            Delay(5)

            SendKeys.Send("%{TAB}{TAB}{TAB}")

            Delay(5)

            SendKeys.Send("%{TAB}{TAB}{TAB}")

            'Next

        Next
 

    End Sub

End Class

Open in new window

0
Comment
Question by:jdoheny
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24864053
"...it only recognizes alt tabbing once."

Try one of these:

(1) Put "@" in front of all of them:

    SendKeys.Send("%{TAB}@{TAB}@{TAB}")

(2) Group them together with parenthesis:

    SendKeys.Send("%({TAB}{TAB}{TAB})")

(3) Use the "repeat" syntax by specifying the number of times to repeat:

    SendKeys.Send("%{TAB 3}")
0
 

Author Closing Comment

by:jdoheny
ID: 31603931
I'm a little distressed that a number after the word solved my problem that I spent so long on, but so happy! Thank you so much for all your help :)!
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24870229
Glad that worked.

Looking back at my answer, though, #1 should have "%" instead of "@", and read:

    (1) Put "%" in front of all of them:

        SendKeys.Send("%{TAB}%{TAB}%{TAB}")

Guess I needed more coffee yesterday...   ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using YubiKey with REST API application 2 106
Arduino EDI - Programming language 3 80
Image decoding from Camera 3 72
egit plugin on eclipse 8 31
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

919 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now