AutoHotkey Community

It is currently May 27th, 2012, 12:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: how to verify sendinput
PostPosted: October 2nd, 2009, 6:27 pm 
Offline

Joined: May 15th, 2009, 6:26 pm
Posts: 12
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 2nd, 2009, 6:51 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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. :D

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 7:49 pm 
Offline

Joined: May 15th, 2009, 6:26 pm
Posts: 12
"Can you post you AHK code?"

It's very very basic :P
-------------
;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,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 8:37 pm 
Offline

Joined: September 6th, 2009, 4:22 pm
Posts: 20
@scamper_22
Maybe this will be of use?
Skrommel did a nice ahk script that shows keyboard input here:
http://www.donationcoder.com/Software/S ... ml#ShowOff


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 9:26 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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'
}
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 3:34 pm 
Offline

Joined: May 15th, 2009, 6:26 pm
Posts: 12
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 :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 9:14 pm 
Offline

Joined: May 15th, 2009, 6:26 pm
Posts: 12
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google [Bot], Leef_me, Pulover, rbrtryn, XstatyK and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group