Editor del menú contextual para archivos .ahk || 22/11/2015

Compartir enlaces, herramientas y otros recursos de Internet que puedan ser útiles para programar en AutoHotkey
User avatar
Flipeador
Posts: 1018
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Editor del menú contextual para archivos .ahk || 22/11/2015

Post by Flipeador » 15 Oct 2015, 22:19

Image

Code: Select all

if (FileExist(A_Desktop "\backup_ahkcm1.reg")) || (FileExist(A_Desktop "\backup_ahkcm2.reg")) {
	MsgBox, 4148,, se han encontrado uno o mas archivos de copia de seguridad:`n%A_Desktop%\backup_ahkcm1.reg`n%A_Desktop%\backup_ahkcm2.reg`n`n¿desea volver a hacer una copia de seguridad sobreescribiendo estos achivos?.
	IfMsgBox, No
		goto, Init
} Run, %A_WinDir%\regedit.exe -e "%A_Desktop%\backup_ahkcm2.reg" "HKEY_LOCAL_MACHINE\Software\Classes\.ahk",, UseErrorLevel
Run, %A_WinDir%\regedit.exe -e "%A_Desktop%\backup_ahkcm1.reg" "HKEY_CLASSES_ROOT\AutoHotkeyScript",, UseErrorLevel
if !(ErrorLevel)
	MsgBox, 4160,, se guardó una copia de seguridad en el escritorio.`n%A_Desktop%\backup_ahkcm1.reg`n%A_Desktop%\backup_ahkcm2.reg
