nak said:
Hey Timothy,
Why would you use SendKeys in a SAAS? I really don't see the call for
it, other than being "sneaky"
'Sneaky' & SaaS in the same Paragraph + Me = Rant!
<RANT>I avoid SaaS because the user can't quarantine the application before
scanning and use. From my perspective, SaaS is itself accomplice to sneaky,
but the corporations don't share my view and have been pursuing this kind of
technology since the heyday of minicomputers; and to the expense of users
and the online economy. They don't understand that those of us doing desktop
apps are going to come at them with safer, faster, cheaper functionality
every time because when application speed runs the additional bottleneck of
server connection speeds, it's like putting the mice in charge of guarding
the cheese or worse still, privatising the maintenance of the power-grid.
That's without allowing for security issues such as not giving your AV
vendor the necessary 48 hours to adapt to the very latest malware before
scanning and running the application. You can't use SaaS securely. Period.
It's absolutely impossible - and even the old Honeywell dual
motherboard/multibase systems with dedicated communication's processor but
without the x86 infrastructure holes and almost hacker-proof, could not keep
a malware author from compromising the outer zone of the system if the
administrator made the fatal error of clearing the use of SaaS. Ultimately,
the quest for SaaS has made drive-by websites not only possible but more
sophisticated; and you can see the source code of the proof here:
http://scripts.web-design-1011.info/</RANT>
I also would have thought that SendKeys would be deprecated - meaning that
all possible applications of the method would have a better alternate route
by now. However, if you are building a web editor for a desktop app using
the web browser control and you wish to restore the cursor/selection
position after performing a string operation to insert some standard tags
not recognised by execCommand or correct execCommand's use of the invalid
'align' attribute when attempting to align a specific block element, there
is no SelectionStart or SelectionLength property to edit.
You have to paste a special character that does not appear in HTML, find the
character to return the selection start, and when you undo the paste, take
note of the length of the InnerHTML before and after to get the
SelectionLength. But wait, it get's even clunkier. After correcting one of
the execCommand's many shortcomings on the fly, the selection/cursor
position is lost and it becomes necessary to use SendKeys with a combination
of {HOME} and copious numbers of {RIGHT} to restore the position the cursor
as it was before you started correcting the original screw-up.
And do you think it works? Maybe! SendKeys sends the keys when it feels like
it, and if you send enough keys using SendWait to prevent inadvertent
typographic mix-ups from REAL keyboard input, the program waits indefinitely
while the operating system looks for something else, anything else to do
first. That's just to show a desktop example of an unfortunately legitimate
use - but if you have a better way for me to restore selection/cursor
position when the MSHTML processor inevitably screws it up, I'm all ears.
As to what the OP was trying to do, it looked like something familiar - but
it could be anything. The OP is simply not telling us enough.