Jump to content

build up $var then run as part of same script


Recommended Posts

I playing with setting up a usb key menu that builds its self from the contents of a folder which contains shortcuts.

so my idea was to build up a $var line by line which i already did, now i would like the script to use the built up $var as part of the script itself.

i was hoping i could just put the $var on a line by its self but that didn't work. seems like there should be a way but all the searches i could think of on the help file and forums turned up nothing. probably not thinking of the right search.

any help or ideas would be appreciated

Link to comment
Share on other sites

I playing with setting up a usb key menu that builds its self from the contents of a folder which contains shortcuts.

so my idea was to build up a $var line by line which i already did, now i would like the script to use the built up $var as part of the script itself.

i was hoping i could just put the $var on a line by its self but that didn't work. seems like there should be a way but all the searches i could think of on the help file and forums turned up nothing. probably not thinking of the right search.

any help or ideas would be appreciated

May need more info or example scripts to see what you've done but you could use something like _FileListToArray to retrieve an array of your shortcuts and do something with it from there.

#Include <File.au3>
#Include <Array.au3>
$shortCuts = _FileListToArray(@ScriptDir, "*.lnk", 1)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($shortCuts, "$shortCuts")

I didn't follow what you wanted to do with the $var stuff.

Link to comment
Share on other sites

May need more info or example scripts to see what you've done but you could use something like _FileListToArray to retrieve an array of your shortcuts and do something with it from there.

I didn't follow what you wanted to do with the $var stuff.

yes i did started with the FileListToArray and then broke up the TrayCreateMenu example to build up a variable line by line like this:

$var = $var & "SomeScriptHere" & @CRLF

in order to build the script and hopefully menu on the fly.

