找回密码
 加入
搜索
楼主: lizhongbo

[AU3基础] 通过对比,获取系统未使用的盘符的方法求助

[复制链接]
发表于 2020-6-12 16:32:34 | 显示全部楼层
lizhongbo 发表于 2020-6-11 22:05
谢谢,还有个问题就是,添加一个按钮,每点击一次按钮,组合框内容就显示下一项内容!这个搞定了,但是如 ...

我再瞎扯一下!



#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GuiComboBox.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("可用盘符", 306, 96)
$Combo1 = GUICtrlCreateCombo("", 24, 16, 145, 25)
$Button1 = GUICtrlCreateButton("确认挂载", 200, 16, 75, 25)
$Button2 = GUICtrlCreateButton("卸载", 200, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $pf = 0
Global $aNewOrder, $aNewOrderInfo[1][3], $aFixedOrder[27]


For $i = 65 To 90
        If $pf = 0 And Not FileExists(Chr($i) & ':') Then $pf = $i
        If Not FileExists(Chr($i) & ':') Then
                If StringRegExp('XY', '(?i)' & Chr($i)) = 0 Then GUICtrlSetData($Combo1, Chr($i), Chr($pf))
        EndIf
Next

Func zhkxyg($up = "")
        $sPartion = _GUICtrlComboBox_GetList($Combo1)

        If StringRight($sPartion, 1) == '|' Then $sPartion = StringTrimRight($sPartion, 1)
        $aNewOrder = StringSplit($sPartion, '|', 1)
        ReDim $aNewOrderInfo[UBound($aNewOrder)][3]
        $aNewOrderInfo[0][0] = $aNewOrder[0]
        For $i = 1 To $aNewOrder[0]
                _GUICtrlComboBoxEx_SetCurSel($Combo1, GUICtrlRead($Combo1))
                If GUICtrlRead($Combo1) = $aNewOrder[$i] Then
                        If $up = "" Then 
                                ControlCommand('', '', $Combo1, 'SetCurrentSelection', $i)
                        Else
                                If $i <> 1 Then _GUICtrlComboBox_SetCurSel($Combo1, $i-2)
                        EndIf
                        ExitLoop
                EndIf
        Next
EndFunc   ;==>zhkxyg

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Button1
                        zhkxyg()
                Case $Button2
                        zhkxyg("1")
                        ;MsgBox(4096,"", "找到" & _GUICtrlComboBox_GetList ( $Combo1 ))
                        ;_GUICtrlComboBoxEx_SetCurSel($Combo1,GUICtrlRead($Combo1)+1)
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2020-6-12 16:45:11 | 显示全部楼层
本帖最后由 xzf680 于 2020-6-12 16:48 编辑


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GuiComboBox.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("可用盘符", 306, 96)
$Combo1 = GUICtrlCreateCombo("", 24, 16, 145, 25)
$Button1 = GUICtrlCreateButton("确认挂载", 200, 16, 75, 25)
$Button2 = GUICtrlCreateButton("卸载", 200, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $aNewOrder, $aNewOrderInfo[1][3], $aFixedOrder[27]
For $i = 65 To 87
        If Not FileExists(Chr($i) & ':') Then GUICtrlSetData($Combo1, Chr($i))
Next
_GUICtrlComboBox_SetCurSel($Combo1, 0)
Func zhkxyg($up = "")
        $sPartion = _GUICtrlComboBox_GetList($Combo1)
        If StringRight($sPartion, 1) == '|' Then $sPartion = StringTrimRight($sPartion, 1)
        $aNewOrder = StringSplit($sPartion, '|', 1)
        ReDim $aNewOrderInfo[UBound($aNewOrder)][3]
        $aNewOrderInfo[0][0] = $aNewOrder[0]
        For $i = 1 To $aNewOrder[0]
                _GUICtrlComboBoxEx_SetCurSel($Combo1, GUICtrlRead($Combo1))
                If GUICtrlRead($Combo1) = $aNewOrder[$i] Then
                        If $up = "" Then 
                                _GUICtrlComboBox_SetCurSel($Combo1, $i)
                        Else
                                If $i <> 1 Then _GUICtrlComboBox_SetCurSel($Combo1, $i-2)
                        EndIf
                        ExitLoop
                EndIf
        Next
EndFunc   ;==>zhkxyg

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Button1
                        zhkxyg()
                Case $Button2
                        zhkxyg("1")
                        ;MsgBox(4096,"", "找到" & _GUICtrlComboBox_GetList ( $Combo1 ))
                        ;_GUICtrlComboBoxEx_SetCurSel($Combo1,GUICtrlRead($Combo1)+1)
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
 楼主| 发表于 2020-6-12 17:50:40 | 显示全部楼层
再次表示感谢!!!谢谢大家的帮助
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 04:13 , Processed in 0.075309 second(s), 13 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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