Solved

sendkeys for windows key + m ???

Posted on 2003-11-21
6
1,477 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
[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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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…
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 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…

717 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