torels Posted May 12, 2009 Posted May 12, 2009 Hi there I'm working on a project where I need to know where the selection is in the IE document (it will only contain formatted text... no links, controls or multimedia) and then insert some code in that position Can anyone give any help ? thanks in advance Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
Juvigy Posted May 12, 2009 Posted May 12, 2009 Sounds easy - just search for the text and add more text after that. For more details you will have to make us a Demo.
torels Posted May 12, 2009 Author Posted May 12, 2009 no you don't get it... it's in an embedded IE object... and I don't want to use Ctrl+F or stuff like that, in addition to the fact that I don't know how to retrieve the selection's position with Ctrl+F I want to get the selection's position by using _IE_commands #include <IE.au3> $js="java script: document.body.contentEditable = 'true'; document.designMode = 'on'; void 0" $gui=GUICreate("",600,600) GUISetState() $oIe= _IECreateEmbedded() GUICtrlCreateObj($oIe,0,0,600,600) _IENavigate($oIe, "http://torels.altervista.org") _IENavigate($oIe,$js) Do Until GUIGetMsg()=-3 here is what I have but it's absolutely nohing what I needed was a method to get the selection's position & length thanks Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
torels Posted May 12, 2009 Author Posted May 12, 2009 sorun the code aboveselect anything in the page you get (which is editable because of the _IE_Navigate($oIe, $js))How am I going to get the position of the selection ???(so to insert some html code in that position)my goal is basically to do in the $oIe what _GUICtrlEdit_GetSel() does in an edit Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
torels Posted May 19, 2009 Author Posted May 19, 2009 bump Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
Moderators big_daddy Posted May 21, 2009 Moderators Posted May 21, 2009 Have fun! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360) $GUI_Button_Paste = GUICtrlCreateButton("Paste", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) GUISetState() ;Show GUI _IENavigate($oIE, "http://torels.altervista.org") $oIE.document.body.contentEditable = True $oIE.document.designMode = 'on' ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://torels.altervista.org") Case $msg = $GUI_Button_Paste $oRange = _IE_CurrentSelectionGetRange($oIE) If Not @error Then _IE_RangePasteHTML($oRange, ClipGet()) EndIf EndSelect WEnd GUIDelete() Exit Func _IE_CurrentSelectionGetRange(ByRef $oIE) $oRange = $oIE.document.selection.createRange() If IsObj($oRange) Then Return $oRange Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_IE_CurrentSelectionGetRange Func _IE_RangePasteHTML(ByRef $oRange, $sHTML) $oRange.pasteHTML($sHTML) Return 1 EndFunc ;==>_IE_RangePasteHTML
DeltaRocked Posted February 3, 2011 Posted February 3, 2011 Have fun!Hi Bigdaddy,I am trying to insert a character in a textarea / text box but according to MSDN documentation pasteHTML does not work with textarea or text . How do I go ahead with this?RegardsDeltaRocked.
jvanegmond Posted February 3, 2011 Posted February 3, 2011 Hi Bigdaddy,I am trying to insert a character in a textarea / text box but according to MSDN documentation pasteHTML does not work with textarea or text . How do I go ahead with this?RegardsDeltaRocked.Have you tried it? Worked for me. The MSDN is not entirely clear: It might as well say "PasteHTML does not work when used incorrectly". github.com/jvanegmond
DeltaRocked Posted February 3, 2011 Posted February 3, 2011 Have you tried it? Worked for me. The MSDN is not entirely clear: It might as well say "PasteHTML does not work when used incorrectly". I have tried with this code . I have also tried with I have tried $oIE.document.selection.createRange() but always give me this error The requested action with this object has failed.: $oRange.pasteHTML('a') $oRange.pasteHTML('a')^ ERROR Where am i going wrong? This site which I am visiting is http://www.google.com Regards DeltaRocked. $oIE = _IEAttach($ie_handle, 'Embedded') $oActive_e = $oIE.document.activeElement.name $oForms = _IEFormGetCollection($oIE) $iNumForms = @extended Local $string = '' For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($oIE, $i) $val = _IEFormElementGetObjByName($oForm, $oActive_e) If @error == 0 Then $element_val_old = $val.value $i_old = $i ExitLoop EndIf Next ControlSend($ie_handle, '', $control_class_namenn, "?") $oForm = _IEFormGetCollection($oIE, $i_old) $val = _IEFormElementGetObjByName($oForm, $oActive_e) $element_val_new = $val.value $oRange = $oForm.document.selection.createRange() ; $oRange.pasteHTML('a') MsgBox(0, '', $element_val_old & @CRLF & $element_val_new)
jvanegmond Posted February 3, 2011 Posted February 3, 2011 That fails for me too. Not sure what the difference is between my test and yours. Is something like this a suitable alternative? I have just google since you said you used that. #include <IE.au3> $oIE = _IECreate("http://www.google.com") _IEErrorHandlerRegister() $oActive_e = $oIE.document.activeElement.name $oForms = _IEFormGetCollection($oIE) $iNumForms = @extended Local $string = '' For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($oIE, $i) $val = _IEFormElementGetObjByName($oForm, $oActive_e) If @error == 0 Then $element_val_old = $val.value $i_old = $i ExitLoop EndIf Next ;ControlSend($ie_handle, '', $control_class_namenn, "?") $oForm = _IEFormGetCollection($oIE, $i_old) $val = _IEFormElementGetObjByName($oForm, $oActive_e) $element_val_new = $val.value _IEPropertySet($val, "innertext", "lol") ;MsgBox(0, '', $element_val_old & @CRLF & $element_val_new) github.com/jvanegmond
DeltaRocked Posted February 3, 2011 Posted February 3, 2011 (edited) That fails for me too. Not sure what the difference is between my test and yours. Is something like this a suitable alternative? I have just google since you said you used that. Hi Manadar, Solved this... This will insert the text at the current CARET position inside IE only. $oRange = $val.document.selection.createRange() $orange.text='d' Edited February 3, 2011 by deltarocked
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