Trancedified
Freshman
I read up on Regular Expressions, can it handle reading through an open application and find a Social Security Number
For example, an SSN would look like:
SSN: 5 5 5-5 5-5 5 5 5
I would like to grab all the underlined numbers and display them like this after I see SSN:
555-55-5555
Any ideas?
Here is the code to "Detect" and look through an open application:
Any ideas?
Chris
For example, an SSN would look like:
SSN: 5 5 5-5 5-5 5 5 5
I would like to grab all the underlined numbers and display them like this after I see SSN:
555-55-5555
Any ideas?
Here is the code to "Detect" and look through an open application:
Code:
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmSource
Inherits System.Windows.Forms.Form
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByRef lpClassName As String, ByVal lpWindowName As String) As Integer
Private Const WM_SETTEXT As Short = &HCs
Private Const WM_GETTEXT As Short = &HDs
Dim hwndTarget As Integer 'target handle
Private Sub btnSend_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnSend.Click
Dim s As String
s = CStr(txtMsg.Text)
SendMessage(hwndTarget, WM_SETTEXT, Len(s), s)
End Sub
Private Sub frmSource_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim hw As Integer
Dim cw As Integer
Dim s As String
Dim i As Integer
'first, we need to find the hwnd of the target text box
btnSend.Enabled = False
hw = FindWindow(0, "Target Form") 'find the hwnd of the target form
If hw Then
cw = FindWindowEx(hw, 0, 0, 0) 'for each child window...
Do While cw
s = Space(20)
i = SendMessage(cw, WM_GETTEXT, 15, s) 'see if the child window is the right one
If VB.Left(s, i) = "TargetBox" Then
hwndTarget = cw
btnSend.Enabled = True
Exit Do
Else
cw = FindWindowEx(hw, cw, 0, 0) 'look for the next child
End If
Loop
End If
End Sub
End Class
Any ideas?
Chris