找回密码
 加入
搜索
查看: 2400|回复: 2

[AU3基础] [已解决]怎样在系统部署时获取正在运行的程序名或窗口名

[复制链接]
发表于 2010-11-12 10:59:01 | 显示全部楼层 |阅读模式
本帖最后由 学习一下 于 2010-11-15 11:58 编辑

在系统部署时怎样获取正在运行的程序名或窗口名(不是进程名),试用窗口管理函数来获取无效。

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-11-12 16:42:49 | 显示全部楼层
本帖最后由 yhxhappy 于 2010-11-12 16:46 编辑

不太明白楼主的意思,希望以下代码对你有帮助
  1. #include <WinAPI.au3>
  2. #Include <WinAPIEx.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <GuiListView.au3>

  5. ;创建主窗口
  6. $GUI = GUICreate("EnumWindows",  1000, 700)

  7. ;绘制并生成数据表
  8. $listview = GUICtrlCreateListView("", 15, 10, 970, 640)
  9.         _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_REPORT, $LVS_EX_FULLROWSELECT))
  10.         _GUICtrlListView_AddColumn($listview, "窗口句柄", 85)
  11.         _GUICtrlListView_AddColumn($listview, "窗口标题", 450)
  12.         _GUICtrlListView_AddColumn($listview, "窗口文本", 250)
  13.         ;_GUICtrlListView_AddColumn($listview, "CLASS", 50)
  14.         _GUICtrlListView_AddColumn($listview, "PID", 55)
  15.         _GUICtrlListView_AddColumn($listview, "进程名称", 100)

  16. ;刷新按钮
  17. $Installa_Button = GUICtrlCreateButton("刷新", 835, 655, 150, 35)       

  18. AddListviewItem()
  19. GUISetState()

  20. While 1
  21.     $msg = GUIGetMsg()
  22.         Switch $Msg
  23.         Case $GUI_EVENT_CLOSE
  24.                 Exit
  25.         Case $Installa_Button
  26.                 AddListviewItem()
  27.         EndSwitch
  28. WEnd

  29.        
  30. Func AddListviewItem()
  31.         _GUICtrlListView_DeleteAllItems($listview)
  32.         $aWindows = _WinAPI_EnumWindows()
  33.         For $i = 1 To $aWindows[0][0]
  34.                 $WindowHandle = $aWindows[$i][0]
  35.                 $WindowsClass = $aWindows[$i][1]
  36.                 $WindowTitle = WinGetTitle($aWindows[$i][0])
  37.                 $WindowText = WinGetText($aWindows[$i][0])
  38.                 $ProcessPID = WinGetProcess($aWindows[$i][0])
  39.                 $e = StringSplit(_WinAPI_GetModuleFileNameEx($ProcessPID), "")                          ;提取进程名称,也可以取进程的路径
  40.                 $ProcessName = $e[$e[0]]
  41.                 If $WindowTitle <> "" Then GUICtrlCreateListViewItem($WindowHandle & "|" & $WindowTitle& "|" & $WindowText & "|" & $ProcessPID & "|" & $ProcessName, $listview)                  ;如果窗口标题为空,则不添加进表格,去掉判断则会全部添加
  42.         Next
  43. EndFunc
复制代码

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-11-15 11:57:48 | 显示全部楼层
回复 2# yhxhappy

谢谢你的帮助,在你的源码中找到了我需要的
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2026-9-25 08:02 , Processed in 0.094574 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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