I am running MS multi session and using a dialog to write in another MS window (building scripts). My problem is in trying to set the focus to the other window.
I have an edit box for the user to type in the name of the other window (or if I use SetDialogProp to set it) but the script fails.
It fails even if I don't use that value but have SetFocus hard coded! Just having the window name in the dialog makes it fail. (I know this sounds crazy)
To repro:
1. Open this dialog
2. In a 2nd session create a new script titled 'TEST SCRIPT' (all uppercase)
3. In dialog, enter random text and then press 'Write to script'
- it works
4. Click Text1 or type 'Macro - TEST SCRIPT' and press 'Write to script'
- Script fails!
- 'Wrong window' Window = 'Script Builder'' or 'Press Esc to quit'
Code: Select all
Dialog>ScriptBuilder
object ScriptBuilder: TForm
Left = 528
Top = 255
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'ScriptBuilder'
ClientHeight = 205
ClientWidth = 414
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object btnWrite: tMSButton
Left = 128
Top = 124
Width = 89
Height = 25
Caption = 'Write to Script'
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object ebWindow: TEdit
Left = 128
Top = 41
Width = 121
Height = 21
TabOrder = 1
TextHint = 'Script Window...'
end
object btnText1: tMSButton
Left = 92
Top = 84
Width = 75
Height = 25
Caption = 'Text1'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 10
DoBrowse = False
BrowseStyle = fbOpen
end
object btnText2: tMSButton
Left = 181
Top = 84
Width = 75
Height = 25
Caption = 'Text2'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 11
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>ScriptBuilder
SetDialogProperty>ScriptBuilder,ebWindow,Text,TEST
AddDialogHandler>ScriptBuilder,btnWrite,OnClick,WriteScript
AddDialogHandler>ScriptBuilder,btnText1,OnClick,Text1
AddDialogHandler>ScriptBuilder,btnText2,OnClick,Text2
Show>ScriptBuilder,r
SRT>WriteScript
Let>strWindow=Macro - TEST SCRIPT
SetFocus>strWindow
GetActiveWindow>WinTitle,,,,
If>WinTitle=strWindow
Let>SK_DELAY=10
SendText>CmdStr
Else
Mdl>Wrong window: %WinTitle%
Endif
SetDialogProperty>ScriptBuilder,,Visible,True
END>WriteScript
SRT>Text1
SetDialogProperty>ScriptBuilder,ebWindow,Text,Macro - TEST SCRIPT
END>Text1
SRT>Text2
SetDialogProperty>ScriptBuilder,ebWindow,Text,Macro - SOME OTHER TEXT
END>Text2