• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

activeate another window

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
vbnetway
Asked:
vbnetway
1 Solution
 
ShauliCommented:
'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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now