Jump to content

MRU UDF


Yashied
 Share

Recommended Posts

LAST VERSION - 1.3

06-Apr-09

Deprecated.

A collection of functions for working with Most Recently Used (MRU) lists.

Available functions

_MRU_Create

_MRU_Release

_MRU_GetSize

_MRU_SetSize

_MRU_GetItem

_MRU_GetItemCount

_MRU_AddItem

_MRU_AddArray

_MRU_DeleteItem

_MRU_SearchItem

_MRU_Reset

_MRU_GetAsArray

_MRU_GetAsString

_MRU_RegAssign

_MRU_RegRead

_MRU_RegWrite

MRU UDF Library v1.3

Previous downloads: 1573

MRU.au3

Example1

#Include <MRU.au3>

Global Const $RegKey = 'HKLM\SOFTWARE\Test\MRU'

Global $Mru, $Array

$Mru = _MRU_Create()

_MRU_AddItem($Mru, 'Item 4')
_MRU_AddItem($Mru, 'Item 3')
_MRU_AddItem($Mru, 'Item 2')
_MRU_AddItem($Mru, 'Item 1')
MsgBox(0, '', _MRU_GetAsString($Mru, '|'))
_MRU_SetSize($Mru, 2)
$Array = _MRU_GetAsArray($Mru)
For $i = 1 To $Array[0]
    MsgBox(0, '', $Array[$i])
Next
_MRU_RegWrite($Mru, $RegKey)

_MRU_Release($Mru)

Example2

#Include <GUIComboBox.au3>
#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>
#Include <MRU.au3>

Global Const $RegKey = 'HKLM\SOFTWARE\Test\MRU'

Global $ButtonOk, $Combo, $Msg, $Mru

$Mru = _MRU_Create($RegKey)

GUICreate('Test', 400, 88)
$Combo = GUICtrlCreateCombo('', 20, 20, 360, 21)
GUICtrlSetData(-1, _MRU_GetAsString($Mru, '|'), _MRU_GetItem($Mru, 1))
$ButtonOk = GUICtrlCreateButton('OK', 165, 58, 70, 21)
GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Do
    $Msg = GUIGetMsg()
    If $Msg = $ButtonOk Then
        _MRU_AddItem($Mru, GUICtrlRead($Combo))
        _MRU_RegWrite($Mru)
    EndIf
Until ($Msg = $ButtonOk) Or ($Msg = $GUI_EVENT_CLOSE)

_MRU_Release($Mru)

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Switch BitAND($wParam, 0xFFFF)
        Case $Combo
            Switch BitShift($wParam, 16)
                Case $CBN_EDITCHANGE
                    _GUICtrlComboBox_AutoComplete($Combo)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND
Edited by Yashied
Link to comment
Share on other sites

  • 1 month later...

is it possible with this to grap the MRU of the Win+R command?

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Hi Yashied,

I haven't had a chance to try this out yet but wanted to say thanks for all of the cool examples you've been kicking out.

I'll let you know how it goes.

Hat's off, sir!

Thanks.

is it possible with this to grap the MRU of the Win+R command?

No. This UDF will not work with an MRU of Run Dialog. At least without further modification. You can watch himself on the MRU structure of a Run Dialog.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

Link to comment
Share on other sites

Thanks.

No. This UDF will not work with an MRU of Run Dialog. At least without further modification. You can watch himself on the MRU structure of a Run Dialog.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

yea, tried it out myself, unfortunately you are right, (cry for standardisation), thanks anyway.

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

modified two lines and thats it:-)

#Include <GUIComboBox.au3>
#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>
#include <process.au3>
#Include <MRU.au3>
; modified two lines in _MRUGetAsString
; func _MRUGetAsString($MruID, $sSeparator, $remove = "")
; $str &= stringreplace($MruArray[Asc(StringLeft(StringTrimLeft($MruArray[0], $j - 1), 1)) - 96],$remove,"")

#include <misc.au3>

;~ const $RegKey = 'HKLM\SOFTWARE\Test\MRU'
const $RegKey = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU'
local $ButtonOk, $Combo, $Msg, $Mru
$Mru = _MRUCreate($RegKey)

GUICreate('Test', 400, 88)
$Combo = GUICtrlCreateCombo('', 20, 20, 360, 80)
GUICtrlSetData(-1, _MRUGetAsString($Mru, '|',"\1"), _MruGetItem($Mru, 1))
$ButtonOk = GUICtrlCreateButton('OK', 165, 58, 70, 21)
GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
$done = False
do
    $Msg = GUIGetMsg()
    if $Msg = $ButtonOk or _IsPressed("0D") then
        _MRUAddItem($Mru, GUICtrlRead($Combo)& "\1")
        _MRURegWrite($Mru)
        _rundos(GUICtrlRead($Combo))
        $done = True
    endif
until ($done) or ($Msg = $GUI_EVENT_CLOSE)

_MRURelease($Mru)

func WM_COMMAND($hWnd, $msgID, $wParam, $lParam)
    switch $lParam
        case GUICtrlGetHandle($Combo)
            if BitShift($wParam, 0x10) = $CBN_EDITCHANGE then
                _GUICtrlComboBox_AutoComplete($Combo)
            endif
        case else
            ;;;
    endswitch
    return $GUI_RUNDEFMSG
endfunc; WM_COMMAND
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

modified two lines and thats it:-)

Very good, but this will be true only for the Run Dialog. There are several types of MRU, but the most common and easiest to use is the one that I realized in my UDF. Here are a few species.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs

:D

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...

Yashied, the example #1 is crashing the application. The second one does not work for me either after specifying data in the input box.

The error was come after calling to the first _MRU_AddItem function:

C:\All\B_QA\QA\MyTools\Astetaine\examples\MRU Yashied\MRU.au3 (379) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
if $MruArray[$j] = $sItem then
if ^ ERROR

I also noticed that the registry is not created "$RegKey = 'HKLM\SOFTWARE\Test\MRU'"

Does the UDF should create the registry key above?

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

I guess the problem is that with UAC activated under Vista+ you need to run the script with elevated Admin rights to access the HKLM registry hive. Maybe renaming any occurrence of HKLM to HKU or HKCU will do the trick.

Link to comment
Share on other sites

I guess the problem is that with UAC activated under Vista+ you need to run the script with elevated Admin rights to access the HKLM registry hive. Maybe renaming any occurrence of HKLM to HKU or HKCU will do the trick.

Thanks Kafu for the advice, I am running on XP.

But as Yashied says latter on, this udf is not supported anymore.

Thanks Yashied, I was not aware to the MRU functions at the WinAPIEX UDF, I will dig into them.

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...