Meerecat Posted July 15, 2011 Share Posted July 15, 2011 (edited) Hello I am trying to write a script where certain text is entered into a document using a hotkey. It works, ie the text is entered when the hotkey is pressed. But it seems to continue to hold down the SHIFT + CTRL keys until I toggle sticky keys on and off, even if I quit the script. Here is my example: #Include <Misc.au3> $dll = DllOpen("user32.dll") While Sleep(100) ;Loop the program If _IsPressed("11", $dll) AND _IsPressed("31", $dll) AND _IsPressed("10", $dll) Then _Send() If _IsPressed("7B", $dll) Then DllClose($dll) Exit EndIf WEnd Func _Send() Send ('Please find attached pro forma for your order as requested. Also attached are our bank details should you wish to make payment directly into our account. On receipt of cleared funds we will despatch your order. Please note, this could take up to 4 working days.'& @LF & @LF & 'If you have any queries or need further information, please do not hesitate to contact me.') ;Send('test') EndFunc It only occurs when sending long strings of text. If I Send('test') the problem doesn't occur. Incidentally is the a better way of doing this, ie rather than 'Sending' the text, perhaps copy the text straight from a separate text file? I guess I would start with FileOpen but am lost after that. Any advice greatfully received. Kind Regards Lee Edited July 15, 2011 by Meerecat Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer. Link to comment Share on other sites More sharing options...
Tvern Posted July 15, 2011 Share Posted July 15, 2011 If you can get a handle to the control you're using, try using ControlSetText. If you can't get the handle, or the control does not respond to ControlSetText, then you could try the following: Not sure this will solve the problem completely, but at least it'll be faster Func _Send() ;store old clupboard contents. (I think this only works for strings) $sClip = ClipGet() ;put the string in the clipboard. ClipPut('Please find attached pro forma for your order as requested. Also attached are our bank details should you wish to make payment directly into our account. On receipt of cleared funds we will despatch your order. Please note, this could take up to 4 working days.'& @LF & @LF & 'If you have any queries or need further information, please do not hesitate to contact me.') ;paste string Send('^v') ;restore old clipboard ClipPut($sClip) EndFunc If you still have the problem with this, try adding Send("{SHIFTUP}") Send("{CTRLUP}")before the function returns. Link to comment Share on other sites More sharing options...
Meerecat Posted July 15, 2011 Author Share Posted July 15, 2011 If you can get a handle to the control you're using, try using ControlSetText. If you can't get the handle, or the control does not respond to ControlSetText, then you could try the following: Not sure this will solve the problem completely, but at least it'll be faster Func _Send() ;store old clupboard contents. (I think this only works for strings) $sClip = ClipGet() ;put the string in the clipboard. ClipPut('Please find attached pro forma for your order as requested. Also attached are our bank details should you wish to make payment directly into our account. On receipt of cleared funds we will despatch your order. Please note, this could take up to 4 working days.'& @LF & @LF & 'If you have any queries or need further information, please do not hesitate to contact me.') ;paste string Send('^v') ;restore old clipboard ClipPut($sClip) EndFunc If you still have the problem with this, try adding Send("{SHIFTUP}") Send("{CTRLUP}")before the function returns. Works like a charm, thank you. Rather than inserting the text into the script directly, could I store it in a separate text or ini file and read it from that, without actually opening the file? I guess I would use FileOpen, but can I put the contents of a file into the clipboard, given I'm not really opening the file? Many Thanks Lee Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer. Link to comment Share on other sites More sharing options...
JohnOne Posted July 15, 2011 Share Posted July 15, 2011 Func _Send($s_msg) $a_msg = StringSplit($s_msg," ") For $i = 1 To $a_msg[0] Send($a_msg[$i]) Next EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Meerecat Posted July 15, 2011 Author Share Posted July 15, 2011 Func _Send($s_msg) $a_msg = StringSplit($s_msg," ") For $i = 1 To $a_msg[0] Send($a_msg[$i]) Next EndFunc I'm obviously being thick, so please feel free to tell me so. But do I somehow use that with FileOpen? I have looked at the help file, just don't get it. Thanks, and feel free to tell me to go away if this is so simple I should just get it Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer. Link to comment Share on other sites More sharing options...
JohnOne Posted July 15, 2011 Share Posted July 15, 2011 (edited) But do I somehow use that with FileOpen?No. You'd want to use FileOpen("file.ext",$iFlag) for that.Or Just $sFileRead = FileRead("File.ext")$sFileRead will hold the contents of whatever is in the file, and you can Send that if you wish. Edited July 15, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Meerecat Posted July 15, 2011 Author Share Posted July 15, 2011 No. You'd want to use FileOpen("file.ext",$iFlag) for that.Or Just $sFileRead = FileRead("File.ext")$sFileRead will hold the contents of whatever is in the file, and you can Send that if you wish.Thank you both very much, that's perfect. Now to have a play around with this Lack of planning on your part does not constitute an emergency on my part.-The biggest idiot can ask questions the smartest man cannot answer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now