VB API如何獲取視窗內控制項的控制代碼(急急急!)

2021-05-05 07:36:34 字數 2216 閱讀 3537

1樓:匿名使用者

private declare function windowfrompoint lib "user32" (byval xpoint as long, byval ypoint as long) as long

private declare function getcursorpos lib "user32" (lppoint as pointapi) as long

private declare function getwindowtext lib "user32" alias "getwindowtexta" (byval hwnd as long, byval lpstring as string, byval cch as long) as long

private type pointapi

x as long

y as long

end type

dim n as pointapi

dim a as long

private sub form_load()

timer1.interval = 100

label1.caption = "移動滑鼠指標"

end sub

private sub timer1_timer()

getcursorpos n

a = windowfrompoint(n.x, n.y)

if a <> 0 then

dim s as string

s = string(100, chr(0))

getwindowtext a, s, 100

label1.caption = "目標標題或文字: " & trim(s)

label2.caption = "目標控制代碼為 " & a

end if

end sub

2樓:

用這個 api 宣告:

private declare function getdlgitem lib "user32" alias "getdlgitem" (byval hdlg as long, byval niddlgitem as long) as long

然後,dim hwnd as long

hwnd = getdlgitem ( hdlg , niddlgitem )

hdlg是視窗的控制代碼,niddlgitem是hdlg視窗內的控制項的id號,返回值hwnd就是控制項的控制代碼。

《vb》api如何獲取視窗內控制項的控制代碼?

3樓:匿名使用者

private declare function windowfrompoint lib "user32" (byval xpoint as long, byval ypoint as long) as long

private declare function getcursorpos lib "user32" (lppoint as pointapi) as long

private declare function getwindowtext lib "user32" alias "getwindowtexta" (byval hwnd as long, byval lpstring as string, byval cch as long) as long

private type pointapi

x as long

y as long

end type

dim n as pointapi

dim a as long

private sub form_load()

timer1.interval = 100

label1.caption = "移動滑鼠指標"

end sub

private sub timer1_timer()

getcursorpos n

a = windowfrompoint(n.x, n.y)

if a <> 0 then

dim s as string

s = string(100, chr(0))

getwindowtext a, s, 100

label1.caption = "目標標題或文字: " & trim(s)

label2.caption = "目標控制代碼為 " & a

end if

end sub

如何固定ie視窗大小,如何固定IE視窗大小?

把滑鼠放到視窗邊框上,把它拖動到最大,關閉瀏覽器,下次再開啟瀏覽器時就會是上次關閉時的最在狀態了.但有一點一定要注意,那就是拉大的視窗必須是最後乙個關閉的視窗,這樣記憶功能才能生效.如果這種方法對你的瀏覽器不湊效,還可以嘗試一下這種方法 從 開始 選單中選擇 執行 在 執行 輸入框中輸入 reged...

ip如何獲取新增網路印表機,IP如何獲取 新增網路印表機

1 開始 設定 印表機和傳真 p 單擊開啟 印表機和傳真 視窗。2 在此視窗中單擊 新增印表機 彈出 新增印表機嚮導 視窗。3 單擊 下一步 在新增印表機嚮導 本地或網路印表機 中,選擇 連線到此計算機的本地印表機 並把 自動檢測並安裝即插即用印表機 前面的勾選狀態去掉 此選項為預設值,很多人以為應...

急!!php獲取url引數,php如何獲取url的引數

url 傳值只能用get 方法,親,你的前台頁面必須用get方法 你這前台用post 後台用get,然後還用url 你這是要玩壞伺服器的節奏嗎 你兩種方式不對,你post傳值用get獲取 你列印一下 post和 get試試,看看到底哪種能接收到值 這個位址在 server http referer ...