Code: Select all
;Win+z Test
#z::
Text:=""
Clipboard:=""
SendInput, ^a
SendInput, ^c
Text:=Clipboard
Clipboard:=""
;two spaces
Text:=StrReplace(Text, "m) "," ")
Clipboard:=Text
SendInput ^a
SendInput ^v
Sendinput, ^{Home}
Return
Code: Select all
;Win+z Test
#z::
Text:=""
Clipboard:=""
SendInput, ^a
SendInput, ^c
Text:=Clipboard
Clipboard:=""
;two spaces
Text:=StrReplace(Text, "m) "," ")
Clipboard:=Text
SendInput ^a
SendInput ^v
Sendinput, ^{Home}
Return
Code: Select all
Text: = RegexReplace(Text,"m) "," ")
Text: = StrReplace(Text," "," ")
Text = StrReplace(Text," "," ")
Text: = StrReplace(%Text%," "," ")
Text = StrReplace(Text," ",A_Space)
Code: Select all
StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]
Code: Select all
Text := RegExReplace(Text,"m)\s\s"," ") ; read the regex quickref below
Code: Select all
Text: = RegExReplace(Text,"m) "," ") ; invalid, space between : =
Text: = StrReplace(Text," "," ") ; invalid, space between : =
Text = StrReplace(Text," "," ") ; invalid because you lack : in :=
Text: = StrReplace(%Text%," "," ") ; invalid because you use %% and no space between : =
Text = StrReplace(Text," ",A_Space) ; invalid because you lack : in :=
I think it's the same as Autohotkey.TextPad's regular expression syntax is based on that used by the programming language Perl. It is synonymous with ECMAScript and JavaScript regular expressions.
Code: Select all
;Win+z Test
#z::
Text= ""
Clipboard= ""
SendInput, ^a
SendInput, ^c
Text:= Clipboard
Clipboard= ""
;clean Regex chars
Text:= RegExReplace(Text,"m)\s\s"," ")
;two spaces
Text:= StrReplace(Text, " "," ")
Clipboard:= Text
SendInput ^a
SendInput ^v
Sendinput, ^{Home}
Return
Code: Select all
#Z::
Clipboard := ""
Send, ^a^c
Double_Space := A_Space . A_Space
Single_Space := A_Space
Clipboard := StrReplace(Clipboard, Double_Space, Single_Space)
Send, ^v^{Home}
Return
Code: Select all
;Win+z Test
#z::
Clipboard := ""
Send, ^a^c
;strip space preceeding mdash
in_put := " —"
out_put := "—"
Clipboard := StrReplace(Clipboard, in_put, out_put)
;strip space following mdash
in_put := "— "
out_put := "—"
Clipboard := StrReplace(Clipboard, in_put, out_put)
;strip double curly braces surrounding mdash from previous script action to avoid {{{{—}}}}
in_put := "{{—}}"
out_put := "—"
Clipboard := RegexReplace(Clipboard, in_put, out_put)
;surround mdash with double curly braces
in_put := "—"
out_put := "{{—}}"
Clipboard := StrReplace(Clipboard, in_put, out_put)
Send, ^v^{Home}
Return
Code: Select all
temp := Clipboard
temp := StringReplace(temp, in_put, out_put)
temp := StringReplace(temp, in_put, out_put)
Clipboard := temp
Code: Select all
FileEncoding cp0 ; Reset the default just in case.
MsgBox % "File encoding: " FileOpen(A_ScriptFullPath, "r").Encoding
. "`nSystem default ANSI codepage: CP" DllCall("GetACP")
Code: Select all
MsgBox % Asc(Clipboard) ; Returns the first ANSI byte or UTF-16 code unit of Clipboard.
I'd recommend using #NoEnv in all scripts, but this is one case where it's especially important. If you don't use #NoEnv and temp happens to be empty, it will return the value of the TEMP environment variable instead.berban wrote:temp variable
Code: Select all
#Include D:\AHKFunctionsLibrary\SearchAndReplace.ahk
#InstallKeybdHook
#NoEnv ;Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ;Enable warnings to assist with detecting common errors.
AutoTrim, Off
;Alt+m em dash —
!m::
;Send, {Asc 0151}
Send, {u+2014}
Return
Code: Select all
text:="some test with — an mdash"
in_put := "—"
out_put := "{{—}}"
MsgBox % StrReplace(Text, in_put, out_put) ; will show some test with {{—}} an mdash
Users browsing this forum: Bing [Bot], TAC109 and 143 guests