+ Reply to Thread
Results 1 to 2 of 2

API question - Reflection for regis graphics

Hybrid View

  1. #1
    Registered User
    Join Date
    04-19-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    87

    API question - Reflection for regis graphics

    hi

    im trying to use the windows API to enter a password into a reflection window that pops up.
    My problem is that i can step through the code using F8, and see the password being
    entered and the ok button pressed.

    However, when i run the code, it stops at the point where the password prompt window pops up
    and the cursor is just blinking waiting for input.

    What do i need to do to make this work please? i have tried adding the do loop to wait for the pop up
    and also tried application.ontime but both dont work.

    thanks


    The API function declarations are as follows:

    Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    Declare Function SetForegroundWindow Lib "user32" ( _
    ByVal hWnd As Long) As Long
    
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Declare Function SetActiveWindow Lib "user32.dll" (ByVal hWnd As Long) As Long
    
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long
    and the function to enter the password is:

    Function EnterPassword()
    
    Dim hDialog As Long, hTextbox As Long, hButton As Long, hOK As Long
    
    Dim hWnd As Long
    
    Const WM_SETTEXT = &HC
    Const BM_CLICK = &HF5
    
        hWnd = FindWindow(vbNullString, "Reflection Secure Shell Client")
    
        AppActivate "Reflection Secure Shell Client"
        hTextbox = FindWindowEx(hWnd, 0, "Edit", "")
        SendMessage hTextbox, WM_SETTEXT, ByVal 0, ByVal PASSWORD
    
        hOK = FindWindowEx(hWnd, 0, "Button", "OK")
    
        SetActiveWindow hWnd
        
    SendMessage hOK, BM_CLICK, ByVal CLng(0), ByVal CLng(0)
    
    End Function
    The VBA code in excel is


    Sub ChangeType()
    
        Dim RTCIS_Session As New Reflection4.Session, I As Long
        Dim B As String, Item As String
    '    
        B = "0171B"
    '    Item = "81431583"
            
        On Error GoTo ErrorHandler
    
        SetUpKeys
            
        With RTCIS_Session 
        
            .Visible = True
            .ProcessDataComm = False
            .ConnectionType = CONNECT_TYPE
            .ConnectionSettings = "HOST " & CONNECT_HOST
            .ConnectionSettings = "USERNAME " & CONNECT_USERNAME
            .Connect
            
    'Loop does not solve it!'
                Do Until FindWindow(vbNullString, "Reflection Secure Shell Client") > 0
                    .Wait 2 'wait 2 seconds'
                Loop
    
                EnterPassword
    
    'Does not solve it either!'
    Application.OnTime Now + TimeValue("00:00:03"), "EnterPassword"
    
    
            TransmitWait RTCIS_Session, CR
                    TransmitWait RTCIS_Session, Bslot & CR
                    
            OriginalType = .GetText(10, 89, 10, 94)
     
            For I = 1 To 16
                TransmitWait RTCIS_Session, CR
            Next I
    
    
    
    
            'other code here'
            
    
    
    
    
            .quit
    
        End With
    
        Exit sub
    
        ErrorHandler:
        Session.MsgBox "Error " & Err.Number & " : " & Err.Description, vbExclamation + vbOKOnly
        Resume Next
    End Sub
    For reference, the setupkeys sub is

    Sub SetUpKeys()
    
        CR = Chr(rcCR)
        LF = Chr(rcLF)
        SI = Chr(rcSI)
        
    End Sub

  2. #2
    Registered User
    Join Date
    04-19-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: API question - Reflection for regis graphics

    any ideas please?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with VBA/Reflection loop
    By JHadley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2013, 09:46 AM
  2. Excel to active wrq reflection for regis graphics session
    By gary-kc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2012, 09:26 AM
  3. [SOLVED] I want to add automaticaly my postponed check in my banking regis.
    By Alain Kieffer in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-12-2005, 04:05 PM
  4. Graphics question on Excel VBA UserForm
    By Jens Meier in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-23-2005, 07:05 PM
  5. [SOLVED] API graphics question
    By Mike510 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2005, 09:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1