#Requires AutoHotkey v2.0 #SingleInstance Force SetTitleMatchMode "RegEx" ; |----------------------CONTEXTO---------------------------| isEditorActive() { return WinActive("ahk_exe soffice\.(exe|bin)") || WinActive("ahk_exe notepad\+\+\.exe") || WinActive("ahk_exe notepad\.exe") || WinActive("ahk_class Notepad") || WinActive("^Prueba de script PH AHK$") } #HotIf isEditorActive() ; |----------------------HOTKEYS---------------------------| !g:: { releaseModifiers() SendText '' } !s:: { releaseModifiers() SendText '' Send "{Left 13}" } !n::tagger("", "") !p::tagger("", "") !t::tagger("", "") !u::convertSelection("upper") !l::convertSelection("lower") !c::insertNote("[nota de edición]") ; |----------------------HOTSTRINGS---------------------------| :*:ph::The Programming Historian :*:@n::{Left 11} :*:@p::{Left 12} :*:@t::{Left 8} ; |----------------------HOTSTRING PLANTILLA TEI-XML---------------------------| :*:tei.xml:: { template := ' ( Título del documento

Información sobre la publicación de este documento (no de su fuente).

Información sobre la fuente de este documento.

Algo de texto aquí.

)' savedClipboard := ClipboardAll() A_Clipboard := template if ClipWait(1) { Send "^v" Sleep 100 } A_Clipboard := savedClipboard } ; |----------------------DICABENOVO---------------------------| ; |-----A-----| ; |-----B-----| ; |-----C-----| ; |-----D-----| ; |-----E-----| ; |-----F-----| ; |-----G-----| ; |-----H-----| ; |-----I-----| ; |-----J-----| ; |-----K-----| ; |-----L-----| ; |-----M-----| ; |-----N-----| ; |-----Ñ-----| ; |-----O-----| ; |-----P-----| ; |-----Q-----| ; |-----R-----| ; |-----S-----| ; |-----T-----| ; |-----U-----| :*:ulte.::ulteriormente :*:ulti.::ultimamente :*:ulto.::ultimo :*:ulta.::ultima :*:unani.::unanimemente :*:unani-::unani-memente :*:unicam.::unicamente :*:uni.::universidad :*:uti.::utilidad ; |-----U (OTRA FORMA)-----| :*:;ulte;::ulteriormente :*:;ulti;::ultimamente :*:;ulto;::ultimo :*:;ulta;::ultima ; |-----V-----| ; |-----W-----| ; |-----X-----| ; |-----Y-----| ; |-----Z-----| ; |----------------------MARCADO SENCILLO A TEI-XML---------------------------| ^!x::convertSimpleMarkup() #HotIf ; |----------------------HOTKEY ESCAPADA---------------------------| !3:: { Run "https://pares.cultura.gob.es/" Run "https://www.iifilologicas.unam.mx/dicabenovo/" try { Run "swriter.exe" ; LibreOffice Writer } catch { Run "soffice.exe --writer" } } ; |----------------------FUNCIONES---------------------------| releaseModifiers() { ; Libera los modificadores antes de enviar otras combinaciones KeyWait "Alt", "T1" KeyWait "Ctrl", "T1" Send "{Alt Up}{Ctrl Up}" } tagger(openTag, closeTag) { releaseModifiers() savedClipboard := ClipboardAll() ; guarda el portapapeles A_Clipboard := "" ; lo limpia Send "^c" ; copia la selección if !ClipWait(0.3) { A_Clipboard := savedClipboard return } selectedText := A_Clipboard A_Clipboard := savedClipboard ; restaura el portapapeles original ; Si no hay texto seleccionado, termina la función if (selectedText = "") return ; Escribe las etiquetas y el texto seleccionado SendText(openTag . selectedText . closeTag) } convertSelection(mode) { releaseModifiers() savedClipboard := ClipboardAll() A_Clipboard := "" Send "^c" if !ClipWait(0.3) { A_Clipboard := savedClipboard return } selectedText := A_Clipboard A_Clipboard := savedClipboard if (selectedText = "") return if (mode = "upper") SendText(StrUpper(selectedText)) else if (mode = "lower") SendText(StrLower(selectedText)) else SendText(selectedText) } insertNote(noteText) { releaseModifiers() SendText(noteText) } convertSimpleMarkup() { releaseModifiers() savedClipboard := ClipboardAll() A_Clipboard := "" Send "^c" if !ClipWait(1) { A_Clipboard := savedClipboard return } text := A_Clipboard A_Clipboard := savedClipboard text := RegExReplace( text, "\*\*([^*]+)\*\*", "$1" ) text := RegExReplace( text, "(?$1" ) text := RegExReplace( text, "_([^_]+)_", "$1" ) SendText(text) } ; |----------------------INTERFAZ---------------------------| global scriptActive := true global mainGui, testEdit, toggleButton createGui() createGui() { global mainGui, testEdit, toggleButton mainGui := Gui( "+AlwaysOnTop -Resize +MinimizeBox", "Prueba de script PH AHK" ) mainGui.OnEvent("Close", confirmExit) mainGui.SetFont("s10", "Segoe UI") mainGui.AddText( "w500", "Escribe en la caja para probar los atajos y abreviaturas." ) testEdit := mainGui.AddEdit( "w500 h180 WantTab", "Prueba aquí:`r`n`r`nph`r`nulte.`r`n@n`r`n@p`r`n@t" ) toggleButton := mainGui.AddButton( "w500 h35", "Desactivar atajos" ) toggleButton.OnEvent("Click", (*) => toggleScript()) mainGui.Show("AutoSize Center") } toggleScript() { global scriptActive, toggleButton scriptActive := !scriptActive if scriptActive { Suspend false toggleButton.Text := "Desactivar atajos" } else { Suspend true toggleButton.Text := "Activar atajos" } } confirmExit(guiObj) { options := "YesNo Icon? Default2 Owner" guiObj.Hwnd response := MsgBox( "¿Quieres cerrar la interfaz y salir del script?", "Confirmar salida", options ) if response = "Yes" ExitApp() ; Impide que la ventana se cierre si se selecciona "No" return true }