Init:
#SingleInstance Force
Gui, 1:New, +HWND_G +Disabled, AutoHotKey %A_AhkVersion%
Gui, Font, Q5
Gui, Add, Text, x20 y20 w560 h15, Ruta de AutoHotKey por defecto:
Gui, Add, GroupBox, x10 y5 w585 h180 c0x5151FF, General
Gui, Add, Edit, x25 y35 w505 h20 +ReadOnly vE1 gEN
Gui, Add, Button, x530 y35 w50 h20 gB1, ...
Gui, Add, Text, x25 y95 w560 h15, Editor:
Gui, Add, Edit, x30 y110 w500 h20 vE4 gEN
Gui, Add, Button, x530 y110 w50 h20 gB3, ...
Gui, Add, Text, x30 y140 w50 h15, Nombre:
Gui, Add, Edit, x85 y135 w195 h20 vE5 gEN
Gui, Add, Text, x295 y140 w40 h15, Icono:
Gui, Add, Edit, x340 y135 w190 h20 vE6 gEN
Gui, Add, Button, x530 y135 w50 h20 gB4, ...
Gui, Add, Text, x25 y65 w50 h15, Nombre:
Gui, Add, Edit, x70 y60 w195 h20 vE2 gEN
Gui, Add, Text, x290 y65 w40 h15, Icono:
Gui, Add, Edit, x335 y60 w195 h20 vE3 gEN
Gui, Add, Button, x530 y60 w50 h20 gB2, ...
Gui, Add, Text, x25 y165 w145 h15, Acción al hacer doble clic:
Gui, Add, Radio, x180 y165 w120 h15 vR1 gEN, Ejecutar Script
Gui, Add, Radio, x340 y165 w120 h15 vR2 gEN, Editar Script
Gui, Add, GroupBox, x10 y185 w585 h145 c0x5151FF, Ejecutar
Gui, Add, Checkbox, x20 y235 w180 h15 vCB2 gEN, Ejecutar script (Unicode 32-Bit):
Gui, Add, Checkbox, x20 y210 w180 h13 vCB1 gEN, Ejecutar script (Ansi)
Gui, Add, Edit, x200 y205 w330 h20 vE7 gEN
Gui, Add, Button, x530 y205 w50 h20 gB5, ...
Gui, Add, Edit, x200 y230 w330 h20 vE8 gEN
Gui, Add, Button, x530 y230 w50 h20 gB6, ...
Gui, Add, Checkbox, x20 y285 w180 h13 vCB4 gEN, Ejecutar script (v2 Alpha)
Gui, Add, Edit, x200 y255 w330 h20 vE9 gEN
Gui, Add, Button, x530 y255 w50 h20 gB7, ...
Gui, Add, Checkbox, x20 y260 w180 h13 vCB3 gEN, Ejecutar script (Unicode 64-Bit)
Gui, Add, Edit, x200 y280 w330 h20 vE10 gEN
Gui, Add, Button, x530 y280 w50 h20 gB8, ...
Gui, Add, GroupBox, x10 y330 w585 h115 c0x5151FF, Compilar
Gui, Add, Button, x490 y450 w105 h25 Disabled vAP gSave, Aplicar
Gui, Add, Button, x380 y450 w105 h25 gGuiClose, Cancelar
Gui, Add, Button, x270 y450 w105 h25 gGuiClose, Aceptar
Gui, Add, Checkbox, x20 y375 w180 h15 vCB6 gEN, Compilar (Unicode 32-Bit):
Gui, Add, Checkbox, x20 y400 w180 h15 vCB7 gEN, Compilar (Unicode 64-Bit):
Gui, Add, Checkbox, x20 y350 w180 h15 vCB5 gEN, Compilar (Ansi):
Gui, Add, Edit, x200 y345 w330 h20 vE12 gEN
Gui, Add, Button, x530 y345 w50 h20 gB10 Disabled, ...
Gui, Add, Edit, x200 y395 w330 h20 vE14 gEN
Gui, Add, Button, x530 y370 w50 h20 gB11 Disabled, ...
Gui, Add, Edit, x200 y370 w330 h20 vE13 gEN
Gui, Add, Button, x530 y395 w50 h20 gB12 Disabled, ...
Gui, Add, Text, x20 y310 w50 h15, Icono:
Gui, Add, Edit, x200 y305 w330 h20 vE11 gEN
Gui, Add, Button, x530 y305 w50 h20 gB9, ...
Gui, Add, Text, x20 y425 w50 h15, Icono:
Gui, Add, Edit, x200 y420 w330 h20 vE15 gEN
Gui, Add, Button, x530 y420 w50 h20 gB13 Disabled, ...
Gui, Show, w603 h480 Hide
DllCall("User32.dll\AnimateWindow", "Ptr", _G, "UInt", 200, "UInt", 0x00020000+0x00080000)
WinSet, Redraw,, ahk_id %_G%
gosub, Load
Gui, -Disabled
return
GuiEscape:
GuiClose:
DllCall("User32.dll\AnimateWindow", "Ptr", _G, "UInt", 200, "UInt", 0x00010000+0x00080000)
ExitApp
return
Load:
Gui, +OwnDialogs
GuiControlGet, E1
if !(E1) {
	SplitPath, A_AhkPath,, OutputVar
	ahkexe := OutputVar "\AutoHotKey" (A_IsUnicode?(A_PtrSize=8?"U64":"U32"):"A32") ".exe"
	if !(FileExist(ahkexe)) {
		GuiControl, Disable, AP
		MsgBox, 4144,, %ahkexe%`nno existe`, verifique la ruta de instalación de AutoHotKey!.
	} else {
		FileGetVersion, ahkversion, %ahkexe%
		WinSetTitle, ahk_id %_G%,, AutoHotKey %ahkversion%	
}} else ahkexe := GetValidPathName(E1)
GuiControl,, E1, %ahkexe%
RegRead, OutputVar, HKCR\AutoHotkeyScript\Shell\Open
if (ErrorLevel)
	OutputVar := "Open"
GuiControl,, E2, %OutputVar%
RegRead, OutputVar, HKCR\AutoHotkeyScript\DefaultIcon
if (ErrorLevel)
	OutputVar := ahkexe
GuiControl,, E3, %OutputVar%
RegRead, Editor, HKCR\AutoHotkeyScript\Shell\Edit\Command
GuiControl,, E4, %Editor%
RegRead, OutputVar, HKCR\AutoHotkeyScript\Shell\Edit
if (ErrorLevel)
	OutputVar := "Edit"
GuiControl,, E5, %OutputVar%
RegRead, OutputVar, HKCR\AutoHotkeyScript\Shell\Edit, Icon
if (ErrorLevel)
	OutputVar := Editor
GuiControl,, E6, %OutputVar%
RegRead, OutputVar, HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell
GuiControl,, % "R" (OutputVar="Edit"?2:1), 1
Loop, Parse, % "Open,OpenA32,OpenU32,OpenU64,OpenH", `,
	RegRead, OutputVar, HKCR\AutoHotkeyScript\Shell\%A_LoopField%, Icon
until !(ErrorLevel)
GuiControl,, E11, %OutputVar%
Loop, Parse, % "Compile,CompileA32,CompileU32,CompileU64", `,
	RegRead, OutputVar, HKCR\AutoHotkeyScript\Shell\%A_LoopField%, Icon
