Solved

sendkeys for windows key + m ???

Posted on 2003-11-21
6
1,369 Views
Last Modified: 2008-02-01
Hi

Actualy I couldn't find something like 'sendkeys winkey+m'  on the net. May be there's another way using ASCII-Codes or so... Anyway the object is to minimize all application windows. Please note that I'm programming in excel and that I want to minimize all application windows not the workbooks-windows...

*mg
0
Comment
Question by:mgroyal
  • 3
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 70 total points
Comment Utility
You could use the keybd event API,but it will minimize all apps:

' declarations
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B


'  usage
    Call keybd_event(VK_LWIN, 0, 0, 0)
    Call keybd_event(77, 0, 0, 0) ' 77 = M
    Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
    Call keybd_event(77, 0, KEYEVENTF_KEYUP, 0)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
hearing...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
After call vinnyd's code,

application.WindowState=xlNormal
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:mgroyal
Comment Utility
Hi,

I tried the API-Code but it isn't working. I receive the follow error-message:

Compile error: Only comments may appear after End Sub, End Function, End Property..

What I need to do?
0
 
LVL 1

Author Comment

by:mgroyal
Comment Utility
the code is working... Thx Vinnyd

Unfortunately my idea with win+m isn't working. Actually I've a window from an other application for which I need to have the focus.
For example: I have window called PS/nVision. Is it possible to control this window over its name? (API)

I'll double the point if there is a solution for this.

Thx mg

0
 
LVL 16

Assisted Solution

by:Richie_Simonetti
Richie_Simonetti earned 70 total points
Comment Utility
Use findwindow api to locate the desired window and ShowWindow to give it the focus.

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

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


dim ret as long

ret=findwindow(vbnullstring,"Window caption goes here")
ShowWindow ret,vbnormalfocus


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
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…
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…

772 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