一、利用API取得視窗的標題ば陸ù疤澹疲錚潁恚焙桶磁ィ茫錚恚恚幔睿洌豹ぴ詖疤迥?櫓刑砑尤縵麓碼:
OptionExplicit
PrivateDeclareFunctio nGe4WindowTextLib"us—
er32"Alias"GetWindowTeft9"(Cyd
Long,ByVallpStringAsStlh「
Long)AsLong
'在窗體聲明節中加入API函數「GetWindowText」的說明
'函數將向lpstring中載入
PrivateSubCommand1_Clik()
DimreturncodeAsLong
DimcaptextAsString
DimcaplenAsLong
catext=String$(100,0)
caplen=99
returncode=GetWindowTeyt(By
ByValcaptext,ByValcaplen)
printreturncode
Printcaptext
Printcaplen
EndSub
二、取得滑鼠在目前視窗(顧客區)的螢幕座標そ立一新項目窗體form1並加入控製文字方塊Text1、Text2ぴ詢疤?櫓惺淙耄邯
OptionExplicit
PrivateDeclon GetCursorPosLbb"user32"
(lpPointAsPOINTAPI)AsLong
PrivateTypePOINTAPI
XAsLongYAsLong
EndType
DimptAsPOINTAPI
DimreturncodeAsLong
PrivateSubForm_Load()
Text1. Text=""
Text2. Text=""
MaxButton=Fale
MinButton=Fale
Form1. WindowState=2
EndSub
PrivateSubForm_Mouse Move(ButtonAsInteger,
ShiftAsInteger,XAsSingle,YAsSingle)
'注意pt結構是按引用傳遞的
reurncode=GetCursoPos(pt)
Text1. Text=pt. X
Text2. Text=pt. 1
EndSub
三、記錄Windows使用時間
建立新專案視窗form1,輸入代碼:
PrivateSubForm_Load()
form1. visible=false
Openapp. pat+"memo.txt"FoqAppendA。1
Print#1,"啟動windoww:"&CStr(Now)
Close#1
EndSub
PrivateSubForm_Unload(CancelAsInteger)
Openapp. pat+"memo.txt"FoqAppendA。1
Print#1,"關閉windoww:"&CStr(Now)
Close#1
End
EndSub
最後將此程序加入啟動組即可。 (->