It is currently Thu May 23, 2013 5:38 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: could somebody double check me on aome autoit script?
PostPosted: Tue Apr 26, 2011 10:37 am 
Offline

Joined: Tue Mar 18, 2008 9:31 am
Posts: 62
Location: Maryland:haaha
Just wondering if somebody could look over my script for making MyPaint portable.
The folder layout can be found here:
http://www.mediafire.com/?xsf2ubd223cfeus
which also includes the program and full script.
The program fully works, I just wanted to make sure I didn't miss anything.

Code:
;If Running Quit
If ProcessExists("Mypaint.exe") Then
   MsgBox(0, "Warning", "Mypaint is already running!")
Else

   ;Splash Screen
   SPLASHIMAGEON("MyPaint Portable",@ScriptDir &"\app\info\splash.jpg",600,300 )
   SLEEP(0x05DC)
   SPLASHOFF()

   ;Backup Files
   FileCopy(@userprofiledir &"\.recently-used.xbel", @ScriptDir &"\data\backup\files", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint", @userprofiledir &"\Local Settings\Application Data\MyPaint1")

   ;Copy Settings Files
   FileCopy(@ScriptDir &"\data\settings\files", @userprofiledir &"\.recently-used.xbel", 1)
   DirMove(@ScriptDir &"\data\settings\files\MyPaint", @userprofiledir &"\Local Settings\Application Data\MyPaint")

   ;Run the App
   RunWait ( @ScriptDir &"\app\app\mypaint.exe" )

   ;Delete Settings
   DirRemove (@ScriptDir &"\data\settings", 1 )
   DirCreate (@ScriptDir &"\data\Settings")
   DirCreate (@ScriptDir &"\data\Settings\Files")
   DirCreate (@ScriptDir &"\data\Settings\Reg")


   ;Backup Settings Files
   FileCopy(@userprofiledir &"\.recently-used.xbel", @ScriptDir &"\data\settings\files", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint", @ScriptDir &"\data\settings\files\MyPaint")

   ;Apply Delete Reg
   FileDelete ( @userprofiledir &"\.recently-used.xbel" )

   ;Copy Backup Files
   FileCopy(@ScriptDir &"\data\backup\files", @userprofiledir &"\.recently-used.xbel", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint1", @userprofiledir &"\Local Settings\Application Data\MyPaint")

   ;Delete Backup
   DirRemove (@ScriptDir &"\data\Backup", 1 )
   DirCreate (@ScriptDir &"\data\Backup")
   DirCreate (@ScriptDir &"\data\Backup\Files")
   DirCreate (@ScriptDir &"\data\Backup\Reg")

EndIf


Top
 Profile  
 
 Post subject: Re: could somebody double check me on aome autoit script?
PostPosted: Tue Apr 26, 2011 10:58 am 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3729
Looks OK to me and it doesn't fail with AU3 Check! I would also add some error checking using @error. Did you want help with that?

I didn't download the file by the way, because I don't know where myPaint.exe is from?!

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: could somebody double check me on aome autoit script?
PostPosted: Tue Apr 26, 2011 11:25 am 
Offline

Joined: Tue Mar 18, 2008 9:31 am
Posts: 62
Location: Maryland:haaha
Sure if you wanted to. It's my first script with autoit and I didn't even think of error checking.
The mypaint.exe was from http://mypaint.intilinux.com/. I just installed the app and copied all the files into the /app/app folder.

*edit* was thinking of using inetget to download the installer and 7zip to extract it using the commandline.

and thanks by the way for taking the time


Top
 Profile  
 
 Post subject: Re: could somebody double check me on aome autoit script?
PostPosted: Tue Apr 26, 2011 12:43 pm 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3729
Quote:
*edit* was thinking of using inetget to download the installer and 7zip to extract it using the commandline.

I would do it like that as well, FileSize is 7.9MB. Have a look at these to get you started.

InetGet Example >> http://www.autoitscript.com/forum/topic ... _p__864490
7-Zip Example >> http://www.autoitscript.com/forum/topic ... _p__865508

Your Example with a little update >> included a Function that can reduce the memory whilst the process is running.
Code:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
Global $iPID

; If Running Quit
If ProcessExists("Mypaint.exe") Then
   MsgBox(0, "Warning", "Mypaint is already running!")
Else
   ; Splash Screen
   SplashImageOn("MyPaint Portable", @ScriptDir & "\app\info\splash.jpg", 600, 300)
   Sleep(0x05DC)
   SplashOff()

   ; Backup Files
   FileCopy(@UserProfileDir & "\.recently-used.xbel", @ScriptDir & "\data\backup\files", 1)
   DirMove(@UserProfileDir & "\Local Settings\Application Data\MyPaint", @UserProfileDir & "\Local Settings\Application Data\MyPaint1")

   ; Copy Settings Files
   FileCopy(@ScriptDir & "\data\settings\files", @UserProfileDir & "\.recently-used.xbel", 1)
   DirMove(@ScriptDir & "\data\settings\files\MyPaint", @UserProfileDir & "\Local Settings\Application Data\MyPaint")

   ; Run the App
   $iPID = Run(@ScriptDir & "\app\app\mypaint.exe")
   While ProcessExists($iPID)
      _ReduceMemory() ; Reduce the Memory of current PID, not used in RunWait. Normally memory is 11MB, not it will be 0.5MB!!
      Sleep(100)
   WEnd

   ; Delete Settings
   DirRemove(@ScriptDir & "\data\settings", 1)
   DirCreate(@ScriptDir & "\data\Settings")
   DirCreate(@ScriptDir & "\data\Settings\Files")
   DirCreate(@ScriptDir & "\data\Settings\Reg")


   ; Backup Settings Files
   FileCopy(@UserProfileDir & "\.recently-used.xbel", @ScriptDir & "\data\settings\files", 1)
   DirMove(@UserProfileDir & "\Local Settings\Application Data\MyPaint", @ScriptDir & "\data\settings\files\MyPaint")

   ; Apply Delete Reg
   FileDelete(@UserProfileDir & "\.recently-used.xbel")

   ; Copy Backup Files
   FileCopy(@ScriptDir & "\data\backup\files", @UserProfileDir & "\.recently-used.xbel", 1)
   DirMove(@UserProfileDir & "\Local Settings\Application Data\MyPaint1", @UserProfileDir & "\Local Settings\Application Data\MyPaint")

   ; Delete Backup
   DirRemove(@ScriptDir & "\data\Backup", 1)
   DirCreate(@ScriptDir & "\data\Backup")
   DirCreate(@ScriptDir & "\data\Backup\Files")
   DirCreate(@ScriptDir & "\data\Backup\Reg")
EndIf

Func _ReduceMemory() ; Only for the current process. Can be found on the AutoIt Forums.
   Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
   If @error Then
      Return SetError(1, 0, 0)
   EndIf
   Return $aReturn[0]
EndFunc   ;==>_ReduceMemory

Note: I can't really see a need for error checking right now as this is just for your use!!

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: could somebody double check me on aome autoit script?
PostPosted: Wed May 04, 2011 12:33 pm 
Offline

Joined: Tue Mar 18, 2008 9:31 am
Posts: 62
Location: Maryland:haaha
OK...so I've done a few things to the script this week.

Here's a link of the completed package:http://www.mediafire.com/?oaw677l02c9e95d

First I made it so the "DownloadFiles.exe" program downloads all the files, extracts them, moves files in proper places, deletes the installer and 7zip, and moves the "MyPaint Portable.exe" to the root folder from the app folder.

DownloadFiles:
Code:
#NoTrayIcon
MsgBox (0, "Downloader", "Please be paitent while MyPaint downloads." )
InetGet ("http://download.gna.org/mypaint/mypaint-0.9.1-win32-installer.exe", @ScriptDir &"\app\app\mpi.exe", 0 )
Runwait ( @ScriptDir &"\app\app\7z.exe x mpi.exe", @ScriptDir &"\app\app\", @SW_HIDE )
DirCreate ( @ScriptDir &"\App\App\lib\" )
DirCreate ( @ScriptDir &"\App\App\lib\gtk-2.0" )
DirCreate ( @ScriptDir &"\App\App\share" )
DirCreate ( @ScriptDir &"\App\App\share\icons" )
DirCreate ( @ScriptDir &"\App\App\share\themes" )
DirCreate ( @ScriptDir &"\App\App\etc" )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\classic", @ScriptDir &"\App\App\brushes\classic", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\deevad", @ScriptDir &"\App\App\brushes\deevad", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\experimental", @ScriptDir &"\App\App\brushes\experimental", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\ramon", @ScriptDir &"\App\App\brushes\ramon", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\tanda", @ScriptDir &"\App\App\brushes\tanda", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\gtk-2.0\2.10.0", @ScriptDir &"\App\App\lib\gtk-2.0\2.10.0", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\hicolor", @ScriptDir &"\App\App\share\icons\hicolor", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\MS-Windows", @ScriptDir &"\App\App\share\themes\MS-Windows", 1 )
DirMove ( @ScriptDir &"\App\App\$_OUTDIR\gtk-2.0", @ScriptDir &"\App\App\etc\gtk-2.0", 1 )
DirRemove ( @ScriptDir &"\App\App\$_OUTDIR", 1 )
DirRemove ( @ScriptDir &"\App\App\$PLUGINSDIR", 1 )
FileDelete ( @ScriptDir &"\App\App\7z.exe" )
FileDelete ( @ScriptDir &"\App\App\7z.Dll" )
FileDelete ( @ScriptDir &"\App\App\mpi.exe" )
FileMove ( @ScriptDir &"\App\MyPaint Portable.exe", @ScriptDir , 1 )
MsgBox (0, "Finished", "MyPaint portable is ready to run." )



MyPaint Portable:
Code:
#NoTrayIcon
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
Global $iPID

;If Running Quit
If ProcessExists("Mypaint.exe") Then
   MsgBox(0, "Warning", "Mypaint is already running!")
Else

   ;Splash Screen
   SPLASHIMAGEON("MyPaint Portable",@ScriptDir &"\app\info\splash.jpg",600,300 )
   SLEEP(0x05DC)
   SPLASHOFF()

   ;Backup Registry
   ;Run("regedit.exe /e backup1.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\backup\reg")
   ;Run("regedit.exe /e backup2.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\backup\reg")
   ;Run("regedit.exe /e backup3.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\backup\reg")

   ;Backup Files
   FileCopy(@userprofiledir &"\.recently-used.xbel", @ScriptDir &"\data\backup\files", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint", @userprofiledir &"\Local Settings\Application Data\MyPaint1")

   ;Apply Registry Settings
   ;Run("regedit.exe /s settings1.reg", @ScriptDir &"\data\settings\reg")
   ;Run("regedit.exe /s settings2.reg", @ScriptDir &"\data\settings\reg")
   ;Run("regedit.exe /s settings3.reg", @ScriptDir &"\data\settings\reg")

   ;Copy Settings Files
   FileCopy(@ScriptDir &"\data\settings\files", @userprofiledir &"\.recently-used.xbel", 1)
   DirMove(@ScriptDir &"\data\settings\files\MyPaint", @userprofiledir &"\Local Settings\Application Data\MyPaint")

   ;Run the App
   $iPID = Run(@ScriptDir & "\app\app\mypaint.exe")
   While ProcessExists($iPID)
      _ReduceMemory() ; Reduce the Memory of current PID, not used in RunWait. Normally memory is 11MB, not it will be 0.5MB!!
      Sleep(100)
   WEnd

   ;Delete Settings
   DirRemove (@ScriptDir &"\data\settings", 1 )
   DirCreate (@ScriptDir &"\data\Settings")
   DirCreate (@ScriptDir &"\data\Settings\Files")
   DirCreate (@ScriptDir &"\data\Settings\Reg")

   ;Backup Settings Registry
   ;Run("regedit.exe /e Settings1.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\settings\reg")
   ;Run("regedit.exe /e Settings2.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\settings\reg")
   ;Run("regedit.exe /e Settings3.reg HKEY_LOCAL_keypath, @ScriptDir &"\data\settings\reg")

   ;Backup Settings Files
   FileCopy(@userprofiledir &"\.recently-used.xbel", @ScriptDir &"\data\settings\files", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint", @ScriptDir &"\data\settings\files\MyPaint")

   ;Apply Delete Reg
   Run("regedit.exe /s Delete.reg", @ScriptDir &"\data")
   FileDelete ( @userprofiledir &"\.recently-used.xbel" )

   ;Apply Backup Registry
   ;Run("regedit.exe /s Backup1.reg", @ScriptDir &"\data\backup\reg")
   ;Run("regedit.exe /s Backup2.reg", @ScriptDir &"\data\backup\reg")
   ;Run("regedit.exe /s Backup3.reg", @ScriptDir &"\data\backup\reg")

   ;Copy Backup Files
   FileCopy(@ScriptDir &"\data\backup\files", @userprofiledir &"\.recently-used.xbel", 1)
   DirMove(@userprofiledir &"\Local Settings\Application Data\MyPaint1", @userprofiledir &"\Local Settings\Application Data\MyPaint")

   ;Delete Backup
   DirRemove (@ScriptDir &"\data\Backup", 1 )
   DirCreate (@ScriptDir &"\data\Backup")
   DirCreate (@ScriptDir &"\data\Backup\Files")
   DirCreate (@ScriptDir &"\data\Backup\Reg")

EndIf

Func _ReduceMemory() ; Only for the current process. Can be found on the AutoIt Forums.
   Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
   If @error Then
      Return SetError(1, 0, 0)
   EndIf
   Return $aReturn[0]
EndFunc   ;==>_ReduceMemory


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group