?
Solved

activeate another window

Posted on 2004-07-30
3
Medium Priority
?
178 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
[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 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 2000 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

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!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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 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…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

762 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