标题:如何获取任务栏内程序图标坐标,鼠标单击?
只看楼主
mayong123
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2008-10-30
 问题点数:0 回复次数:1 
如何获取任务栏内程序图标坐标,鼠标单击?

比如我要找到“新建文件夹”图标在任务栏得坐标,移动鼠标到这个图标上,单击?谢谢各位帮忙....


用下面这段代码得到的是负值。。。
Private Sub Command1_Click()
Dim h As Long, r As RECT
h = FindWindow(vbNullString, Text1.Text) '这里写上你的窗口标题,必须一字不差
GetWindowRect h, r
MsgBox "左上角坐标(" & r.Left & "," & r.Top & ")" & vbCrLf & "右下角坐标(" & r.Right & "," & r.Bottom & ")" & vbCrLf & "窗口高" & r.Bottom - r.Top & "窗口宽" & r.Right - r.Left
End Sub
搜索更多相关主题的帖子: 鼠标 新建文件夹 任务栏 
2011-10-09 16:46
mayong123
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2008-10-30
得分:0 
下面这段代码如何用?没看懂。。各位帮忙看看
Public   Property   Let   Progress(Percent   As   Single)

        If   Percent   <   0   Then
                hWndTray   =   0
                SetCursorPos   CursorPos.x,   CursorPos.y
                Unload   Me
            Else
                If   hWndTray   =   0   Then
                        GetCursorPos   CursorPos   'save   cursor   pos
                        hWndTray   =   FindWindowEx(FindWindow( "Shell_TrayWnd ",   " "),   0,   "TrayNotifyWnd ",   " ")   'find   tray
                        GetWindowRect   hWndTray,   WindowRect
                        With   WindowRect
                                Width   =   (.Right   -   .Left   -   2)   *   15   'adjust   my   size
                                Height   =   (.Bottom   -   .Top   -   2)   *   15
                        End   With
                        PrintY   =   (ScaleHeight   -   TextHeight( "A "))   /   2   'vertical   print   pos
                        SetParent   hWnd,   hWndTray   'tray   is   my   parent
                        ScaleWidth   =   100   'percent
                        FColor   =   ForeColor   'colors...
                        If   FColor   <   0   Then
                                FColor   =   GetSysColor(FColor   And   &H7FFFFFFF)
                        End   If
                        BColor   =   BackColor
                        If   BColor   <   0   Then
                                BColor   =   GetSysColor(BColor   And   &H7FFFFFFF)
                        End   If
                        BColor   =   Not   (FColor   Xor   BColor)
                        Show
                End   If
                With   Screen
                        SetCursorPos   .Width   /   .TwipsPerPixelX,   .Height   /   .TwipsPerPixelY       'to   make   tray   visible
                End   With
                PrintPercent   =   Int(Percent)   &   "% "
                Cls
                CurrentX   =   50   -   TextWidth(PrintPercent)   /   2
                CurrentY   =   PrintY
                Print   PrintPercent
                Line   (0,   0)-(Percent,   Height),   BColor,   BF
        End   If

End   Property
2011-10-11 15:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-351900-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.063016 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved