Results 1 to 5 of 5

Thread: SendKeys "{alt+Tab}" doesnt work :P

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    330

    SendKeys "{alt+Tab}" doesnt work :P

    Is there a way to use SendKeys for alt + tab , to switch windows..?

  2. #2
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    Re: SendKeys "{alt+Tab}" doesnt work :P

    Quote Originally Posted by ne0_b0mb3r
    Is there a way to use SendKeys for alt + tab , to switch windows..?

    Yes,

    Code:
    Private Sub Command1_Click()
        Dim wsh, MyKey
        Set wsh = CreateObject("Wscript.Shell")
        MyKey = "%{TAB}"
        wsh.SendKeys MyKey
    End Sub
    Last edited by Dungeon Keeper; Mar 23rd, 2008 at 10:17 AM.

  3. #3
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: SendKeys "{alt+Tab}" doesnt work :P

    Shouldn't there be a,
    Code:
    Set wsh = Nothing
    before you exit the sub?

  4. #4
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    Re: SendKeys "{alt+Tab}" doesnt work :P

    Yes!

  5. #5
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: SendKeys "{alt+Tab}" doesnt work :P

    Quote Originally Posted by ne0_b0mb3r
    Is there a way to use SendKeys for alt + tab , to switch windows..?
    This is one way. Open Visual Studio to see the demo run.

    Code:
    Option Explicit
    Dim i%
    
    Private Sub Command1_Click()
       i% = 0
       Timer1.Enabled = Not Timer1.Enabled = True
    End Sub
    
    Private Sub Form_Load()
       Timer1.Enabled = False
       Timer1.Interval = 2000
       AppActivate "MSDN Library Visual Studio 6.0", 1
    End Sub
    
    Private Sub Timer1_Timer()
       i% = i% + 1
          Me.Caption = "Alt + Tab " & i% & " Times"
          If i% >= 8 Then Timer1.Enabled = False
       SendKeys "%{TAB}"
    End Sub
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

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