Run Box Replacement

08/14/2013 02:29 Liented#1
Here's a run box replacement. If you run a command the box will stay be displayed. Until you press ESC or cancel.

Changes:
added support for resolution: 1024x768
(but I added static positions, easier)
added Google search
To open a website enter this (example
Code:
$i www.autoitscript.com
Some other commands:
windir
sysdir
progdir
desktop
mydocs
$g keywords
$b|file(s)
First is the Windows directory.
Second is the system directory.
Third is the Program Files directory.
Fourth is the desktop folder
Fifth is the "My Documents" folder
Sixth is search on Google for keywords
Example:
Code:
$g James Bond
Last:
You can create backups of file(s). The backup will be placed in your windows directory, in a folder backup. With the extension .backup.
You can't backup files with no extension, but you can backup multiple files.
See examples below

Backup examples:
Code:
$b|desktop\important.doc
$b|C:\scripts\test.au3
$b|sysdir\*.exe
$b|progdir\AutoIt3\Examples\English\*.au3
Last:
You can create backups of file(s). The backup will be placed in your windows directory, in a folder backup. With the extension .backup.
You can't backup files with no extension, but you can backup multiple files.
See examples below
And it works perfect
Code:
$g_szVersion = "Commandbox"
If WinExists($g_szVersion) Then
WinActivate("Commandbox")
Exit
EndIf

AutoItWinSetTitle($g_szVersion)


AutoItSetOption("RunErrorsFatal", 0)

If @DesktopWidth = "1280" Then
  $pos = 810
Else
  $pos = 563
EndIf

$Command = InputBox("Commandbox", " ", "", "", 250, 110, 0, $pos)

If $Command <> "" Then
  While $Command <> ""
   Command($Command)
$Command = InputBox("Commandbox", " ", "", "", 250, 110, 0, $pos)
  WEnd
  Exit
Else
  Exit
EndIf

Func Command($Command)

;------------ Internet
$Match = StringInStr($Command, "$i")
If $Match > 0 Then $Command = StringReplace($Command, "$i", "iexplore")

;------------ Google
$Match = StringInStr($Command, "$g")
If $Match > 0 Then $Command = StringReplace($Command, "$g ", "iexplore www.google.com/search?q=")

;------------ System directories
$Sysdir = StringInStr($Command, "sysdir")
$Windir = StringInStr($Command, "windir")
$Progdir = StringInStr($Command, "progdir")
$Desktop = StringInStr($Command, "desktop")
$MyDocs = StringInStr($Command, "mydocs")

If $Windir > 0 Then $Command = StringReplace($Command, "windir", @WindowsDir)
If $Sysdir > 0 Then $Command = StringReplace($Command, "sysdir", @SystemDir)
If $Desktop > 0 Then $Command = StringReplace($Command, "desktop", FileGetShortName(@DesktopDir))
If $MyDocs > 0 Then $Command = StringReplace($Command, "mydocs", FileGetShortName(@MyDocumentsDir))
If $Progdir > 0 Then $Command = StringReplace($Command, "progdir", FileGetShortName(@ProgramFilesDir))

;------------ Backup
$Match = StringInStr($Command, "$b")
If $Match > 0 Then
Backup($Command)
Return
EndIf

Run($Command)
If @Error = 1 Then Run(@ComSpec & " /c Start " & $Command, "", @SW_HIDE)

EndFunc;---Run command

Func Backup($Command)
$Command = StringSplit($Command, "|")
$Backup = FileGetShortName($Command[2])

$Filename = StringSplit($Backup, "\")
$Filename = $Filename[$Filename[0]]

$Folder = @WindowsDir & "\backup"
DirCreate($Folder)
$Folder = $Folder & "\"

FileCopy($Backup, $Folder & $Filename & ".backup")

$Command = ""
EndFunc

Exit