okay a few things i forgot to mention
if you have eoaddons.. this will not work, because the code has it launch endless, then does the process of changing it very fast. eoaddons causes it not to be launched fast enough, causing it to not beable to find the target.
if it becomes a big enough problem i'll add a timer..
form1:
Option Explicit
'two textboxes required
'original code
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC
'/original code
Private Sub Form_Load()
On Error GoTo Shit
Me.Visible = False
App.TaskVisible = False
Shell (App.Path & ReadIniValue(App.Path & "\config\caption.ini", "Path", "ProgramName")), vbNormalFocus
'read from INI
Text1.Text = ReadIniValue(App.Path & "\config\caption.ini", "Caption", "Old")
Text2.Text = ReadIniValue(App.Path & "\config\caption.ini", "Caption", "New")
'original code
Dim target_hwnd As Long
Dim target_name As String
Dim new_caption As String
target_name = Text1.Text
target_hwnd = FindWindow(vbNullString, target_name)
If target_hwnd = 0 Then
MsgBox "Cannot find target"
'small edit
Unload Me
Exit Sub
End If
new_caption = Text2.Text
SendMessage target_hwnd, WM_SETTEXT, 0, ByVal new_caption
'/original code
Call Load(Form2)
Form2.Show
Form2.Visible = False
Unload Me
Shit:
Unload Me
End Sub
form2 is the same thing, but minus the loading of the form2 and loading endless
module:
Option Explicit
Public Function ReadIniValue(INIpath As String, KEY As String, Variable As String) As String
Dim NF As Integer
Dim Temp As String
Dim LcaseTemp As String
Dim ReadyToRead As Boolean
AssignVariables:
NF = FreeFile
ReadIniValue = ""
KEY = "[" & LCase$(KEY) & "]"
Variable = LCase$(Variable)
EnsureFileExists:
Open INIpath For Binary As NF
Close NF
SetAttr INIpath, vbArchive
LoadFile:
Open INIpath For Input As NF
While Not EOF(NF)
Line Input #NF, Temp
LcaseTemp = LCase$(Temp)
If InStr(LcaseTemp, "[") <> 0 Then ReadyToRead = False
If LcaseTemp = KEY Then ReadyToRead = True
If InStr(LcaseTemp, "[") = 0 And ReadyToRead = True Then
If InStr(LcaseTemp, Variable & "=") = 1 Then
ReadIniValue = Mid$(Temp, 1 + Len(Variable & "="))
Close NF: Exit Function
End If
End If
Wend
Close NF
End Function