找回密码
 加入
搜索
查看: 4640|回复: 9

[GUI管理] 已解决 如何点击任务栏托盘图标?

  [复制链接]
发表于 2011-12-7 17:22:34 | 显示全部楼层 |阅读模式
本帖最后由 nop 于 2011-12-16 20:35 编辑

比如我右击托盘QQ图标再选择“离线”,再比如右击阿里旺旺选择“注销”,方法应该都是一样的,如何实现?
发表于 2011-12-7 20:41:02 | 显示全部楼层
回复 1# nop

参考了这里.
http://www.autoitscript.com/forum/topic/106169-tray-icon-click/

#include "SysTray_UDF.au3"
;Left-click Feedreader's icon on system tray
; Press hide inactive icon's button part is from Valik's refresh system tray script!
$oldMatchMode = Opt("WinTitleMatchMode", 4)
$oldChildMode = Opt("WinSearchChildren", 1)
$class = "classname=Shell_TrayWnd"
$hControl = ControlGetHandle($class, "", "Open Skype")
; get tray position and move there. Helps if Auto Hide tray option is used.
$posTray = WinGetPos(_FindTrayToolbarWindow ())
MouseMove($posTray[0], $posTray[1])
$index = _SysTrayIconIndex ("QQ.exe"); Change this to some other application if needed
If $index <> -1 Then
   $pos = _SysTrayIconPos ($index)
   If $pos = -1 Then
      ; ***** Moved by CatchFish *****
      ; If XP and the Hide Inactive Icons mode is active
      If $hControl <> "" And ControlCommand($class, "", $hControl, "IsVisible", "") Then
         ControlClick($class, "", $hControl)
         Sleep(250); Small delay to allow the icons to be drawn
      EndIf
      ; ******************************
      $pos = _SysTrayIconPos ($index)
      If $pos = -1 Then Exit ; ** A real error this time;)
   EndIf
   MouseMove($pos[0], $pos[1])
   Sleep(1000)
   MouseClick("right")

   MouseMove($pos[0] - 50 , $pos[1] - 200)
   MouseClick("left")
EndIf

评分

参与人数 2金钱 +38 收起 理由
nop + 18
afan + 20

查看全部评分

 楼主| 发表于 2011-12-7 23:30:12 | 显示全部楼层
回复 2# lixiaolong


    看的好眼花啊。。这段我还是用按键精灵来录制吧
发表于 2011-12-8 17:32:22 | 显示全部楼层
按键精灵录出来的应该全是座标吧
发表于 2011-12-10 19:02:36 | 显示全部楼层
看着虽然代码眼晕,但慢慢研究会学不少东西的!
发表于 2011-12-10 21:51:57 | 显示全部楼层
看了都是英文啊,头大的不行
发表于 2012-6-1 17:43:06 | 显示全部楼层
回复 2# lixiaolong


   这串代码  太好了,解决了一个问题。
发表于 2012-6-1 21:34:01 | 显示全部楼层
已经成功应用,感谢2楼大大
发表于 2014-10-30 11:48:14 | 显示全部楼层
感谢2楼大大分享,学习啦~
发表于 2016-12-16 20:52:38 | 显示全部楼层
点不到位置.....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-16 18:43 , Processed in 0.079632 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表