AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to verify sendinput

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
scamper_22



Joined: 15 May 2009
Posts: 12

PostPosted: Fri Oct 02, 2009 5:27 pm    Post subject: how to verify sendinput Reply with quote

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
View user's profile Send private message
txquestor



Joined: 22 Aug 2009
Posts: 294

PostPosted: Fri Oct 02, 2009 5:51 pm    Post subject: RE: SendInput ot Console Window Reply with quote

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. Very Happy
_________________

"Man's quest for knowledge is an expanding series whose limit is infinity"
Back to top
View user's profile Send private message
scamper_22



Joined: 15 May 2009
Posts: 12

PostPosted: Fri Oct 02, 2009 6:49 pm    Post subject: Reply with quote

"Can you post you AHK code?"

It's very very basic Razz
-------------
;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
View user's profile Send private message
rootey



Joined: 06 Sep 2009
Posts: 20

PostPosted: Fri Oct 02, 2009 7:37 pm    Post subject: Reply with quote

@scamper_22
Maybe this will be of use?
Skrommel did a nice ahk script that shows keyboard input here:
http://www.donationcoder.com/Software/Skrommel/index.html#ShowOff
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Fri Oct 02, 2009 8:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
scamper_22



Joined: 15 May 2009
Posts: 12

PostPosted: Sat Oct 03, 2009 2:34 pm    Post subject: Reply with quote

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 Razz
Back to top
View user's profile Send private message
scamper_22



Joined: 15 May 2009
Posts: 12

PostPosted: Tue Oct 13, 2009 8:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group