| View previous topic :: View next topic |
| Author |
Message |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri Oct 02, 2009 5:27 pm Post subject: how to verify sendinput |
|
|
Hi all,
I'm using autohotkey as part of an automation project.
One of the tasks is to have autohotkey send keyinput via
SendInput
The program then takes some action on that keyboard input.
I'm trying to figure out if autohotkey is not sending the keypresses correctly (maybe to the wrong window) or if it has something to do with the application itself.
Is there some tool I can use to see what autohotkey is sending?
I have tried SPY++ (came with vc 6), but I think because I am sending input to a console window, it does not show up there. I only have the keyboard option in SPY++ option checked. |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Fri Oct 02, 2009 5:51 pm Post subject: RE: SendInput ot Console Window |
|
|
Hi scamper_22,
You only provided a limited amout of info to answer your question.
Can you post you AHK code?
what is the name of the console program?
Is it the only program AHk interacts with?
That said, whenever you run a script, if you right-click on the AHK Icon
in the system tray, you'll see the name of program called "Window Spy".
If you Mouseover the console window it may give you info about the window.
Also a program called "Winspector" will display all event messages when you interact with the console window.
If you go to the 1st page of ASK for HELP, at the top of the page are links to help you get more info. "Tutorial for Newbies"
You can also do a search on "Comspec" & Console, there are quite a number of scripts and help in interacting with "Console" windows.
You can also add "Msgbox' commands after the code line to see what is sent to the window.
Good Luck.  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Fri Oct 02, 2009 6:49 pm Post subject: |
|
|
"Can you post you AHK code?"
It's very very basic
-------------
;Autohotkey script to send keys
;%1 is the window name to match
;%2 is the keys to send
SetTitleMatchMode RegEx
IfWinExist , %1%
{
WinActivate %1%
SendInput %2%
}
-------------
"what is the name of the console program?"
that would be confidential.
"Is it the only program AHk interacts with?"
No, we use it for a few applications. We don't have a big enough sample size that I could say it is the fault of either one.
--------------
It's pretty tough debug this as it rarely happens, so far it hasn't happened in my testing. But some users have said it does.
Thanks for the pointers though.
Cheers, |
|
| Back to top |
|
 |
rootey
Joined: 06 Sep 2009 Posts: 20
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Fri Oct 02, 2009 8:26 pm Post subject: |
|
|
Send only sends keystrokes so you can only check that command to verify whether or not it's sending the correct keys, which is as easy as checking the lines most recently executed (double-click the tray icon for the script and press Ctrl+L).
But if you want to get some more detailed debug info you could do something like this:
| Code: | SetTitleMatchMode RegEx
IfWinExist , %1%
{
WinActivate %1%
Loop, Parse, 2 ; parses the variable '2' by character
{
WinGetActiveTitle, aTitle ; retrieves the active window
SendInput %A_LoopField% ; sends a character
debugvar .= "Active Window Title: " aTitle
. "`tCharacter Sent: " A_LoopField "`n" ; saves to var what window was active when a particular chracter was sent
VarSetCapacity(aTitle,0) ; empties the aTitle variable
}
MsgBox % debugvar ; displays the results saved to the variable 'debugvar'
}
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Sat Oct 03, 2009 2:34 pm Post subject: |
|
|
Thanks sinkfaze.
Yeah, last thing I tried was adding a retry loop around my script (not in the script itself). So it would call autohotkey.exe 3 times with my script spacing about 10 seconds apart. Same result.
That pretty much rules out an odd message being lost for some reason. It also rules out a fluke if between winactivate and sendinput, the active window changed.
Just as a confirmation. How does autohotkey send keyinput to a console window? Is it just a postmessage?
My hunch right now is that the internal console app is getting into a weird state where it is rejecting keyboard input. Time to go find that source code  |
|
| Back to top |
|
 |
scamper_22
Joined: 15 May 2009 Posts: 12
|
Posted: Tue Oct 13, 2009 8:14 pm Post subject: |
|
|
Okay looks like the problem is solved.
Changed SendInput to ControlSend.
No reports of the problem since then.
Figure it must have something to do with activating the window. |
|
| Back to top |
|
 |
|