Results 1 to 30 of 30

Thread: Browser Windows

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    20

    Browser Windows

    I am having difficulty in sending code to a specific browser window. The user will have several browser windows opened. One for example will be labeled as "HOME" and the other as "EARLY". I need to be able to identify the browser window names and than direct a URL address. I can write the URL address but not to the correct browser. Seems my code is writing to the last active window. A sample of my code is shown below:
    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    4.                 ByVal hwnd As Long, _
    5.                 ByVal lpOperation As String, _
    6.                 ByVal lpFile As String, _
    7.                 ByVal lpParameters As String, _
    8.                 ByVal lpDirectory As String, _
    9.                 ByVal nShowCmd As Long) As Long
    10.  
    11. Private Const SW_SHOWNORMAL As Long = 1
    12.  
    13. 'Magellan DDE application information
    14.  
    15. Private Const DDEApplication = "Magellan"
    16.  
    17. Private Const DDETopic1 = "LocalVariable"
    18.  
    19. Private Const DDEItem1 = "EARLY"
    20.  
    21. Private Sub Form_Load()
    22.  
    23.  Dim lActiveHwnd As Long, lMinimized As Long, lForeGround As Long, iCounter As Integer, lhwnd As Long
    24. Dim lpclass As String * 256, lnkTopic As String, TermCode As String, ConvertedCode As String
    25. Dim nlength As Integer, vk As Integer, scan As Integer, oemchar As String, dl As Long, nCheckBox As Integer
    26.      
    27. On Error GoTo errMe      
    28.        
    29.           lActiveHwnd = GetDesktopWindow        'first gets the desktop handle
    30.  
    31.  
    32.             lActiveHwnd = GetWindow(lActiveHwnd, GW_CHILD)        'look for the first child
    33.  
    34.             Do Until lActiveHwnd = 0
    35.  
    36.             '' now get the window text and match against the Const AppName. If a match is found then exit do. If not the do will exit.
    37.             lpclass = Space(256)
    38.             lhwnd = GetWindowText(lActiveHwnd, lpclass, 255)
    39.            
    40.                 If Trim(Left(lpclass, Len(SendKeyAppName))) = SendKeyAppName Then
    41.  
    42.                     Exit Do
    43.                 End If
    44.  
    45.                 lActiveHwnd = GetWindow(lActiveHwnd, GW_HWNDNEXT)
    46.             Loop
    47.  
    48.  
    49. '            'If a window is found
    50.        
    51.             If lActiveHwnd <> 0 Then
    52.        
    53.                 'Get the @ACCOUNT information from Magellan
    54.  
    55.                
    56.                 txtacct.LinkMode = vbLinkNone
    57.                 txtacct.LinkTopic = DDEApplication & "|" & DDETopic1
    58.                 txtacct.LinkItem = DDEItem1
    59.                 txtacct.LinkMode = vbLinkManual
    60.                 txtacct.LinkRequest
    61.  
    62.  
    63.                 Dim strURL As String
    64.                 strURL = "https://uat.earlyresolution.net/EarlyResolution/jsp/Main.jsp?SESS_NBR_MRTG=" & txtacct.Text & "&SESS_CURR_EVENT=0&SESS_CURR_SCR_ID=13456&SESS_CURR_SCR_ID_IMMUTABLE=13456"
    65.                 ShellExecute Me.hwnd, "Open", strURL, vbNullString, "C:\", SW_SHOWNORMAL
    66.                
    67.                 End
    68.    
    69.        
    70.  
    71.                         Else
    72.                             MsgBox "No window named that starts with" & SendKeyAppName
    73.                             End
    74.                         End If
    75.                        
    76.  
    77.        
    78. errMe:
    79.        
    80.             MsgBox "The Following error has occurred, Please advise system administrator" & Err.Description, vbInformation, "ACCTLKUP"
    81.             End
    82.          
    83.      
    84. End Sub
    Last edited by Hack; May 1st, 2007 at 11:32 AM. Reason: Added VB Highlight Tags

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