Writing to text box

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Still_a_newb
orc pawn
orc pawn
Posts: 27
Joined: Sun Apr 25, 2004 9:36 pm

Writing to text box

Post by Still_a_newb » Tue May 11, 2004 9:08 pm

How could I have my macro type something in the chat window, but not send it? Also, after I have text written, how would I make it send?

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Tue May 11, 2004 9:37 pm

If /keypress won't do it for you, which I don't think it will but never tried, then there is not a way with macros. Not a way that I can think of.

Edit: No. In fact I know you can't do what you want to because /keypress doesn't actually send a keystroke.

Banannaboy
a lesser mummy
a lesser mummy
Posts: 43
Joined: Tue Apr 13, 2004 9:59 pm

Post by Banannaboy » Tue May 11, 2004 9:56 pm

Wouldnt it be possible to find the XML for the chat window, find the name of the place where you type, and set a value into the box? I have no clue how to do that, but it seems to me like it might be possible.

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Tue May 11, 2004 10:29 pm

In a plugin yes. To answer your question, in a macro, no.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Wed May 12, 2004 12:11 am

You're all absolutely incorrect.

/keypress x chat
is designed to type x in whatever edit box/text field you have active. It does work.
You cannot TYPE this in a window an expect it to work, but heres a simple test for you.

make a social, type in it "/keypress x chat"
then click on the chat input box (you know, so the caret shows up and blinks)
click the hotkey about 75 times.
75 x's magically appear in your chat box

now open up a social edit box (other than the one you just made).
click on one of the input fields
click the hotkey about 75 times.
75 x's magically appear in the social edit box.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Wed May 12, 2004 4:51 am

/keypress x chat

Learn something everyday.

Banannaboy
a lesser mummy
a lesser mummy
Posts: 43
Joined: Tue Apr 13, 2004 9:59 pm

Post by Banannaboy » Wed May 12, 2004 10:23 am

Woot thanks

Still_a_newb
orc pawn
orc pawn
Posts: 27
Joined: Sun Apr 25, 2004 9:36 pm

Post by Still_a_newb » Wed May 12, 2004 7:48 pm

Lax. Thanks for that /keypress x chat. But now, how could I have a macro automatically click in the chat box for me?

Code: Select all

<code to click in main chat box>
/keypress chat x
On the same subject, if I have something written inside the text box, whats the command to send it? I tried

Code: Select all

/keypress enter
but it doesnt work. For example.

Code: Select all

<code to click in main chat box>
/keypress xxxxx chat
/delay 10s
<code to make the chat send>
so it would type the xxxxx into the text box, wait 10 seconds to allow me to edit/change/whatever it, then send it?

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Wed May 12, 2004 7:53 pm

Also, you dont need to click on the main chat, use either
/keypress /
or
/keypress CHAT_SLASH
to open up a chat window with the slash..
OR to open up an empty one:
/keypress CHAT_EMPTY


then
/keypress x chat
/kepyress x chat
/keypress x chat
/keypress enter chat
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

guest_01
a ghoul
a ghoul
Posts: 115
Joined: Thu Apr 22, 2004 5:15 am

Post by guest_01 » Wed May 12, 2004 9:17 pm

Am I the only one who finds this buggy? Maybe it's because I'm using VC6.0 (but I did do that upgrade for it just the other day...)

Regardless,

/keypress x chat

does absolutely nothing for me... been trying to find ways to enter information into the chat bar since the death of /press, and nothing has been working... mainly doing this for a plugin, tried

pWndMgr->HandleKeyboardMsg('x',1);
pWndMgr->HandleKeyboardMsg('x',0);

and

DoMappable((PSPAWNINFO)pCharSpawn,"x chat");

and even

DoCommand(NULL,"/keypress x chat");

Both of those do nothing aswell, regardless of whether the cursor is in the chat box... if anyone can point me in the right direction, it would be much appreciated....

