$OPTIMIZE ON
$APPTYPE GUI
$TYPECHECK ON
CONST VK_LBUTTON = &H1
CONST VK_RBUTTON = &H2
CONST WM_SETTEXT = &HC
DEFLNG CTLHND
DIM BFR AS STRING:BFR =SPACE$(255)
DECLARE FUNCTION SendMessagex LIB "user32" ALIAS "SendMessageA" ( hwnd AS LONG, wMsg AS LONG, wParam AS LONG, lParam AS STRING) AS LONG
DECLARE FUNCTION GetAsyncKeyState LIB "user32" ALIAS "GetAsyncKeyState" ( vKey AS LONG) AS INTEGER
DECLARE FUNCTION WindowFromPoint LIB "user32" ALIAS "WindowFromPoint" (xPoint AS LONG, yPoint AS LONG) AS LONG
DECLARE FUNCTION GetParent LIB "user32" ALIAS "GetParent"( hwnd AS LONG) AS LONG
DECLARE FUNCTION GetWindowText LIB "user32" ALIAS "GetWindowTextA" ( hwnd AS LONG, ByRef lpString AS STRING, cch AS LONG) AS LONG
DECLARE FUNCTION GetClassName LIB "user32" ALIAS "GetClassNameA" ( hwnd AS LONG, ByRef lpClassName AS STRING, nMaxCount AS LONG) AS LONG
DECLARE FUNCTION SetWindowPos LIB "user32" ALIAS "SetWindowPos"(hWnd AS LONG, hWndAfter AS LONG, x AS INTEGER, y AS INTEGER, width AS INTEGER, height AS INTEGER, FLAGS AS INTEGER) AS INTEGER
DECLARE SUB DOINIT
DECLARE SUB DOTIMER
DECLARE SUB STARTCAPT
DECLARE SUB CHECKLEN(Key AS WORD, Shift AS INTEGER)
DECLARE SUB SENDDATA
DECLARE SUB GETADDITIONALINFO
CREATE TIMEX AS QTIMER
INTERVAL=100
ONTIMER=DOTIMER
ENABLED=0
END CREATE
CREATE BFONT AS QFONT
NAME= "ARIAL"
SIZE= 9
COLOR= 0
BOLD= 1
ITALIC= 0
END CREATE
CREATE RFONT AS QFONT
NAME= "ARIAL"
SIZE= 9
COLOR= 255
BOLD= 1
ITALIC= 0
END CREATE
CREATE FORM AS QFORM
CAPTION= "SEND IT"
WIDTH= 647
HEIGHT= 180
ONSHOW=DOINIT
CENTER
CREATE REDIT AS QRICHEDIT
FONT= BFONT
HIDESELECTION= 0
SCROLLBARS= 3
PLAINTEXT= 1
WANTTABS= 1
FONT= BFONT
TOP= 10
LEFT= 10
WIDTH= 480
HEIGHT= 80
ONKEYDOWN=CHECKLEN
END CREATE
CREATE SENDBTN AS QBUTTON
CAPTION= "SEND"
TABORDER= 2
TAG= 2
FONT= BFONT
ONCLICK=SENDDATA
TOP= 35
LEFT= 520
WIDTH= 80
HEIGHT= 30
END CREATE
CREATE GROUPBOX AS QGROUPBOX
CAPTION="Press Capture Control Button then Click on a control in the Application you want the above text sent to..."
TOP= 100
LEFT= 10
WIDTH= 620
HEIGHT= 45
CREATE CAPTBTN AS QBUTTON
CAPTION= "CAPTURE CONTROL"
TABORDER= 3
TAG= 3
FONT= BFONT
ONCLICK=STARTCAPT
TOP= 15
LEFT= 10
WIDTH= 130
HEIGHT= 25
END CREATE
CREATE PANEL4 AS QPANEL
BEVELOUTER=0
FONT= BFONT
TOP= 13
LEFT= 140
WIDTH= 470
HEIGHT= 25
END CREATE
END CREATE
END CREATE
SUB SENDDATA
SENDMESSAGEX CTLHND, WM_SETTEXT, 0 ,REDIT.TEXT
END SUB
SUB DOTIMER
DEFINT BS
BS=GETASYNCKEYSTATE(&H01) OR GETASYNCKEYSTATE(&H02)
IF BS<>0 THEN
CTLHND=WINDOWFROMPOINT(SCREEN.MOUSEX, SCREEN.MOUSEY)
IF CTLHND = SENDBTN.HANDLE OR CTLHND = CAPTBTN.HANDLE THEN EXIT SUB
GETADDITIONALINFO
SENDDATA
TIMEX.ENABLED=0
CAPTBTN.FONT=BFONT
END IF
END SUB
SUB STARTCAPT
TIMEX.ENABLED=1
PANEL4.CAPTION=""
CAPTBTN.FONT=RFONT
END SUB
SUB CHECKLEN
IF LEN(REDIT.TEXT)>255 THEN
KILLMESSAGE(FORM.HANDLE, &H102)
END IF
END SUB
SUB GETADDITIONALINFO
DEFSTR TXT,ST
DEFLNG LH
TXT="Handle= " & STR$(CTLHND)
LH = GETWINDOWTEXT(CTLHND,BFR, 255)
ST = LEFT$(BFR, LH)
IF ST<>"" THEN TXT=TXT & " Title: " & ST
LH = GETCLASSNAME(CTLHND,BFR, 255)
ST = LEFT$(BFR, LH)
TXT = TXT & " Class: " & ST
PANEL4.CAPTION=TXT
END SUB
SUB DOINIT
REDIT.TEXT="Sample Text to Send"
SetWindowPos(FORM.handle, -1, 0, 0, 0, 0, 3)
END SUB
FORM.SHOWMODAL
|