Solved

sendkeys for windows key + m ???

Posted on 2003-11-21
6
1,391 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
ID: 9799058
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
ID: 9799386
hearing...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9799415
After call vinnyd's code,

application.WindowState=xlNormal
0
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.

 
LVL 1

Author Comment

by:mgroyal
ID: 9808918
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
ID: 9809020
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
ID: 9809878
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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

930 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

12 Experts available now in Live!

Get 1:1 Help Now