Solved

activeate another window

Posted on 2004-07-30
3
170 Views
Last Modified: 2012-05-05
hi,

i am using sendkyes function along with APIs like sendmessage in my application to send and set some items on a separate process window (APP1.exe for example) that is active already when my apps starts

what i want to do is to activate App1.exe so it gets the foucs if i use sendkeys

i tried wm_setfocus or wm_activate from sendmessage , but i understand it is only one way notification

any help is greatly appreciated

thx
0
Comment
Question by:vbnetway
3 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 500 total points
Comment Utility
'If App1.exe is minimized then use:

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Sub Command1_Click()
    Dim appHwnd As Long, myString As String
    appHwnd = FindWindow(myString, "app1TITLE")
    ShowWindow appHwnd, 3
    SetForegroundWindow appHwnd
End Sub

'Note: For this code to work you need the exact TITLE of the App1.exe. In addition, [ShowWindow appHwnd, 3] will maximize App1.exe. If you want it in normal window then change 3 to 1.

'Another option is

Private Sub Command1_Click()
    AppActivate "App1TITLE"
End Sub

'Note that again, the TITLE is needed here. In addition, AppActivate will work only if App1.exe is not minimized. Just behinde another application.

S
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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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