关于Combo的三个小问题
#include <WinAPI.au3>#include <GuiComboBox.au3>
#include <Array.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $sComboRead
Local $hGUI = GUICreate("进程列表", 360, 180, -1, -1)
Local $hCombo = GUICtrlCreateCombo("", 10, 20,200,30)
Local $hButnf = GUICtrlCreateButton("搜索", 285, 15, 60,30)
Local $iClose = GUICtrlCreateButton("关闭", 285,135,60, 35)
GUISetState()
;--------------------------------------------------------------------------------------------------------------------
_SendMessage($hCombo, 0x14B)
Local $prr = ProcessList()
For $i = 1 To $prr
_GUICtrlComboBox_AddString($hCombo,$prr[$i])
Next
Sleep(9000)
Local $iPID = Run("notepad.exe", "", @SW_SHOWMINIMIZED)
Sleep(9000)
ProcessClose($iPID)
;--------------------------------------------------------------------------------------------------------------------
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $iClose
ExitLoop
Case $hCombo
_SendMessage($hCombo, 0x14B)
_GUICtrlComboBox_BeginUpdate($hCombo)
Local $prr = ProcessList()
For $i = 1 To $prr
_GUICtrlComboBox_AddString($hCombo,$prr[$i])
Next
_GUICtrlComboBox_EndUpdate($hCombo)
Case $hButnf
local $ret=_GUICtrlComboBox_FindString($hCombo, "notepad.exe",100)
ConsoleWrite($ret & @CRLF)
EndSwitch
WEnd
如上,想把进程列表导入Combo,并能实时更新,但是效果不行
想实现的效果是
1、如何在点击组合框的下拉箭头展现列表的时候,列表的项目能跟系统的进程管理器一样即时刷新呢?
上例中打开和关闭notepad.exe进程在列表中没有反应
2、列表的项目怎么按拼音或其它条件排序呢?不排序的话看着杂乱无章
3、如何查找列表中的项目呢? 回调函数每隔 sleep(300)刷新一次? 回调函数每隔 sleep(300)刷新一次?
heroxianf 发表于 2017-3-12 15:37 http://www.autoitx.com/images/common/back.gif
要用到回调函数吗?刚接触AU3的Combo,发现自定义函数不少,是不是有什么函数不知道,没用上呢.... 帖子沉了,还无解。再回头看看.... http://www.autoitx.com/thread-54661-1-2.html
做个参考! 做个参考!
heroxianf 发表于 2017-3-25 12:50 http://www.autoitx.com/images/common/back.gif
感谢指点....
{:face (332):} 用回调函数定时刷新似乎有些浪费或占用资源。能实现按需刷新就好了..... 回复 7# cashiba
Local $prr = ProcessList()
Local $ii = 0
For $i = 2 To $prr ;- 1
_GUICtrlComboBox_AddString($hCombo, $prr[$i])
_GUICtrlListView_AddItem($ListView1, $prr[$i], 3)
$DriveFreeGB = ByteConversion($prr[$i]);单位转换
_GUICtrlListView_AddSubItem($ListView1, $ii, $DriveFreeGB, 1)
$ii += 1
Next
AdlibRegister("Ffive", 60000)
While 1
Sleep(1000)
WEnd
Func Ffive()
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
GUICtrlSetData($hCombo, "")
_WinAPI_PostMessage($ListView1, 0x0100, 0X74, 0)
_WinAPI_PostMessage($hCombo, 0x0100, 0X74, 0)
Local $prr = ProcessList()
Local $ii = 0
For $i = 2 To $prr ;- 1
_GUICtrlComboBox_AddString($hCombo, $prr[$i])
;GUICtrlSetData($ListView1, $prr[$i])
;GUICtrlCreateListViewItem($prr[$i], $ListView1)
_GUICtrlListView_AddItem($ListView1, $prr[$i], 3)
$DriveFreeGB = ByteConversion($prr[$i]);单位转换
_GUICtrlListView_AddSubItem($ListView1, $ii, $DriveFreeGB, 1)
;_GUICtrlListView_AddSubItem($ListView1, $ii, $prr[$i], 2)
$ii += 1
Next
EndFunc ;==>Ffive
回复cashiba
chzj589 发表于 2017-3-26 15:54 http://www.autoitx.com/images/common/back.gif
谢谢chzj589大虾~
看样子也就是是用回调函数来解决了,就是时不时的闪烁一下有些不美....
{:face (239):} 本帖最后由 kk_lee69 于 2017-3-29 18:32 编辑
回复 1# cashiba
不用回調函數吧˙
使用GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")即可達到所要效果吧 回复cashiba
不用回調函數吧˙
使用GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")即可達 ...
kk_lee69 发表于 2017-3-29 18:05 http://www.autoitx.com/images/common/back.gif
对消息还不是太熟,再慢慢琢磨...感谢指点! 回复 11# cashiba
請直接 點擊 COMBO 下拉三角形 多次即可看到成效
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <WinAPI.au3>
#include <GuiComboBox.au3>
#include <Array.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $sComboRead
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
Local $hGUI = GUICreate("表", 360, 180, -1, -1)
Local $hCombo = GUICtrlCreateCombo("", 10, 20,200,30)
Local $hButnf = GUICtrlCreateButton("搜索", 285, 15, 60,30)
Local $iClose = GUICtrlCreateButton("??", 285,135,60, 35)
GUISetState()
;--------------------------------------------------------------------------------------------------------------------
_SendMessage($hCombo, 0x14B)
Local $prr = ProcessList()
For $i = 1 To $prr
_GUICtrlComboBox_AddString($hCombo,$prr[$i])
Next
$CHECK=0
;--------------------------------------------------------------------------------------------------------------------
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $iClose
ExitLoop
Case $hCombo
Case $hButnf
F)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
Local $hWndFrom, $iIDFrom, $iCode
;$hWndFrom = $hWnd
$hWndFrom = $ilParam
$iIDFrom =_WinAPI_LoWord($iwParam);獲取低位 $iControl = BitAND($iwParam, 0xFFFF)
$iCode = _WinAPI_HiWord($iwParam);獲取高位 $iMsg = BitShift($iwParam, 16)
IF $iCode=7 Then
IF $CHECK=1 Then
GUICtrlSetData($hCombo, "", "")
GUICtrlSetData($hCombo, "重新搜索1|重新搜索2", "重新搜索2")
$CHECK=0
Else
$CHECK=1
GUICtrlSetData($hCombo, "", "")
Local $prr = ProcessList()
For $i = 1 To $prr
_GUICtrlComboBox_AddString($hCombo,$prr[$i])
Next
EndIf
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_COMMAND 谢谢kk_lee69大虾不吝赐教....
收藏代码学习了
{:face (332):}
页:
[1]