Page 1 of 2

i need a script for only the alphabet

Posted: 05 Mar 2024, 15:47
by vanove
I want that only the alphabet keyboards will work, when i use this script, but in a hungarian keyboard ...

Im a hungarian poet, and im a mess when im writing so ... im always end up writing to the ..ing nowhere, in the middle of the night, and there is nothing in the monitor, because an hour ago i pushed some not alphabetic keyboard, probably the worst one, and after that some other, so, thats the problem.

can i use v1 or v2 for this?

Re: i need a script for only the alphabet

Posted: 05 Mar 2024, 19:26
by mikeyww
Welcome to this AutoHotkey forum!

Are you really referring to keyboards, or just keys?

Code: Select all

#Requires AutoHotkey v2.0
ih := InputHook('V')
ih.KeyOpt('{All}', 'S')
ih.KeyOpt('abcdefghijklmnopqrstuvwxyz{LShift}{RShift}', '-S')
ih.Start
Well, I don't know, but this seems like a pretty tough way to write poetry. On the other hand, I'm not a poet!

Re: i need a script for only the alphabet

Posted: 06 Mar 2024, 15:20
by vanove
hi! thanx to the answer!

yeh, i mean the alphabet keys in the keyboard ...

and yeh u are right, i need the enter and the space key too, and this three ? , .

maybe thats enough

and some hungarian alphabet caracter too: ö,ü,ó,é,á,ű,í,ú

thanx for the help!

Re: i need a script for only the alphabet

Posted: 06 Mar 2024, 17:19
by kunkel321
I think you can just add them to the list that Mike already made... Like this:

Code: Select all

ih.KeyOpt('abcdefghijklmnopqrstuvwxyz{LShift}{RShift}{Space}?{,}öüóéáűíú.', '-S')
I think braces need to go around the comma {,} but I'm not sure. Try it and see if it works.

Here is the help section:
https://www.autohotkey.com/docs/v2/lib/InputHook.htm#KeyOpt

EDIT: I tried it, and the comma does work. Here, I added Ctrl and Esc, to make it easier to end the script if you need to. Also Enter, so you can make new paragraphs. LOL. You can add/remove different keys that you need/don't need.

Code: Select all

#SingleInstance
#Requires AutoHotkey v2.0

ih := InputHook('V')
ih.KeyOpt('{All}', 'S')
ih.KeyOpt('abcdefghijklmnopqrstuvwxyz{LShift}{RShift}{Space}{Enter}{Ctrl}{Esc}?{,}öüóéáűíú.', '-S')
ih.Start

^Esc::ExitApp  ; Ctrl+Esc exits script

Re: i need a script for only the alphabet

Posted: 06 Mar 2024, 17:44
by vanove
thx, i will try it!

Re: i need a script for only the alphabet

Posted: 20 Mar 2024, 21:07
by vanove
so i tried the program , the "enter" for some reason doesnt work, and maybe the arrows will be good, if they will be in active mode, but dont know how to write it in the script

other than that the sript works fine ...

sorry for the late answer, but didnt have too much "good mood" to do anything till now ...

Re: i need a script for only the alphabet

Posted: 20 Mar 2024, 21:33
by vanove
and i noticed that the "í" doesnt work, despite the fact that, that is in a script ...

Re: i need a script for only the alphabet

Posted: 21 Mar 2024, 02:06
by boiler
kunkel321 wrote:
06 Mar 2024, 17:19
I think braces need to go around the comma {,} but I'm not sure. Try it and see if it works.

EDIT: I tried it, and the comma does work.
Try it without braces because there is no reason for them around the comma. They are extraneous in that case.

Re: i need a script for only the alphabet

Posted: 21 Mar 2024, 07:24
by kunkel321
vanove wrote:
20 Mar 2024, 21:33
and i noticed that the "í" doesnt work, despite the fact that, that is in a script ...
This is odd... Do the other accented characters öüóéáűú work?

Re: i need a script for only the alphabet

Posted: 21 Mar 2024, 19:37
by vanove
the other caracters are working, the enter and the "í" doesnt

Re: i need a script for only the alphabet

Posted: 22 Mar 2024, 07:25
by kunkel321
vanove wrote:
21 Mar 2024, 19:37
the other caracters are working, the enter and the "í" doesnt
Sorry, I don't know why it's not working... I can't test it, because I only have an English setup.

Re: i need a script for only the alphabet

Posted: 22 Mar 2024, 14:38
by vanove
ok i understand, but the enter?

Strange behavior of "Enter" with inputHooks.

