Solved

sendkeys for windows key + m ???

Posted on 2003-11-21
6
1,407 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

776 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