How to remove characters, without english letters??

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

How to remove characters, without english letters??

Post by hancre » 26 Jul 2021, 02:39

I want to remove characters, without english letters.

I found a few scripts for the task.
all the scripts make me put the text in the code.
ex.

v2_text = 123dfs@♥ ♧ ♣ ⊙ ◈ ▣ abcdASDF`!`@`#`$`%
v2 := RegExReplace(v2_text, "[^a-zA-Z0-9]")
MsgBox % v2

I want to do it by a hotkey in other text editors ( ms-word, google document, notepad and others ).

How can I get the results ?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to remove characters, without english letters??

Post by swagfag » 26 Jul 2021, 04:12

conceptually
  1. get the text u want to make changes to. use whatever method u prefer/are familiar with/is available(clipboard, messages, Accessibility, other available custom APIs provided)
  2. alter the retrieved text according to ur needs(u already got the regex for doing just that)
  3. paste/replace the text back into the target application. use whatever method u prefer/are familiar with/is available(clipboard, messages, Accessibility, other available custom APIs provided)

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to remove characters, without english letters??

Post by hancre » 26 Jul 2021, 06:08

@swagfag I want to get the result without copy & paste by a hotkey.
getting the result isn't possible ? ^^

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to remove characters, without english letters??

Post by boiler » 26 Jul 2021, 12:23

Why wouldn’t you want to use copy and paste with a hotkey? You can have one hotkey do both and also restore the previous contents of the clipboard, so it’s not like you would even know it used copy/paste (unless you check clipboard history).

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to remove characters, without english letters??

Post by hancre » 26 Jul 2021, 20:49

@boiler Ok. Reading the first reply carefully, I found it's available.
I understand the concept of code.

but I can't make it by myself.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to remove characters, without english letters??

Post by boiler » 26 Jul 2021, 21:02

With the code below, you would highlight the text you want to replace, then press Ctrl+Tab. It uses the RegEx pattern you suggested. It will also remove things like spaces and tabs, so if you want to keep things like that, they would have to be added.

Code: Select all

^Tab::
	Clipboard := ClipSave
	Clipboard := ""
	Send, ^c
	ClipWait, 1
	if ErrorLevel
		return
	Clipboard := RegExReplace(Clipboard, "[^a-zA-Z0-9]")
	Send, ^v
	Sleep, 500
	ClipSave := Clipboard
return

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to remove characters, without english letters??

Post by hancre » 28 Jul 2021, 00:40

@boiler
Thanks a lot.
It helps my problem fastly.

I replaced "[^a-zA-Z0-9]") to "[^a-zA-Z0-9_ \n]") to keep space. ^^

Post Reply

Return to “Ask for Help (v1)”