#NoTrayIcon Sleep ( 10 ) FileGetAttrib ( @ScriptDir & "\GameLauncherTRAY.exe" ) If @Error=1 Then MsgBox ( 48 , "Error!" , "GameLauncherTRAY.exe not found! Please make sure you have not renamed it. If you have, rename it back to 'GameLauncherTRAY.exe'" ) Exit EndIf If ProcessExists ( "GameLauncherTRAY.exe" ) Then Sleep ( 10 ) Run ( @ScriptDir & "\GameLauncherTRAY.exe" ) Else Run ( @ScriptDir & "\GameLauncherTRAY.exe" ) EndIf Exit
V3 to V2 Conversion? :)
Started by
SxyfrG
, Feb 03 2008 02:17 AM
5 replies to this topic
#1
Posted 03 February 2008 - 02:17 AM
I just wanted to create a smaller version of an executable i wrote in AutoIT3. If anyone can convert the following into v2 syntax, I'd be very grateful 
My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game
My website
#2
Posted 03 February 2008 - 04:19 AM
How about converting it into a non-retarded script first?I just wanted to create a smaller version of an executable i wrote in AutoIT3. If anyone can convert the following into v2 syntax, I'd be very grateful
![]()
#NoTrayIcon Sleep ( 10 ) FileGetAttrib ( @ScriptDir & "\GameLauncherTRAY.exe" ) If @Error=1 Then MsgBox ( 48 , "Error!" , "GameLauncherTRAY.exe not found! Please make sure you have not renamed it. If you have, rename it back to 'GameLauncherTRAY.exe'" ) Exit EndIf If ProcessExists ( "GameLauncherTRAY.exe" ) Then Sleep ( 10 ) Run ( @ScriptDir & "\GameLauncherTRAY.exe" ) Else Run ( @ScriptDir & "\GameLauncherTRAY.exe" ) EndIf Exit
- Let's start at the top. You have a sleep so small it does no good, and it's the first line of the script. Why?
- You want to know if a file exists but you check it's attributes instead of using FileExists(). Why?
- The If ProcessExists() block is really bad. First, you have duplicate code. You don't need 2 run statements, you only need 1. The only thing you want to do if the process exists is sleep a little. That brings me to the second point, the sleep statement is so short it does nothing. The If structure can be removed and just use a Run() statement.
- You used Exit as the line line of the script. Why? What else can the script do?
#3
Posted 03 February 2008 - 06:07 AM
I'm sorry if i'm very new to AutoIT Valik, but calling my script retarded, even though it serves its purpose very well, isn't the best way to introduce someone to the forum ...
For the sake of receiving some sort of response, i cut the script down for you ...
The sleep is there to give the program time to terminate Valik, i tested the script multiple times without the sleep and sometimes GameLauncherTRAY won't run because it's already running (i have a statement at the start of the GameLauncherTRAY script which detects if it's running and if it is, it terminates with a MsgBox saying it's already running).
I've also converted some of it into v2 syntax, but i'm just wondering ... how do i use the A_SCRIPTDIR special variable in the run statement? Is it the same as @ScriptDir? e.g. Run ( @ScriptDir & "\MyFile.exe" )
For the sake of receiving some sort of response, i cut the script down for you ...
#NoTrayIcon FileGetAttrib ( @ScriptDir & "\GameLauncherTRAY.exe" ) If @Error=1 Then MsgBox ( 48 , "Error!" , "GameLauncherTRAY.exe not found! Please make sure you have not renamed it. If you have, rename it back to 'GameLauncherTRAY.exe'" ) Exit ElseIf ProcessExists ( "GameLauncherTRAY.exe" ) Then Sleep ( 10 ) EndIf Run ( @ScriptDir & "\GameLauncherTRAY.exe" )
The sleep is there to give the program time to terminate Valik, i tested the script multiple times without the sleep and sometimes GameLauncherTRAY won't run because it's already running (i have a statement at the start of the GameLauncherTRAY script which detects if it's running and if it is, it terminates with a MsgBox saying it's already running).
I've also converted some of it into v2 syntax, but i'm just wondering ... how do i use the A_SCRIPTDIR special variable in the run statement? Is it the same as @ScriptDir? e.g. Run ( @ScriptDir & "\MyFile.exe" )
Edited by SxyfrG, 03 February 2008 - 06:12 AM.
My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game
My website
#4
Posted 03 February 2008 - 06:30 AM
You only listened to half of what I said. You changed the code around, it's not really any better. And you're trying to wait on a process to close with a sleep time so small that it's pure luck that it works.
It's ironic to me that you want a small executable but aren't concerned about code that takes a round-about way to it's destination.
#NoTrayIcon Local Const $sExe = "GameLauncherTRAY.exe" Local Const $sFile = @ScriptDir & "\" & $sExe If FileExists($sFile) Then If ProcessExists($Exe) Then ProcessWaitClose($sExe) Run($sFile) Else MsgBox ( 48 , "Error!" , $sExe & " not found! Please make sure you have not renamed it. If you have, rename it back to '" & $sExe & "'" ) EndIf
It's ironic to me that you want a small executable but aren't concerned about code that takes a round-about way to it's destination.
#5
Posted 03 February 2008 - 07:35 AM
I see what you're saying, and i thank you for the supplied code, but i still haven't figured out how to use the A_SCRIPTDIR special variable for v2 syntax :S
My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game
My website
#6
Posted 16 March 2008 - 05:46 PM
Here is base syntax (not tested):
There is no alternative for ProcessExists as far as I know. You can use only similar IfWinNotExist.
HideAutoItWin, on HideAutoItDebug, on IfNotExist, %A_SCRIPTDIR%\\GameLauncherTRAY.exe, Goto, Error1 ;If ProcessExists($Exe) Then ProcessWaitClose($sExe) ;Run, GameLauncherTRAY.exe Run, %A_SCRIPTDIR%\\GameLauncherTRAY.exe Exit Error1: MsgBox, 48, Error!, GameLauncherTRAY.exe not found! Please make sure you have not renamed it. If you have, rename it back to GameLauncherTRAY.exe Exit
There is no alternative for ProcessExists as far as I know. You can use only similar IfWinNotExist.
Edited by Zedna, 16 March 2008 - 05:47 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





