VB如何将一个窗口移动到一个指定位置

一个窗口整体的x0,y0坐标,移到桌面的x0,y0坐标
2025-01-05 06:11:26
推荐回答(3个)
回答1:

Private Declare Function SetWindowPos Lib "user32" _
(ByVal Hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long '为窗口指定一个新位置和状态
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Const SWP_NOSIZE = &H1 '忽略cx,cy
Const SWP_NOZORDER = &H4 '忽略hWndInsertAfter
Dim mHwnd&
mHwnd& = FindWindow(0&, "无标题.txt - 记事本")
SetWindowPos mHwnd&, 0, 100, 100, 0, 0, SWP_NOZORDER Or SWP_NOSIZE
End Sub

回答2:

用move方法!

回答3:

VBSCall FindColorEx(0,0,1279,1023,"2e646d",1,1,x,y)
If x>=0 and y>=0
MoveToS x,y
MoveRS 0,-10
LeftDownS 1
MoveToS 172,17
LeftUpS 1
Else
EndIf