加一句=SetForegroundWindow(hwnd),激活窗口至前端就好了
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
Height = 110
Width = 193
ShowWindow = 2
DoCreate = .T.
AutoCenter = .T.
Caption = "Form1"
AlwaysOnTop = .T.
Name = "Form1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 60, ;
Left = 68, ;
Height = 25, ;
Width = 60, ;
Caption = "执行", ;
Name = "Command1"
ADD OBJECT text1 AS textbox WITH ;
Alignment = 3, ;
Value = 1, ;
Height = 25, ;
InputMask = "999", ;
Left = 72, ;
Top = 24, ;
Width = 40, ;
Name = "Text1"
ADD OBJECT label1 AS label WITH ;
Caption = "选择第:", ;
Height = 16, ;
Left = 24, ;
Top = 29, ;
Width = 46, ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
Caption = "行", ;
Height = 16, ;
Left = 116, ;
Top = 29, ;
Width = 46, ;
Name = "Label2"
PROCEDURE init
PUBLIC lnSendHwnd,hwnd
ENDPROC
PROCEDURE command1.Click
#Define EM_SETSEL 0xb1
#Define EM_LINEINDEX 0xbb
#Define WM_SYSCOMMAND 0x112
#Define SC_MAXIMIZE 0xF030
TEXT TO prgprg noshow
2343432435
34454t4365t43
ddffergter
rwew阿德顺丰到付归属感
谁丰东股份23424递四方速递
23424535
水电费45235
3424
ENDTEXT
DECLARE Long FindWindowEx IN WIN32API Long, Long, String, String
Declare Integer SendMessage In WIN32API as SendMessages Integer,Integer,Integer,String
Declare Integer SendMessage In WIN32API as SendMessagen Integer,Integer,Integer,Integer
Declare Integer SendMessageW In WIN32API as SendMsgWn Integer,Integer,Integer,Integer
Declare Integer WinExec in kernel32 string, integer
Declare SetForegroundWindow in win32api long hwnd
hWnd = FindWindowEx( 0, 0, "Notepad", NULL )
if hwnd=0
winexec("NOTEPAD.EXE",5)
hWnd = FindWindowEx( 0, 0, "Notepad", NULL )
SendMessages(m.Hwnd,WM_SYSCOMMAND,SC_MAXIMIZE,null)
lnSendHwnd=FindWindowEx(m.hwnd,0,"Edit",Null)
SendMessages(lnSendHwnd,12,0,prgprg)
endif
=SetForegroundWindow(hwnd)
i=thisform.text1.value
SendMsgWn(lnSendHwnd, EM_SETSEL ;
, SendMsgWn(lnSendHwnd,EM_LINEINDEX,i-1,0) ;
, SendMsgWn(lnSendHwnd,EM_LINEINDEX,i,0) )
ENDPROC
ENDDEFINE