[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

sendkeys for windows key + m ???

Posted on 2003-11-21
6
Medium Priority
?
1,583 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 280 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
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!

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 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