Posted: 23 Mar 2024, 09:26
by kunkel321
vanove wrote:
22 Mar 2024, 14:38
ok i understand, but the enter?
Very strange... I tried the code and Enter doesn't work for me either. On a related note: Check out the code here:
viewtopic.php?p=564175#p564135
Enter also doesn't work as expected with that inputHook code.

It makes me think I'm doing the code wrong(???) I checked the documentation, and I does appear right. It's just {Enter}. Also interesting, is that one of the examples at the bottom of the docs/help page has Enter as an end key, and that code does work. So I don't know what the problem is. I'm going to experiment more.

Edit: An interesting test...
Try this code:

Code: Select all

#SingleInstance
#Requires AutoHotkey v2.0
^Esc::ExitApp ; Ctrl+Esc to Exit.

Loop 100 ; <-- Arbitrary value so it doesn't loop forever. 
{
	ih := InputHook("L1")
	ih.Start()
	ih.Wait()
	tooltip(myStr .= ih.Input)
}
As you type characters, they get added to the ToolTip. Note that they appear in the tooltip the instant that they are typed. However Enter is an exception, which only appears after an addition character is typed. (Note also that you can't actually "see" the word Enter. You know it is there, however, because the tooltip gets taller.) edit: Actually... As I think more, the behavior with the tooltip probably makes sense. The enter character puts in a vertical space, but the next line of text doesn't actually exist until you add an additional character. Maybe(?)

EDIT again:
With the below code, Enter is working as expected. Type some characters, then 'space' or one of the other end keys.

Code: Select all

#SingleInstance
#Requires AutoHotkey v2.0
;===================

!+i:: ; alt shift i
{	
	ih := InputHook(,"{Space}{Tab}{Enter}{Esc}")
	ih.Start()
	ih.Wait()

	ih.OnChar := charFunc() 
	ih.OnEnd := endFunc()

	charFunc(*)
	{	Global myStr .= ih.Input 
	}

	endFunc(*)
	{	msgbox('input:`t' myStr '`nendkey:`t' ih.EndKey)
	}
}

^Esc:: ExitApp()

Re: i need a script for only the alphabet

Posted: 23 Mar 2024, 15:52
by vanove
Thx, ok, so whats the solution? :) The first script was interesting, i tryed it, the second ... i dont know. But what can i change in the "alphabet script" to make work the enter? I dont mind, if it works that way, what your first script showed me. Its ok. But how can i write it to the "alphabet script"? (sorry im not an expert in this matter, and my english not perfect too)

Re: i need a script for only the alphabet

Posted: 05 Apr 2024, 12:08
by vanove
so? anyone has some idea?

Re: i need a script for only the alphabet

Posted: 05 Apr 2024, 14:20
by kunkel321
Sorry, I don't know how to make it work.

Re: i need a script for only the alphabet

Posted: 06 Apr 2024, 07:20
by mikeyww

Code: Select all

#Requires AutoHotkey v2.0
ih := InputHook('V')
ih.KeyOpt('{All}', '+S')
ih.KeyOpt('abcdefghijklmnopqrstuvwxyz{LShift}{RShift}{Enter}', '-S')
ih.KeyOpt('{Enter}', '+V')
ih.Start
ih.Wait
MsgBox ih.EndReason

Re: i need a script for only the alphabet

Posted: 16 Apr 2024, 17:17
by vanove
thanx mikeyww! its almost perfect now:

Code: Select all

ih := InputHook('V')
ih.KeyOpt('{All}', '+S')
ih.KeyOpt('abcdefghijklmnopqrstuvwxyzöőüóéáűíú{LShift}{Space}{RShift}{Up}{Down}{Left}{Right}?.-{Enter}', '-S')
ih.KeyOpt('{Enter}', '+V')
ih.Start
ih.Wait
MsgBox ih.EndReason
i added the arrow keys to the the script, but they doesnt work for some reason, i dont know why ... maybe someone can tell whats the problem ... and how can i put it in the script ...

thanx everyone for the help!

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

Re: i need a script for only the alphabet

Posted: 16 Apr 2024, 17:20
by gregster
@vanove, please use code tags when posting code! Thank you.

ctags.png
(14.18 KiB) Downloaded 41 times

Re: i need a script for only the alphabet

Posted: 16 Apr 2024, 18:15
by mikeyww
I guess you could try making those keys "visible" along with Enter. In the bugs forum, lexikos has recently posted about the real nature of the issue having to do with how the InputHook handles VK and SC keys.