AutoHotkey Community

It is currently May 27th, 2012, 2:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 10th, 2010, 2:09 am 
Offline

Joined: June 9th, 2005, 10:49 am
Posts: 30
Hotstring not backspacing completely & dropping end of line:

I've been having this issue for quite some time and I'm finally irritated enough to post for help. I've searched the forums but can't find an answer. I'm using a close variation of the "Hotstring Helper" found in the AHK documentation.

Issue: When using hotstrings, sometimes AHK will not process a hotstring correctly as in the following:

____Hotstring:
:*rc1:sd``::
SendInput, shutdown -r -m \\10.1.1.1 -t 60
return
____Result:
sshutdown -r -m \\10.1.1.1 -t 6

Most hotstrings process correctly but SOME ALWAYS result in the first typed letter (sometimes the first 2 or 3) NOT being backspaced and then subsequently, the first, second or third of THE END of the string not appearing (depending on how many TYPED letters weren't backspaced):

Example:
____Hotstring:
:*rc1:lmgts``::Let me get this straight
____Result:
lmgLet me get this strai

System & more issue info:
WinXPProSP3
Happening across all different CPU's (Intel/AMD) and abilities (single/dual/quad-core) with lots or little memory.
AHK vers 104805 (...but it's been happening for the last 3 or so versions - maybe more.)
Happens whether it's a direct hotstring or a "SendInput"
** update to the preceding line: I replaced SendInput with Send as a test and voila!, This caused the hotstring to process correctly (albeit slower)! I'm starting to wonder if AHK isn't processing the hotstring fast enough (or too fast) for the PC to handle (in other words, at SendInput speeds, AHK or PC can't keep up).

Geez, while testing the issue in order to create this post, I tried the Send command... I had to adjust the AutoExecute section (I had "SendMode InputThenPlay" in AutoExecute section which was forcing my Send tests to be SendInput) and NOW I get the below result (it's now backspacing correctly). Also, the SendInput (further down) shouldn't be affected by the "SetKeyDelay, 50" but it's now working correctly -- all I changed was to remove the SendMode and added a SetKeyDelay (both of which shouldn't affect SendInput at all) so there's another confusing situation for me (and for you to answer, if you can). :)

When I try the following I get the next result:

____Hotstring:
:*rc1:sd``::
Send, shutdown -r -m \\10.1.1.1 -t 60 -c `"Please save anything and Restart PC{!}`"
return
____Result:
shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!"

____Hotstring:
:*rc1:sd``::
SendInput, shutdown -r -m \\10.1.1.1 -t 60 -c `"Please save anything and Restart PC{!}`"
return
____Result:
shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!"

(P.S. I thought that the R (RAW) in the hotstring commands would write out the {!} but it didn't -- I guess the Send overrides the hotstring's commands and if I WANTED the {}, I'd have to put SendRaw -- good-to-know.)
Anyways, there's the SendInput now working correctly and I dunno why when it failed earlier (again, all I did was to remove the SendMode and added a SetKeyDelay for the Send test).

So, my testing leads me to believe that sometimes AHK runs faster than the PC can handle (or maybe it's the other way around). Of course, that doesn't make sense and why is it only on certain hotstrings? Another answer is that I'm not fully informed on correct hotstring creation. [grin] This is probably a Known Issue (or I'm doing it wrong) but I sure can't figure it out (or search it out). Please reply if you have any answers/thoughts!

P.S.S. Oh yeah, I almost forgot... On some of my problematic hotstrings (like one containing a bunch of e-mail addresses), if I run it in a Notepad it works perfectly but fails (as discussed above) if I run it directly in a Outlook Express message "TO:" line.   It seems that certain windows/programs don't deal with hotstrings as well as others (Internet Explorer will also sometimes munge hotstrings as discussed above).

Thanks very much in advance.

_________________
-- Thanks, BeetleTX330


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2010, 9:15 am 
Most reliable option to deal with apps like Outlook and IE is using AHK and COM instead of triggering "tricky" controls. Search the forum for COM (and/or SEAN).


Report this post
Top
  
Reply with quote  
PostPosted: February 10th, 2010, 2:52 pm 
Offline

Joined: June 9th, 2005, 10:49 am
Posts: 30
Murx wrote:
Most reliable option to deal with apps like Outlook and IE is using AHK and COM instead of triggering "tricky" controls. Search the forum for COM (and/or SEAN).


I appreciate your reply but would still like more info on the non-COM methodology I'm employing. COM resolutions won't work for alot of my requirements (K.I.S.S.). Any non-COM folks out there who can tell me anything about this vagarity in the most basic of AHK functionality? One possibility that I've thought of is to add the SP command into the hotstring for those certain strings that fail in this way. I'll have to test it today... :)

P.S. I wouldn't call a simple hotstring "triggering tricky controls"... however, if you want to discuss "triggering tricky controls", there's always COM!

_________________
-- Thanks, BeetleTX330


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2010, 3:27 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
I'm not sure why you are using Send separately, when you can just specify them as auto-replace hotstrings?

Anyway, with regard to your issue with outlook, etc - I suppose it really does depend on what is happening, maybe the controls are not processing the messages/keypresses fast enough, maybe something else...

Don't know if you want to try any of the following different modes to see which one ends up being more reliable for your purposes? You can trigger the first with sd1`, the second with sd2`, etc.

If you still have problems, you can try adjusting the delay (change k10 for k20 for example) to see if a longer delay helps?
Code:
; Normal auto-replace hotstring
:*rc1:sd1``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode

; SendEvent version, default KeyDelay
:*SErc1:sd2``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode

; SendEvent version, key delay of 10ms (k10)
:*SErc1k10:sd3``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode

; SendInput version (keydelay ignored)
:*SIrc1:sd4``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode

; SendPlay version, default delay
:*SPrc1:sd5``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode

; SendPlay version, 10ms delay (slowest)
:*SPrc1k10:sd6``::shutdown -r -m \\10.1.1.1 -t 60 -c "Please save anything and Restart PC!" ; no need to escape special characters in raw mode


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2010, 9:23 pm 
Offline

Joined: June 9th, 2005, 10:49 am
Posts: 30
Excellent reply! I thought of trying the SP, etc commands but haven't had a chance to test them yet.   I did forget about the hotstring KeyDelay command so I'll test by incorporating that as well.

Regarding why I'm using Send, I'm also sending commands like "CMD" and "C:" through the hotstring to get outta the Home (network) drive before I run the subsequent commands.

_________________
-- Thanks, BeetleTX330


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 12:59 am 
Offline

Joined: June 9th, 2005, 10:49 am
Posts: 30
From AHK's docs:

SetKeyDelay: "A short delay (sleep) is done automatically after every keystroke sent by Send or ControlSend. This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of keystrokes."

Welp, there ya go, it's documented!   I'm just gonna hafta put a SP or use Send for those commands going to 'slow' windows.

_________________
-- Thanks, BeetleTX330


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 12:27 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
You can achieve the same thing with the kn option of hotstrings (this is the key delay option) - some of the examples I posted above have "k10" in there - this means "wait 10ms between key presses" :)

But, as you say, using Send will also work, but you will then have to use SetKeyDelay command to change the wait time if needed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 7:07 pm 
Offline

Joined: June 9th, 2005, 10:49 am
Posts: 30
OceanMachine wrote:
You can achieve the same thing with the kn option of hotstrings (this is the key delay option) - some of the examples I posted above have "k10" in there - this means "wait 10ms between key presses" :)

But, as you say, using Send will also work, but you will then have to use SetKeyDelay command to change the wait time if needed.


Yep, I remembered Kn after you first mentioned it.   Yep, SetKeyDelay command will be necessary for Send, thanks!

_________________
-- Thanks, BeetleTX330


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Bing [Bot], LazyMan, rbrtryn and 18 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