The ONLY way I have gotten this to work so far is by making a social (has to be a social, an alias or a bunch of DoCommands from a plugin doesn't seem to work) that has

/keypress CHAT_SLASH
/keypress x chat

in it, then I get an x in chat.... but since the only way this seems to work is from a social, I'm still no closer to being able to do this from my plugin...

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Wed May 12, 2004 9:46 pm

heh ok you're going to piss me off ;)

let me explain something. Every time you press a key in EQ with MQ2 loaded, that key gets processed not by EQ, but by MQ2. Again... MQ2 handles EVERY SINGLE KEY YOU PRESS. So... obviously there is a way to do all of this through MQ2 either as I described using /keypress or directly with a plugin. I wrote the damn system, so obviously I know a little something something about how it fuckin works. If it doesnt work for you, it doesnt mean its "buggy" it means you're not doing it the right way. Why does it work perfectly when you're typing it yourself, if MQ2 handles every key you press?

That being said....
if you TYPE THE FUCKING COMMAND ITS NOT GOING TO DO ANYTHING FOR YOU. e.g. typing "/keypress x chat", or typing an alias that does "/keypress x chat" is not going to press x in the chat window, its just going to press x.

Oddly, your top info doesnt show you having a text entry selected, but your bottom info does. I wonder which one will work.. hmm.. hmmmmmmm... must be a bug obviously!

and no it has nothing to do with VS6

like I said, there was examples for macros so I dont know why people are still having issues with this macro-wise. For plugins if you were having this trouble for so long why didnt you ask before how to do it?

Lastly why are you calling the command function instead of the functions the command calls? I really have no idea why people always do that.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

guest_01
a ghoul
a ghoul
Posts: 115
Joined: Thu Apr 22, 2004 5:15 am

Post by guest_01 » Thu May 13, 2004 2:44 pm

First off, I'd just like to say that I appreciate the work you've done, and all the help you often are, and I'm not looking to start a battle. Perhaps I was a little unclear in places in my last post, so I'm going to just go back over a bit of it in an attempt to clarify myself.

Lax wrote: That being said....
if you TYPE THE FUCKING COMMAND ITS NOT GOING TO DO ANYTHING FOR YOU. e.g. typing "/keypress x chat", or typing an alias that does "/keypress x chat" is not going to press x in the chat window, its just going to press x.

Oddly, your top info doesnt show you having a text entry selected, but your bottom info does. I wonder which one will work.. hmm.. hmmmmmmm... must be a bug obviously!
I realize that, and sort of expected it, which is why I didn't type those commands in the window, I would make a way to be able to have them execute while the cursor was in the chat window. Ie. an alias that fires on a ctrl+key, which wouldn't remove focus from the chat window.

Since much of my testing was geared at a plugin, and my alias I was working on was actually ctrl+V anyway, I used that. It didn't remove focus from the chat bar, it DID fire (the function that fired from it would put text out to the MQ2 window to verify), but all the commands I tried wouldn't put anything into the chat bar, even though the cursor was blinking there.


Lax wrote:like I said, there was examples for macros so I dont know why people are still having issues with this macro-wise. For plugins if you were having this trouble for so long why didnt you ask before how to do it?

Lastly why are you calling the command function instead of the functions the command calls? I really have no idea why people always do that.
In general, I like to try to figure things out myself before asking. As a result, I have tried just about every function call that seemed remotely related in C++, and then started resorting to DoCommands, hoping against hope that they would work where the C++ methods did not.

The function calls above are just a few of the many that I tried, none of which worked, no matter how I called them.

In the end, the ONLY method I found that put text out to the chat bar was

DoCommand(NULL,"/timed 1 /keypress X chat");

and before you start in on me, take a moment to remember that this was a last resort after trying everything else I could find. For some reason, that /timed 1 seems like the magical part which finally made it work. If you can explain that to me, it would really make me happy, since it would help me understand the system a little better. I don't claim to know as much as you or anyone else about the way MQ2 works, I only know as much as I've been able to find on the boards and piece together from experimenting.


Lax wrote:Why does it work perfectly when you're typing it yourself, if MQ2 handles every key you press?
I assume you mean, litterally typing "blah, blah, blah" in the chat box, NOT "/keypress X chat".... since the latter would obviously not work, since when you hit enter, the chat box would no longer have focus....

I don't pretend to know, but being a programmer and having built some big systems myself, I know there are plenty of opportunities for things to go wrong. The way things SHOULD work, and the way they DO work are often quite different.
Lax wrote: and no it has nothing to do with VS6
That's good to know, was just putting it in because I remember reading in a couple places that VS6 has had issues with some areas of MQ2, and often you were saying to make sure you had the latest patch. Was just putting it in as part of the process of elimination.




Again, would just like to say that I don't want to start a war, I'm just trying to clarify what I was meaning, and hopefully glean some measure of understanding out of this problem. If it's not a bug, I'd like to know why it was happening this way, so I can better understand what NOT to do in the future. If it IS a bug, well, at least I helped provide information to squash it.

Regards

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu May 13, 2004 3:03 pm

I realize that, and sort of expected it, which is why I didn't type those commands in the window, I would make a way to be able to have them execute while the cursor was in the chat window. Ie. an alias that fires on a ctrl+key, which wouldn't remove focus from the chat window.
Okay, that does explain why it wasnt working. If your custom bind fired on CTRL+V and it did this: "/keypress x chat", the problem is that you were holding down CTRL. This means the EFFECTIVE command was "/keypress ctrl+x chat", even though that isnt what you desired. I'll add /noctrl /noalt /noshift commands to do the opposite of what the /ctrl /alt /shift commands do (e.g. those commands act as though the key is held down for that time, even if it is already held down.. the new commands will act as though the key is NOT held down for that time)

Further, this explains why it would work on /timed, because hopefully you would have released the CTRL by then ;)