this is what i have so far:

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray("X:\SystemFiles\StartMenu\")
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

; while statment creation start
$whileS = "While 1" & @CRLF
$whileS = $whileS & "$menuItem = TrayGetMsg()" & @CRLF
$whileS = $whileS & "Case $menuItem = 0" & @CRLF
$whileS = $whileS & "ContinueLoop" & @CRLF

; Menu Creation
#Include <Constants.au3>
#NoTrayIcon
Opt("TrayMenuMode",1)
$loops = 0
Do
    $loops += 1
    $vars = "$FileList[" & $loops &"]"
    $item = TrayCreateItem($vars)

    ; while statment creation build
    $whileS = $whileS & "Case $menuItem = " & $vars & @CRLFle 
    $whileS = $whileS & "Run ('X:\SystemFiles\" & $vars & @CRLF
Until $loops = $FileList[0]

TrayCreateItem("")
$unload = TrayCreateItem("Unload Crypt_Egg")

; while statment creation end
$whileS = $whileS & "Case $menuItem = $unload" & @CRLF
$whileS = $whileS & "ExitLoop" & @CRLF
$whileS = $whileS & "EndSelect" & @CRLF
$whileS = $whileS & "WEnd" & @CRLF

TraySetState()
MsgBox (1,"", $whileS)

so the end of this script would ideally continue to run the $whileS variable instead of showing it as a message.

Link to comment
Share on other sites

why not just while 1...WEnd??

I did try that first but i found that i could not get that to work because i would need to nest a do...until in the middle of the select ....endselect and it didn't seem to work either;

While 1
    $menuItem = TrayGetMsg()
    Select
        Case $menuItem = 0
            ContinueLoop
                $loops = 0
                Do
                    $loops += 1
                    $vars = "$FileList[" & $loops &"]"
                Case $menuItem = $vars
            Run ("X:\SystemFiles\StartMenu\" & $vars)
                Until $loops = $FileList[0]
        Case $menuItem = $unload
            ExitLoop
    EndSelect
WEnd
Link to comment
Share on other sites

I did try that first but i found that i could not get that to work because i would need to nest a do...until in the middle of the select ....endselect and it didn't seem to work either;

While 1
    $menuItem = TrayGetMsg()
    Select
        Case $menuItem = 0
            ContinueLoop
                $loops = 0
                Do
                    $loops += 1
                    $vars = "$FileList[" & $loops &"]"
                Case $menuItem = $vars
            Run ("X:\SystemFiles\StartMenu\" & $vars)
                Until $loops = $FileList[0]
        Case $menuItem = $unload
            ExitLoop
    EndSelect
WEndoÝ÷ Ûú®¢×«b²Ê&+¶êÞvÜ"²×µ©àçe¢ßvåyjeøjب«­¢+Ø%¹±Õ±Ðí¥±¹ÔÌÐì(%¹±Õ±ÐíÉÉä¹ÔÌÐì(9½QÉå%½¸()=ÁÐ ÅÕ½ÐíQÉå5¹Õ5½ÅÕ½Ðì°Ä¤()±½°ÀÌØíÙQÉå%ѵÍlÅtôlÁt((ìб¥Íн͡½ÉÑÕÑÌ(ÀÌØí¥±1¥ÍÐô}¥±1¥ÍÑQ½ÉÉä¡Í­Ñ½Á¥È¤)%ÉɽÈ=ÈÀÌØí¥±1¥ÍÑlÁtôÀQ¡¸(%5Í  ½à ÄØ°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½Ðí9¼¥±ÌÀäÈí½±É̽չ¸ÅÕ½Ðì¤(%á¥Ð)¹%((ì
ÉÑQÉå5¹Ô(ÀÌØíM¡½ÉÑ
ÕÑ5¹ÔôQÉå
ÉÑ5¹Ô ÅÕ½ÐíM¡½ÉÐ
ÕÑÌÅÕ½Ðì¤)½ÈÀÌØí¸ôÄQ¼ÀÌØí¥±1¥ÍÑlÁt(%}ÉÉå ÀÌØíÙQÉå%ѵ̰QÉå
ÉÑ%Ñ´ ÀÌØí¥±1¥ÍÑlÀÌØí¹t°ÀÌØíM¡½ÉÑ
ÕÑ5¹Ô¤¤)9áÐ(ÀÌØíÙQÉå%ѵÍlÁtôU   ½Õ¹ ÀÌØíÙQÉå%ѵ̤´Ä(ÀÌØíEÕ¥ÐôQÉå
ÉÑ%Ñ´ ÅÕ½Ðíá¥ÐÅÕ½Ðì¤)QÉå
ÉÑ%Ñ´ ÅÕ½ÐìÅÕ½Ðì¤((ìM¡½ÜÑÉ䥽¸)QÉåMÑMÑÑ ¤((ì]¥Ð½ÈÑ¥Ù¥Ñä)]¡¥±Ä($ÀÌØíQÉå5ÍôQÉåÑ5Í ¤(%MÝ¥Ñ ÀÌØíQÉå5Í($%
ÍÀ($$%
½¹Ñ¥¹Õ1½½À($%
ÍÀÌØíEÕ¥Ð($$%á¥Ð($%
ͱÍ($$$ÀÌØíM¡½ÉÑ
ÕÐôÅÕ½ÐìÅÕ½Ðì($$%½ÈÀÌØí¸ôÄQ¼ÀÌØíÙQÉå%ѵÍlÁt($$$%%ÀÌØíÙQÉå%ѵÍlÀÌØí¹tôÀÌØíQÉå5ÍQ¡¸($$$$$ÀÌØíM¡½ÉÑ
ÕÐôÀÌØí¥±1¥ÍÑlÀÌØí¹t($$$$%á¥Ñ1½½À($$$%¹%($$%9áÐ($$%%ÀÌØíM¡½ÉÑ
ÕбÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($$$%5Í ½à ØаÅÕ½ÐíQÉä%Ñ´M±ÑÅÕ½Ðì°ÀÌØíM¡½ÉÑ
ÕФ($$%±Í($$$%
½¹Ñ¥¹Õ1½½À($$%¹%(%¹MÝ¥Ñ )]¹

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...