Jump to content

Have created 3 scripts


Solomon
 Share

Recommended Posts

With the help of the guys here, I created a script for cleaning up the My Documents folder on my sisters PC. She's now requested a few features that I've coded and tested. But, I actually have 3 separate scripts. They work fine individually, but I can't work out how to join them together into one compilable script.

Part 1 is the file moving script.

$activedir = IniRead("fm.ini", "dir", "active", "ValueNotFound")
FileChangeDir($activedir)
$audio = IniRead("fm.ini", "types", "audio","ValueNotFound")
$audiodir = IniRead("fm.ini", "dir", "audio", "valuenotfound")
$pic = IniRead("fm.ini", "types", "pic","ValueNotFound")
$picdir = IniRead("fm.ini", "dir", "pic", "valuenotfound")
$text = IniRead("fm.ini", "types", "text","ValueNotFound")
$textdir = IniRead("fm.ini", "dir", "text", "valuenotfound")
$process = IniRead("fm.ini", "process", "processname", "ValueNotFound")
$delay = Iniread("fm.ini", "process", "delay", "ValueNotFound")
while ProcessExists($process)
$audioArray = StringSplit ( $audio, "|" )
For $a = 1 To $audioArray[0]
   FileMove($audioArray[$a], $audiodir)
Next
$picarray = StringSplit ( $pic, "|")
For $p = 1 To $picarray[0]
   FileMove($picarray[$v], $picdir)
Next
$textarray = StringSplit ( $text, "|")
For $t = 1 To $textarray[0]
   FileMove($textarray[$s], $textdir)
Next
Sleep($delay)
WEndoÝ÷ Ù8b±¶¬Æ¥)¨½ëW­¢Ø^rëyË_¢W^®ÆÚ±çhÜ©y(^j[(0j{l¶y«n­ë-¡·nW­¢ÈnµÚ0Ø^

(Part 3 is for the most part copied from the help file.)

What I'd like to know is how to put all these together in one script so that I can compile it, and get all the functionality. I've tried putting them all in the same script, and running it, but I only seem to get 1 functionality (the file moving part, for example) working at a time. :"> This is the first time I've done something like this (adding multiple functionalities to a script) and I'm having trouble finding a guide as to how the script should be laid out. I'm really curious as to why (and how) the script should be laid out in a certain way, but I can't find anything. :">

Anyone who can point me in the right direction will get my undying gratitude. :)

Link to comment
Share on other sites

maybe...

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode", 1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$audio = TrayCreateItem("Audio Dir")
TrayCreateItem("")
$picture = TrayCreateItem("Picture Dir")
TrayCreateItem("")
$text = TrayCreateItem("Text Dir")
TrayCreateItem("")
$Copyitem = TrayCreateItem("Copy Folders")
TrayCreateItem("")
$Shutdownitem = TrayCreateItem("Shutdown")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $audio
            Run("explorer.exe" & " /root,d:\my docs\my music")
        Case $msg = $picture
            Run("explorer.exe" & " /root,d:\my docs\my pictures")
        Case $msg = $text
            Run("explorer.exe" & " /root,d:\my docs\my texts")
        Case $msg = $exititem
            ExitLoop
        Case $msg = $Copyitem
            Set_Copy()
        Case $msg = $Shutdownitem
            Set_Shutdown()
    EndSelect
WEnd

Func Set_Copy()
    $activedir = IniRead("fm.ini", "dir", "active", "ValueNotFound")
    FileChangeDir($activedir)
    $audio = IniRead("fm.ini", "types", "audio", "ValueNotFound")
    $audiodir = IniRead("fm.ini", "dir", "audio", "valuenotfound")
    $pic = IniRead("fm.ini", "types", "pic", "ValueNotFound")
    $picdir = IniRead("fm.ini", "dir", "pic", "valuenotfound")
    $text = IniRead("fm.ini", "types", "text", "ValueNotFound")
    $textdir = IniRead("fm.ini", "dir", "text", "valuenotfound")
    $process = IniRead("fm.ini", "process", "processname", "ValueNotFound")
    $delay = IniRead("fm.ini", "process", "delay", "ValueNotFound")
    While ProcessExists($process)
        $audioArray = StringSplit($audio, "|")
        For $a = 1 To $audioArray[0]
            FileMove($audioArray[$a], $audiodir)
        Next
        $picarray = StringSplit($pic, "|")
        For $p = 1 To $picarray[0]
            FileMove($picarray[$p], $picdir)
        Next
        $textarray = StringSplit($text, "|")
        For $t = 1 To $textarray[0]
            FileMove($textarray[$t], $textdir)
        Next
        Sleep($delay)
    WEnd
EndFunc   ;==>Set_Copy

Func Set_Shutdown()    
    $Dir = IniRead("fm.ini", "shutdown", "dir", "ValueNotFound")
    $Shutdown = IniRead("fm.ini", "shutdown", "shutdown", "ValueNotFound")
    $delay = IniRead("fm.ini", "shutdown", "delay", "ValueNotFound")
    While FileExists($Dir & "\*.*")
        Sleep($delay)
    WEnd
    Sleep(60000)
    If $Shutdown = "9" Then Shutdown(9)
    If $Shutdown = "32" Then Shutdown(32)
    If $Shutdown = "64" Then Shutdown(64)    
EndFunc   ;==>Set_Shutdown

8)

NEWHeader1.png

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...