Solved

activeate another window

Posted on 2004-07-30
3
172 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
ID: 11684131
'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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

773 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