could somebody double check me on aome autoit script?

If you are currently developing portable freeware or planning to do so, use this forum to discuss technical implementation, seek out like-minded developers for partnership, or solicit interested users for beta testing.
Post Reply
Message
Author
pplknownothin
Posts: 62
Joined: Tue Mar 18, 2008 9:31 am
Location: Maryland:haaha
Contact:

could somebody double check me on aome autoit script?

#1 Post by pplknownothin »

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: Select all

;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

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: could somebody double check me on aome autoit script?

#2 Post by guinness »

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?!

pplknownothin
Posts: 62
Joined: Tue Mar 18, 2008 9:31 am
Location: Maryland:haaha
Contact:

Re: could somebody double check me on aome autoit script?

#3 Post by pplknownothin »

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

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: could somebody double check me on aome autoit script?

#4 Post by guinness »

*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: Select all

#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!!

pplknownothin
Posts: 62
Joined: Tue Mar 18, 2008 9:31 am
Location: Maryland:haaha
Contact:

Re: could somebody double check me on aome autoit script?

#5 Post by pplknownothin »

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: Select all

#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: Select all

#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

Post Reply