I do realize you're not wanting to war, and neither am I. I'm just trying to get it across that MQ2 handles every keypress, and if it was a legitimate bug it would have much wider reach. But the above just goes to show it's working *exactly* as it should :)

Something you can do in your plugin is exactly what I mentioned the /noctrl command would do.
a) store the state of ctrl/alt/shift
b) turn them off while your plugin "types"
c) type
d) restore them to their previous state

Here's how you would do this:

Code: Select all

bool KeyboardFlags[4];
	*(DWORD*)&KeyboardFlags=*(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags;
	*(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=0;	

	pWndMgr->HandleKeyboardMsg('L',1);
	pWndMgr->HandleKeyboardMsg('L',0); 

	pWndMgr->HandleKeyboardMsg('a',1);
	pWndMgr->HandleKeyboardMsg('a',0); 

	pWndMgr->HandleKeyboardMsg('x',1);
	pWndMgr->HandleKeyboardMsg('x',0); 

	*(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=*(DWORD*)&KeyboardFlags;
That should work perfectly. Give it a shot and let me know.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

guest_01
a ghoul
a ghoul
Posts: 115
Joined: Thu Apr 22, 2004 5:15 am

Post by guest_01 » Fri May 14, 2004 3:11 am

I had originally considered that it may be the ctrl key interfering, but it wasn't firing off any of my binds that would have been triggered by ctrl+key, but thinking back on that now, it makes sense that it wouldn't, since the keys are being sent directly (with modifiers) to the chat bar, and no to the alias handlers...

This did indeed print characters into the chat bar, but unfortunately, not all of them, and not in the right order....

Since my plugin is just a copy/paste utility, it just takes the text from the clipboard and puts them directly into the chat bar, so you can work with it or continue typing before hitting enter. It is currently working flawlessly with a simple loop through the string array with the commands

SetKeyComboFromChar(szChar,Combo);
DescribeKeyCombo(Combo,szCmd);
DoCommand(NULL,va("/timed 0 /keypress %s chat",szCmd));

that I'm currently using, but when I try using


pWndMgr->HandleKeyboardMsg(szChar,1);
pWndMgr->HandleKeyboardMsg(szChar,0);

in the same loop, it puts out the output incorrectly...

The test string I used in both places (every printable character on the keyboard) was

`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?

the DoCommand put it out correctly, but it took about 3 seconds or so for it to type it all out character by character....
HandleKeyboardMsg gave the output

nm,./* bx;zcvfhjkl'`\-g\+d

but it was instantaniously on the screen.
I would much rather be able to use the HandleKeyboardMsg function, but for the life of me, I havn't been able to figure out why it's giving this output (the output is the same every time too, even in between EQ reloads and zoning, so it doesn't seem like it would just be a memory dump, although I guess that's possible)

I'll continue playing with it, but any further insights you have would be appreciated

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Fri May 14, 2004 3:43 am

The problem if you're using DoCommand from a plugin is that only one command will be executed per frame. So if you have a string of 60 characters, and are getting 30fps, it will take 2 seconds

I'll do some testing on this later, dont have time right now
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0