Results 1 to 3 of 3

Thread: Gaining focus of a window without the complete name

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    1

    Gaining focus of a window without the complete name

    I've been searching online and experimenting but can't get this to work.

    I'm using the Windows Scripting Host (just running .vbs files on the machine)

    What I need to do is gain focus on a particular window. For instance, "1293729 - Details - Windows Internet Explorer" where the number at the beginning changes. If the number was at the end then I know AppActivate can do it on it's own, but if I try to AppActivate " - Details - Windows Internet Explorer" then I get nothing.

    Is there a method I could use to focus on that window? As a side note, there will only be one window at any time that matches that format.

    I'm thinking maybe along the lines of looping through all window titles (if that's possible) until you find one that matches, and then pass it to AppActivate, but I'm new to the Windows API and I'm not sure where I should look.

    Thanks

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Gaining focus of a window without the complete name

    Clicking this led to the following sites:

    Activate Any Window With API

    Activate an App by a Partial Window Title



    BTW, if your post has more to do with the Windows API than VB Script, then you may want to ask a moderator to transfer your thread to the API forum.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Gaining focus of a window without the complete name

    Have you tried the AppActivate method of the WshShell object instead?

    Code:
    CreateObject("WScript.Shell").AppActivate " - Details - Windows Internet Explorer"
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width