DeltaRocked Posted February 1, 2011 Share Posted February 1, 2011 (edited) Hi, Is it possible to convert this javascript code into Autoit thanks and regards DeltaRocked expandcollapse popup<html> <body style="font-family: tahoma; font-size: 8pt;"> <script language="Javascript"> /* ** Returns the caret (cursor) position of the specified text field. ** Return value range is 0-oField.length. */ function doGetCaretPosition (oField) { // Initialize var iCaretPos = 0; // IE Support if (document.selection) { // Set focus on the element oField.focus (); // To get cursor position, get empty selection range var oSel = document.selection.createRange (); // Move selection start to 0 position oSel.moveStart ('character', -oField.value.length); // The caret position is selection length iCaretPos = oSel.text.length; } // Firefox support else if (oField.selectionstart || oField.selectionstart == '0') iCaretPos = oField.selectionstart; // Return results return (iCaretPos); } /* ** Sets the caret (cursor) position of the specified text field. ** Valid positions are 0-oField.length. */ function doSetCaretPosition (oField, iCaretPos) { // IE Support if (document.selection) { // Set focus on the element oField.focus (); // Create empty selection range var oSel = document.selection.createRange (); // Move selection start and end to 0 position oSel.moveStart ('character', -oField.value.length); // Move selection start and end to desired position oSel.moveStart ('character', iCaretPos); oSel.moveEnd ('character', 0); oSel.select (); } // Firefox support else if (oField.selectionstart || oField.selectionstart == '0') { oField.selectionstart = iCaretPos; oField.selectionend = iCaretPos; oField.focus (); } } </script> <form name="blah"> Text Field: <input type="text" name="nameEdit" value=""> <input type="button" value="Get Caret" onclick="document.getElementById('where').value=doGetCaretPosition (document.forms[0].elements[0]);"> <input id="where"> <hr size=1 noshade> New Position: <input type="text" name="newPosValue" value=""> <input type="button" value="Set Caret" onclick="doSetCaretPosition (document.blah.nameEdit, parseInt (document.blah.newPosValue.value));"> </form> </body> </html> Edited February 1, 2011 by deltarocked Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 2, 2011 Share Posted February 2, 2011 Ahem... Search, and are your friends. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DeltaRocked Posted February 3, 2011 Author Share Posted February 3, 2011 Ahem... Search, and are your friends. Lol.... thanks psaltyDS 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