mIRC Home    About    Download    Register    News    Help

Print Thread
#267813 05/10/20 11:36 PM
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
I have a question. I have repeatedly encountered the impossibility of instantly tracking the events of the typed text in the EditBox field. I am forced to create an alias with a timer for looping to check the string constantly.
Maybe there is some simpler way that I don't know?

I have a suggestion to create an event handler for EditBox with additional identifiers to determine the name of the window in which the text is typed, etc:

Code
on *:EDITBOX:*: {}


After all, approximately the same event handler is available for dialog boxes:

Code
on *:DIALOG:*:edit:*: {}


I will give a simple example of why this might be needed.

For example, you want to keep track of your typed text, so that to check for spelling errors and instantly replace, underline, or highlight a misspelled word with a script specially written for this.

Or, for example, you want to make special inserts next to the text when a certain combination of words or symbols appears there.

Perhaps it will be useful for someone to monitor and instantly respond to the event when commands are typed in the text editor.

I suggest that you think about it in order to do it. This can be useful for the developers of their scripts.


🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #267818 06/10/20 03:11 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
There's already an ON KEYDOWN event, but it works only in @win editbox not in #channel editbox. The closest I see getting now is to use $editbox($active) to find the text in that editbox. if $editbox($active).selstart and $editbox($active).selend are the same number, then that's the cursor position. If they're different, then some text has been highlighted, and the only thing you don't know is what happens when you press shift+arrow, since the .selstart and .selend values are sorted low/high which prevents you from knowing whether the text was selected left-to-right or right-to-left. That means if you try to re-create the editbox with /editbox -bNeN it won't preserve the true cursor position in the case of marking right-to-left.

What you described for highlighting or underlining mis-spelled words doesn't seem possible without a DLL of some kind. The editbox doesn't really have underlining or highlighting, it has 'selecting' which means it highlights the word by selecting it, which means as soon as the next keypress happens, the selection is replaced by your keypress. You might alternatively be forced to use a $tip message.

In a channel window, the only way to simulate the ON KEYDOWN event is to have a short interval timer that compares the current and prior $editbox(#channelname) to see if anything changed, then guess the cursor position based on .selstart and .selend and the altered text.

Last edited by maroon; 06/10/20 03:14 PM.
maroon #267819 06/10/20 03:52 PM
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
That's what I'm talking about, that without specially created script "crutches" it is not so easy to keep track of every new change or written word in this field. It would be much more convenient if this were officially implemented through an event handler to make it easier to script to track all the events in the EditBox for the channel and private windows before sending the text, without any aliases and timers looping around to do so.

Another example of how this can be used. For example, you want to create a script that will inform your interlocutor in a private window when you are typing a message and when you pause, or when you erase a message, as it is implemented in modern instant messengers.

For normal operation with this field for typing text "EditBox" - is very necessary such an event handler.

This will be useful not only to me, but to all other developers of their scripts.


🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
maroon #267820 06/10/20 05:59 PM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
There's already an ON KEYDOWN event, but it works only in @win editbox not in #channel editbox.

Right, I remember that when I added this in 1999, I limited it and its related events to custom @windows as I didn't like the idea of scripts interfering with normal windows. Twenty years later, I may be a little more open to the possibility :-)

However, such a change could lead to backward compatibility issues.

First: I can make the event trigger in all windows, not just @windows. If an older script has used the @ window prefix in the event definition, it will work as expected. But if it has used *, this will cause it to trigger in all windows, including status, queries, channels, etc.

Second: currently, using /halt in on KEYDOWN/etc. will only halt the TAB key. I could change it so that it halts all key presses, in effect allowing a script to manage all key presses in a window. This would affect most keys and shortcuts, such as Up/Down, Control+C, Escape, and so on. If an older script uses /halt in @windows, expecting it to only halt TAB, it will in fact block all keyboard input. If it happens to use * as the window prefix and uses /halt, it will block all input to all windows.

I am going to experiment with this and may include changes in the next beta.

Khaled #267824 06/10/20 09:31 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
If /halt in ON KEYDOWN makes the whole client non-responsive, it could be salvaged by using the mouse to get into the scripts editor and uncheck listen/events.

If /halt is a concern, there could be the addition of a -switch for halt to enable the other keys being halted in that event.

Khaled #267826 06/10/20 10:06 PM
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
Another such moment. I have a script that intercepts a YouTube video link that is in an EditBox, parses that link, takes the title from the html code and adds it to that link in the same field.

It turns out something like this:   YouTube "title to this cool video" youtube-link.ru

Question. How will this "on KEYDOWN" handler react if I paste the link using my mouse?


🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
maroon #267842 07/10/20 10:03 PM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
If /halt in ON KEYDOWN makes the whole client non-responsive, it could be salvaged by using the mouse to get into the scripts editor and uncheck listen/events.

In general, with backward compability issues, I am more worried about new or non-technical users who are using scripts but may not know how to fix issues. Even a technical user would be stumped for a while if they ran mIRC and suddenly found that they were no longer able to type in windows :-]

Quote
If /halt is a concern, there could be the addition of a -switch for halt to enable the other keys being halted in that event.

Yes, that may be the best approach.

Khaled #271612 28/04/23 12:15 PM
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
Therefore, it is not necessary to do this on the "ON KEYDOWN" event handler, so as not to break the backward compatibility of already created scripts, but it would be better to create a new "ON EDITBOX" event handler that will track for any keystrokes on the keyboard in the editbox field on channels, query (private) and status windows.

    Syntax: ON <level>:EDITBOX:<#channel,query,status,*>:<keycode,keycodeN,*>:{ <commands> }

    Used identifiers: $keyval, $keychar, $keyrpt. To catch the moment when the key button is released, will probably need to add the identifier $keyup.
    To define a window: $chan, $active, $query(), $scon(), $window().

Regarding the "halt" command, it would probably be appropriate to prohibit its use exclusively only in this event handling, in order to avoid accidents.


It's strange that we still don't have such an important event handler. I hope you find the time and still implement it. Thank.

[Linked Image from i.ibb.co]


🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard