Falls es jemand benutzen möchte.
Das Caret braucht ein Skelett an dem es sich orientieren kann. Es braucht also oberhalb ein leeres Zellengerüst z.B.:
Code: Select all
;| | | | |
Code: Select all
#IfWinActive ahk_class SciTEWindow
^r:: ;{ ;--helps to write the documentation for AHK-Rare
SetKeyDelay, 0, 0
SetBatchLines, -1
MarkDownApp:= "Typora" ;use your own documentation Softwaretitle here, this is for
MarkDownAppName:= "Typora" ;if name of window and app title doesnt match
Send, {Home}{Shift Down}{End}{Shift Up}
Send, {CTRL down}c{CTRL up}
ClipWait, 8
markedCode:= Clipboard
cutpos1:= Instr(markedCode, "`(")
cutpos2:= Instr(markedCode, "`)")
cutpos3:= Instr(markedCode, "`;--") + 2
txtforscript:= " " . SubStr(markedCode, 1, cutpos1) . "`)"
txtforMarkDownApp:= "**" . Trim(SubStr(markedCode, 1, cutpos1) . SubStr(markedCode, cutpos2, 2)) . "** " . SubStr(markedCode, cutpos3, StrLen(markedCode)-cutpos3+3)
MsgBox, 4, Inhalt des Clipboards, Text zum Einfügen ins AHK-Script:`n%txtforscript%`n---------------------------------------------------------------------------`nText zum Einfügen bei %MarkDownAppName%:`n%txtforMarkDownApp%`n---------------------------------------------------------------------------`n`nMöchtest Du weitermachen?
IfMsgBox, No
return
caretx:=A_CaretX, carety:=A_CaretY - 20
ToolTip, Setze jetzt den Curser in`nder Scripttabelle einfach in die richtige Zelle!.`nDie genaue Position ist egal!`n`nIch warte auf Strg+linke Maustaste`n!Tasten loslassen! zum Auslösen der Funktion.,%caretx%, %carety%, 11
;{ Wait for LeftMousebutton down & {LControl Down} and waits for releasing both keys
KeyWait, LControl, D
KeyWait, LButton, D
sleep, 100
KeyWait, LControl
KeyWait, LButton
;}
;this part can be removed - its for SciTE - You only lose the function controlling the number of columns in your table, so you have to manually control it
oSciTE := GetSciTEInstance()
if !oSciTE {
MsgBox, 16, SciTE4AutoHotkey, Cannot find SciTE!
ExitApp
}
hSciTE := oSciTE.SciTEHandle
ControlGet, scintillahwnd, Hwnd,, Scintilla1, ahk_id %hSciTE%
Pos:=SciUtil_GetCurPos(hSci)
thisline:= SciUtil_LineFromPos(hSci, Pos)
If (StrCount(thisline,"|")=4) { ;if you want more columns change 4 to what you need
Send, {ENTER}
SendRawFast(";|")
} else {
lastColumn:= Instr(thisline, "|", -1)
}
SendRawFast(txtforscript)
;{ The loop for space and tabs in your editor
SetKeyDelay, -1, -1
Loop {
Send, {Up}
Send, {LShift Down}{Right}{LShift Up}
Send, {CTRL Down}c{CTRL Up} ;goes up the line, selects the upper character
ClipWait, 8
If !(clipboard=="`|") { ;if no '|' add space to column
Send, {Down}
Send, {Space}
}
else { ;end it and send '|'
Send, {Down}
SendRaw, `|
Send, {Left 1}
Send, {BackSpace 2}
Send, {Tab}
Send, {End}
;~ Send, {Space 3} ;this spaces are not needed anymore
break
}
;}
SetKeyDelay, 20, 50
}
SetKeyDelay, 20, 50
ToolTip, Setze jetzt den Curser in`nTypora an die Einfügeposition.`n`nIch warte auf Strg+linke Maustaste`n!Tasten loslassen! zum Auslösen der Funktion.,%caretx%, %carety%, 11
WinWaitActive, %MarkDownApp%
;{ Wait for LeftMousebutton down & {LControl Down} and waits for releasing both keys
KeyWait, LControl, D
KeyWait, LButton, D
sleep, 100
KeyWait, LControl
KeyWait, LButton
;}
SetKeyDelay, 0, 0
WinGetActiveTitle, MarkDowner
If Instr(MarkDowner, MarkDownApp) {
SendRawFast(txtforMarkDownApp)
Send, {Enter} ;neue Zeile
Send, {Alt Down}s{AltUp} ;save entry to file
}
ToolTip, Okay ready.,%caretx%, %carety%, 11
sleep, 5000
ToolTip,,,, 11
return
;}
#IfWinActive
SendRawFast(string) {
SetKeyDelay, 0, 0
SendRaw, %string%
SetKeyDelay, 20, 50
}
So Bettzeit!