until !(ErrorLevel)
GuiControl,, E15, %OutputVar%
SplitPath, ahkexe,, ahkdir
GuiControl,, E7, "%ahkdir%\AutoHotKeyA32.exe" "`%1" `%*
GuiControl,, E8, "%ahkdir%\AutoHotKeyU32.exe" "`%1" `%*
GuiControl,, E9, "%ahkdir%\AutoHotKeyU64.exe" "`%1" `%*
GuiControl,, E12, "%ahkdir%\Compiler\Ahk2Exe.exe" /in "`%l" /mpress 1 /bin "%ahkdir%\Compiler\ANSI 32-bit.bin"
GuiControl,, E13, "%ahkdir%\Compiler\Ahk2Exe.exe" /in "`%l" /mpress 1 /bin "%ahkdir%\Compiler\Unicode 32-bit.bin"
GuiControl,, E14, "%ahkdir%\Compiler\Ahk2Exe.exe" /in "`%l" /mpress 1 /bin "%ahkdir%\Compiler\Unicode 64-bit.bin"
return
Save:
if !(FileExist(ahkexe)) {
	Gui, +OwnDialogs
	MsgBox, 4144,, %ahkexe%`nno existe`, verifique la ruta de instalación de AutoHotKey!.
	return
} Gui, +Disabled
GuiControl, Disable, AP
GuiControlGet, E2
RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open,, % Trim(E2)
RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open\Command,, %ahkexe% "`%1" `%*
GuiControlGet, E3
if (E3="")
	RegDelete, HKCR\AutoHotkeyScript\DefaultIcon
else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\DefaultIcon,, % Trim(E3)
GuiControlGet, E4
if (E4="") {
	RegDelete, HKCR\AutoHotkeyScript\Shell\Edit
} else {
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Edit\Command,, % Trim(E4)
	GuiControlGet, E5
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Edit,, % Trim(E5)
	GuiControlGet, E6
	if (E6="")
		RegDelete, HKCR\AutoHotkeyScript\Shell\Edit, Icon
	else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Edit, Icon, % Trim(E6)
} GuiControlGet, E11
if (E11="")
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open, Icon, %ahkexe%
else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open, Icon, % Trim(E11)
GuiControlGet, CB1
if (CB1) {
	GuiControlGet, E7
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenA32,, % Trim(E2) " (A32)"
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenA32\Command,, % Trim(E7)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenA32, Icon, % Trim(E11)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\OpenA32
GuiControlGet, CB2
if (CB2) {
	GuiControlGet, E8
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU32,, % Trim(E2) " (U32)"
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU32\Command,, % Trim(E8)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU32, Icon, % Trim(E11)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\OpenU32
GuiControlGet, CB3
if (CB3) {
	GuiControlGet, E9
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU64,, % Trim(E2) " (U64)"
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU64\Command,, % Trim(E9)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenU64, Icon, % Trim(E11)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\OpenU64
GuiControlGet, CB4
if (CB4) {
	GuiControlGet, E10
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenH,, % Trim(E2) " (Alpha)"
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenH\Command,, % Trim(E10)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\OpenH, Icon, % Trim(E11)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\OpenH
GuiControlGet, R1
if (CB1) || (CB2) || (CB3) || (CB4) {
	RegDelete, HKCR\AutoHotkeyScript\Shell\Open
	SplitPath, ahkexe, Filename
	if (R1)
		RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell,, % "Open" (Filename="AutoHotkeyA32.exe"&&CB1?"A32":A_Is64bitOS&&CB3?"U64":CB2?"U32":CB1?"A32":"Alpha")
	else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell,, Edit
} else {
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open,, % Trim(E2)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open\Command,, "%ahkexe%" "`%1" `%*
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Open, Icon, % Trim(E11)
	if (R1)
		RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell,, Open
	else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell,, Edit
} GuiControlGet, E15
if (E15="")
	RegDelete, HKCR\AutoHotkeyScript\Shell\Compile, Icon
else RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Compile, Icon, % Trim(E15)
GuiControlGet, CB5
if (CB5) {
	GuiControlGet, E12
	SplitPath, E12, Filename
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileA,, Compile (A32)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileA\Command,, % Trim(E12)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileA, Icon, % Trim(E15)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\CompileA
GuiControlGet, CB6
if (CB6) {
	GuiControlGet, E13
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU32,, Compile (U32)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU32\Command,, % Trim(E13)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU32, Icon, % Trim(E15)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\CompileU32
GuiControlGet, CB7
if (CB7) {
	GuiControlGet, E14
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU64,, Compile (U64)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU64\Command,, % Trim(E14)
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\CompileU64, Icon, % Trim(E15)
} else RegDelete, HKCR\AutoHotkeyScript\Shell\CompileU64
if (CB5) || (CB6) || (CB7)
	RegDelete, HKCR\AutoHotkeyScript\Shell\Compile
else {
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Compile\Command,, "%ahkdir%\Compiler\Ahk2Exe.exe" /in "`%l" /mpress 1
	RegWrite, REG_SZ, HKCR\AutoHotkeyScript\Shell\Compile, Icon, % Trim(E15)
} RegDelete, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ahk
RegDelete, HKLM\Software\Classes\.ahk
RegWrite, REG_SZ, HKLM\Software\Classes\.ahk,, AutoHotkeyScript
RegWrite, REG_SZ, HKLM\Software\Classes\.ahk\ShellNew, FileName, Template.ahk
RegDelete, HKCU\Software\Classes\.ahk
Gui, -Disabled
return
B1:
GuiControlGet, E1
if (Change(E1, "E1", false))
	gosub, Load
return
B2:
GuiControlGet, E3
Change(E3, "E3")
return
B3:
GuiControlGet, E4
Change(E4, "E4", false)
return
B4:
GuiControlGet, E6
Change(E6, "E6",, false)
return
B5:
GuiControlGet, E7
Change(E7, "E7", false,, "%*")
return
B6:
GuiControlGet, E8
Change(E8, "E8", false,, "%*")
return
B7:
GuiControlGet, E9
Change(E9, "E9", false,, "%*")
return
B8:
GuiControlGet, E10
Change(E10, "E10", false,, "%*")
return
B9:
GuiControlGet, E11
Change(E11, "E11",, false)
return
B10:
GuiControlGet, E12
Change(E12, "E12", false, "/in", Chr(34) "%l" Chr(34), false)
return
B11:
GuiControlGet, E13
Change(E13, "E13", false, "/in", Chr(34) "%l" Chr(34), false)
return
B12:
GuiControlGet, E14
Change(E14, "E14", false, "/in", Chr(34) "%l" Chr(34), false)
return
B13:
GuiControlGet, E15
Change(E15, "E15",, false)
return
EN:
SetTimer, EN2, -500
return
EN2:
if !(FileExist(ahkexe))
	GuiControl, Disable, AP
else GuiControl, Enable, AP
return
Change(Filename, Var, Mode := true, Prefix := "%1", Sub := "", Ch := true) {
	global
	Gui, +OwnDialogs
	try FileSelectFile, OutputVar, 3, % GetValidPathName(Filename),, Iconos (*.exe;*.ico)
	catch
		FileSelectFile, OutputVar, 3,,, Iconos (*.exe;*.ico)
	if !(ErrorLevel) {
		SplitPath, OutputVar,,, Ext
		GuiControl,, %Var%, % (Mode?(OutputVar (Ext="ico"?"":(Prefix?",1":""))):(Chr(34) OutputVar Chr(34) A_Space (Ch?Chr(34):"") Prefix (Ch?Chr(34):"") A_Space Sub))
		GuiControl, Enable, AP
		return true
}} GetValidPathName(Filename) {
	Filename := Trim(RegExReplace(Filename, "[\Q*/?" Chr(34) "<>|`n\E]"))
	if (IsFile(Filename))
		return Filename, ErrorLevel := false
	if IsFile(i:=SubStr(Filename, 1, InStr(Filename, A_Space)-1))
		return i, ErrorLevel := 0
	Loop, Parse, % Filename, %A_Space%, %A_Tab%
	{ _ .= (A_Index=1?"":" ") A_LoopField 
		if (IsFile(_))
			return _, ErrorLevel := false
	} return Filename, ErrorLevel := true
} IsFile(Filename) {
	return (!InStr(i:=FileExist(Filename),"D")&&i)
}

Return to “Otras Utilidades y Recursos”