Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

activeate another window

Posted on 2004-07-30
3
Medium Priority
?
180 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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