0

最近のファイルとして設定されているユーザーの選択があります。

$loc = FileSelectFolder("Choose file location...", "\")
$file = FileOpenDialog("Choose file...", $loc, "Jar Files (*.jar*)")
GUICtrlCreateMenuItem($file, $recentfilesmenu)

私はそれから情報を取得しようとしました:

IniWrite("C:\Config.ini", "Recent", "Recent", GUICtrlRead($recentfilesmenu))

しかし、それは私に68という数字しか与えません.私の間違いはどこですか?

4

1 に答える 1

2

数字68はメニューのcontrolIDです。

_GUICtrlMenu_GetItemTextメニュー項目のテキストを読むために使用する必要があります。

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

$hGui = GUICreate('Read Menu Item', 400, 300)
$mnuFile = GUICtrlCreateMenu('&File')
$mnuFileExit = GUICtrlCreateMenuItem('Exit', $mnuFile)
GUISetState()

; read the text of the menu item
$hMenu = _GUICtrlMenu_GetMenu($hGui)
$sText = _GUICtrlMenu_GetItemText($hMenu, $mnuFileExit, False)
MsgBox(0, 'Menu item text', $sText)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Or $msg = $mnuFileExit Then ExitLoop
WEnd

この出力: 終了


更新

マットの提案を拾うにGUICtrlReadは、はるかに短い高度なパラメーターを利用することもできます。

IniWrite("C:\Config.ini", "Recent", "Recent", GUICtrlRead($recentfilesmenu, 1))
于 2013-08-02T05:40:43.840 に答える