[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Switch focus to minimized app

Posted on 1997-09-30
4
Medium Priority
?
582 Views
Last Modified: 2008-03-17
I wish to switch focus to - and "restore" - a minimized application using a selection from the bar menu of the calling appplication. The "tried and true" methods suggested by MSKB and others: AppActivate "foobar" : sendkeys "% R"
when called by a control on the form work great. The problem is, when called from the bar menu, the popup window for "foobar" is displayed with "restore" higlighted and then everything locks up for from 1 to 30 seconds. When things unlock and "foobar" restores, the MousePointer may or may not be "busy".

Calling App:
        FileMenu_click
        AppActivate "foobar"
        sendkeys "% R"
        end sub

Foobar: Form1_click
        end
        end sub

I have also tried moving all the logic to "foobar" by having the calling app always shell a new app, and having "foobar" check for a previous instance. This produces the same results.
0
Comment
Question by:jwkeller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 4

Expert Comment

by:Chizl
ID: 1436191
I would look into API call SetForegroundWindow instead of AppActivate..   What exacly is "Alt+space+R" supposed to do? Not restore I hope..  sendkeys does nothing, but stuff the keyboard..  When I say stuff the keyboard that means if you hold the Alt+spacebar+R it should do exacly the same thing..  As you can see that doesn't work..

L8r,
Chizl
www.karland.com
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1436192
I would look into API call SetForegroundWindow instead of AppActivate..   What exacly is "Alt+space+R" supposed to do? Not restore I hope..  sendkeys does nothing, but stuff the keyboard..  When I say stuff the keyboard that means if you hold the Alt+spacebar+R it should do exacly the same thing..  As you can see that doesn't work..

L8r,
Chizl
www.karland.com
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1436193
Alt+SPACE R maybe works in the US version, but in my localized version, the combination is Alt+SPACE Å, so it's not a very good way to do it. I would use
  ShowWindow hwnd, SW_RESTORE
where hwnd is a handle for the window in question.
0
 
LVL 4

Accepted Solution

by:
Chizl earned 400 total points
ID: 1436194
You will need to use findwindow to get a handle on the window your looking for..  Then use SetForegroundWindow to set focus on that window.   Then use what andha suggested of ShowWindow..

Declare Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Declare Function SetForegroundWindow Lib "user32" _
    Alias "SetForegroundWindow" _
   (ByVal hwnd As Long) As Long

Declare Function ShowWindow Lib "user32" _
    Alias "ShowWindow" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long

You should be on your way..   API calls are always better than the functions built within..  API calls know the operating system not like the fuction calls..

l8r,
Chizl
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

656 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