Jump to content

Herb191

Active Members
  • Posts

    215
  • Joined

  • Last visited

About Herb191

  • Birthday 12/13/1981

Profile Information

  • Location
    USA
  • WWW
    http://mrautoit.com/

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Herb191's Achievements

  1. It works for me too. Very cool. Thank you.
  2. How can you scroll to the end of a text area in IE without using focus/ControlSend? I have tried several solutions (see code below) but I can't seem to get them to work. Test HTML (test.html) <!DOCTYPE html> <html> <body> <textarea id="textarea-test" rows="4" cols="50"> </textarea> </body> </html> AutoIt Test Code: #RequireAdmin #include <IE.au3> $oIE = _IECreate(@ScriptDir & "\test.html") Local $hWnd = _IEPropertyGet($oIE, "hwnd") Local $oTextarea = _IEGetObjById($oIE, "textarea-test") Local $sText = "" For $i = 1 To 30 $sText &= $i & "&#13;&#10;" _IEPropertySet($oTextarea, "innerhtml", $sText) ;NOT WORKING ;$oTextarea.document.parentwindow.scroll(0, 99999) ;_IEAction($oTextarea, "scrollintoview") ;NOT WORKING ;$iDocHeight = $oTextarea.document.body.scrollHeight() ;$oTextarea.document.parentwindow.scrollTo(0, $iDocHeight) ;NOT WORKING ;$oTextarea.document.parentwindow.scrollTo(0, 99999) ;NOT WORKING ;$oTextarea.scrollintoview() ;WORKING _IEAction($oTextarea, "focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "^{end}") Sleep(100) Next
  3. Posed twice for some reason. Deleted second one.
  4. I tried your code and tried changing the document mode but I keep getting this error: (14) : ==> The requested action with this object has failed.: Local $o_Console = $oIE.document.parentWindow.console Local $o_Console = $oIE.document.parentWindow^ ERROR Test Code: #include <IE.au3> ;TestInMode(5) ;TestInMode(7) TestInMode(8) Func TestInMode($iMode) Local $oIE = _IECreate("about:blank") _IEDocWriteHTML($oIE, MakeHTML($iMode)) SendKeepActive(_IEPropertyGet($oIE, 'hwnd')) Send('{F12}') SendKeepActive("") MsgBox(262144, '', "Wait for console data to fully load before clicking ok.") Local $o_Console = $oIE.document.parentWindow.console MsgBox(262144, 'VarGetType($o_Console)', VarGetType($o_Console)) $o_Console.log("Hello") EndFunc ;==>TestInMode Func MakeHTML($iMode) Local $sHTML $sHTML = "" $sHTML &= "<html>" & @CRLF $sHTML &= "<head>" & @CRLF $sHTML &= " <!-- Use Internet Explorer " & $iMode & " Standards mode -->" & @CRLF $sHTML &= ' <meta http-equiv="x-ua-compatible" content="IE=' & $iMode & '">' & @CRLF $sHTML &= " <title>Test webpage</title>" & @CRLF $sHTML &= "</head>" & @CRLF $sHTML &= "<body>" & @CRLF $sHTML &= " <p>Just some content...</p>" & @CRLF $sHTML &= "</body>" & @CRLF $sHTML &= "</html>" & @CRLF Return $sHTML EndFunc ;==>MakeHTML
  5. How can I interact with the IE Console Debugging API. I have tried: #include <IE.au3> Local $oIE = _IECreate("google.com") Local $oConsole = $oIE.top.document.parentWindow.console $oConsole.log('Hello World')There is a similar post here but I can't seem to get it to work.
  6. M23, Thank you for taking a look at this and sorry for the late reply. I have been swamp with a bunch of other projects. I tested your code and it works much better but there is still some small drifting on my system. I will play with if for a bit and see if I can come up with something that will work. If I find something I will post the solution I come up with here.
  7. Not a problem. I appreciate you taking a look at it. Basically I am making a custom OCR. The 3rd party app is a document viewer that has a lot of functionality that would be hard to code in AutoIt. The overlaying GUI is not actually shown in the final version of the program and is the exact same dimensions as the controller. So when the app is scrolled or resized the dummy controls within the GUI also get moved or resized with the right ratio/position without having to do a lot of complicated calculations. Lastly the dummy controls positions within the GUI are used to display dynamic "selectors" that appear to be selecting the text within the viewer...I know it is complicated however, 99 percent of it is working other then this part I am stuck on.
  8. Okay, here is an example of what I am trying to do. I have a third party application that has a control with a scroll bar. I am overlaying a transparent AutoIt GUI on that control. This AutoIt GUI has its own set of controls that I need to move in sync with the underlying control. In this example I am using notepad. The issue I am having is if you click the scroll down button of the control (the notepad edit control) the AutoIt GUI controls are drifting. They need to appear to be staying at the same point on the underlying control. I believe the root cause of this is the calculations being made in the AddScrollBar() function. Those are the same calculations being made in the first example I provided. I hope that clears things up on what I am trying to do but if you still have any questions please ask. #include <WindowsConstants.au3> #include <WinAPI.au3> #include <WinAPISys.au3> #include <GUIScrollbars_Ex.au3>;UDF page: https://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-new-version-22-nov-14/ Opt("MustDeclareVars", 1) Global $g_hNotepadWin, $g_hNoteEditCtrl, $g_hMainGUI, $g_hEventProc, $g_hEventHook Global $g_iBorderWidth, $g_iTopBorderHeight StartNotepad() GetNotepadBorderInfo() MakeMainGUI() SetHook() AddScrollBar() UpdateMainGUIl() GUISetState(@SW_SHOW) OnAutoItExitRegister("OnAutoItExit") While 1 Select Case ProcessExists('notepad.exe') = 0 Exit EndSelect WEnd Func StartNotepad() Local $sNotepadText Run("notepad.exe") WinWait("[CLASS:Notepad]") $g_hNotepadWin = WinGetHandle("[CLASS:Notepad]") WinMove($g_hNotepadWin, "", 0, 0, 500, 500) $sNotepadText = "" For $i = 1 To 5000 $sNotepadText &= $i & @CRLF & @CRLF Next $g_hNoteEditCtrl = ControlGetHandle($g_hNotepadWin, "", "[CLASS:Edit; INSTANCE:1]") ControlSetText($g_hNotepadWin, "", $g_hNoteEditCtrl, $sNotepadText) EndFunc ;==>StartNotepad Func MakeMainGUI() Local $aCtrlPos, $aWinPos $aCtrlPos = ControlRelativeToDesktop($g_hNotepadWin, $g_hNoteEditCtrl) $aWinPos = WinGetPos($g_hNotepadWin) $g_hMainGUI = GUICreate("", $aCtrlPos[2], $aCtrlPos[3], $aWinPos[0] + $aWinPos[2], $aCtrlPos[1], $WS_POPUP, $WS_EX_TOPMOST) WinSetTrans($g_hMainGUI, "", 90) GUICtrlCreateButton("test", 0, ($aWinPos[1] + $aWinPos[3]) / 2, 50, 50) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) EndFunc ;==>MakeMainGUI Func AddScrollBar() Local $iPageHeight, $iScrollMax, $iPagePixHeight, $iCalculatedPixHeight $iPagePixHeight = _WinAPI_GetClientHeight($g_hNoteEditCtrl) $iPageHeight = _GUIScrollBars_GetScrollInfoPage($g_hNoteEditCtrl, $SB_VERT) $iScrollMax = _GUIScrollBars_GetScrollInfoMax($g_hNoteEditCtrl, $SB_VERT) $iCalculatedPixHeight = ($iPagePixHeight / $iPageHeight) * $iScrollMax _GUIScrollbars_Generate($g_hMainGUI, 0, $iCalculatedPixHeight, 0, 0, True) _GUIScrollBars_SetScrollInfoMax($g_hMainGUI, $SB_VERT, $iScrollMax) _GUIScrollBars_EnableScrollBar($g_hMainGUI, $SB_VERT, $ESB_DISABLE_BOTH) EndFunc ;==>AddScrollBar Func ControlRelativeToDesktop($hWnd, $idControl) Local $Point, $aControlXYPos Dim $aPos[4] $aControlXYPos = ControlGetPos($hWnd, "", $idControl) $Point = DllStructCreate("int;int") DllStructSetData($Point, 1, $aControlXYPos[0]) DllStructSetData($Point, 2, $aControlXYPos[1]) DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($Point)) ;x $aPos[0] = DllStructGetData($Point, 1) ;y $aPos[1] = DllStructGetData($Point, 2) ;width $aPos[2] = $aControlXYPos[2] ;height $aPos[3] = $aControlXYPos[3] Return $aPos EndFunc ;==>ControlRelativeToDesktop Func SetHook() $g_hEventProc = DllCallbackRegister('Event', 'none', 'ptr;dword;hwnd;long;long;dword;dword') $g_hEventHook = _WinAPI_SetWinEventHook($EVENT_OBJECT_VALUECHANGE, $EVENT_OBJECT_VALUECHANGE, DllCallbackGetPtr($g_hEventProc), ProcessExists('notepad.exe')) EndFunc ;==>SetHook Func Event($g_hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadID, $iEventTime) UpdateMainGUIl() EndFunc ;==>Event Func UpdateMainGUIl() Local $iMaxAdjustedHeight, $aCtrlPos, $aWinPos, $iScrollBarWidth, $iNotepadMaxScroll, $iAmountToScroll ;get the main control pos info for notepad $aCtrlPos = ControlGetPos($g_hNotepadWin, "", $g_hNoteEditCtrl) ;get the window pos info for notepad $aWinPos = WinGetPos($g_hNotepadWin) ;find the vertical scroll bar width. It will be 0 if not showing. $iScrollBarWidth = _GUIScrollBars_GetScrollBarXYLineButton($g_hNoteEditCtrl, $OBJID_VSCROLL) ;move and resize the $g_hMainGUI WinMove($g_hMainGUI, "", $aWinPos[0] + $g_iBorderWidth, $aWinPos[1] + $g_iTopBorderHeight, $aCtrlPos[2] - $iScrollBarWidth, $aCtrlPos[3]) $iNotepadMaxScroll = _GUIScrollBars_GetScrollInfoMax($g_hNoteEditCtrl, $SB_VERT) If $iNotepadMaxScroll <> _GUIScrollBars_GetScrollInfoMax($g_hMainGUI, $SB_VERT) Then ;updates the max scroll _GUIScrollBars_SetScrollInfoMax($g_hMainGUI, $SB_VERT, $iNotepadMaxScroll) EndIf Do ;uses the do loop to make sure the pos gets updated right on fast scrolling ;find the scroll pos $iAmountToScroll = _GUIScrollBars_GetScrollInfoPos($g_hNoteEditCtrl, $SB_VERT) If @error Then Exit ;updates the scroll pos of the main GUI _GUIScrollBars_SetScrollInfoPos($g_hMainGUI, $SB_VERT, $iAmountToScroll) ;makes sure both scroll pos are the same Until _GUIScrollBars_GetScrollInfoPos($g_hNoteEditCtrl, $SB_VERT) = _GUIScrollBars_GetScrollInfoPos($g_hMainGUI, $SB_VERT) EndFunc ;==>UpdateMainGUIl Func GetNotepadBorderInfo() Local $aWinPos $aWinPos = WinGetPos($g_hNotepadWin) $g_iBorderWidth = ($aWinPos[2] - _WinAPI_GetClientWidth($g_hNotepadWin)) / 2 $g_iTopBorderHeight = $aWinPos[3] - _WinAPI_GetClientHeight($g_hNotepadWin) - $g_iBorderWidth EndFunc ;==>GetNotepadBorderInfo Func OnAutoItExit() _WinAPI_UnhookWinEvent($g_hEventHook) DllCallbackFree($g_hEventProc) EndFunc ;==>OnAutoItExit
  9. It is part of a much bigger project. I will attempt to make an example I can post here. It will take awhile to put something together though.
  10. In the example I provided I am trying to calculate/find the value of $iTrueTotalPixHeight. Obviously we know the value in the example but I am trying to find this value in a program that the value changes in. The principle should be the same though. If I can calculate the right value in the example I can also get the right value in the program.
  11. Thanks for the reply M23. I also get 17 on my system when I use _WinAPI_GetSystemMetrics. However, I am not sure how I can use those values to convert the _GUIScrollBars_GetScrollInfoMax value into pixels? I guess I should add some more details. I want to find the total scroll value in pixels. Not just the window without the scroll bar.
  12. I am having problems converting scroll bar values into total pixel values. Basically I want to know what the height of a programs window would be if it did not have a scroll bar. I thought this would be a very simple calculation but it is giving me problems. What I have tried. #include <WinAPI.au3> #include <GUIScrollbars_Ex.au3> ;UDF page: https://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-new-version-22-nov-14/ $hGUI = GUICreate("", 200, 200, 50, 50) ;make a random pixel height $iTrueTotalPixHeight = Random(500, 2000, 1) _GUIScrollbars_Generate($hGUI, 0, $iTrueTotalPixHeight) GUISetState(@SW_SHOW) $iPagePixHeight = _WinAPI_GetClientHeight($hGUI) $iPageHeight = _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT) $iScrollMax = _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT) ;$iCalculatedPixHeight = ($iPagePixHeight/$iPageHeight) * $iScrollMax $iCalculatedPixHeight = ($iScrollMax / $iPageHeight) * $iPagePixHeight $sMsg = "The true total pixel height is: " & $iTrueTotalPixHeight & @CRLF $sMsg &= "The calculated total pixel height is: " & $iCalculatedPixHeight MsgBox(0, "", $sMsg)
  13. For anyone that is interested. Removing $WS_EX_COMPOSITED stopped the flickering for me but I needed the double-buffering for what I was doing. I ended up having to disable the ActiveX control and then set the GUI’s cursor using GUISetCursor. Here is a working example for anyone that may run into the same problem. #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $sFileName = FileOpenDialog("Please select file", "", "Image files (*.jpg;*.tif;*.gif;*.bmp;*.png;)"); If @error Then Exit $hGUI = GUICreate("", 500, 500, 0, 0, $WS_SIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_COMPOSITED) $oIE = ObjCreate("Shell.Explorer.2") $g_idGUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 500, 500) GUICtrlSetResizing($g_idGUIActiveX, $GUI_DOCKAUTO) ;navigate to image $oIE.navigate($sFileName) _IELoadWait($oIE) ;makes the HTML that will hold the image $sHTML = "<HTML><HEAD><SCRIPT language=jscript for=document type=text/javascript defer event=oncontextmenu>;return false</SCRIPT></HEAD>" $sHTML &= '<BODY style="BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px">' $sHTML &= '<IMG width=100% height=100% src="' & $sFileName & '"></BODY></HTML>' ;save the HTML to IE _IEDocWriteHTML($oIE, $sHTML) _IELoadWait($oIE) GUICtrlSetState($g_idGUIActiveX, $GUI_DISABLE);<<<<<<<<<<disable GUISetState(@SW_SHOW, $hGUI) ;remove the scroll bar $oIE.document.body.scroll = "no" ;first loop does not flash For $i = 10 To 1 Step -1 ToolTip($i, 0, 0, "First Loop") GUISetCursor(9, 1, $hGUI) Sleep(500) GUISetCursor(2, 1, $hGUI) Next ;change window size WinSetState($hGUI, "", @SW_MAXIMIZE) ;second loop /w no flash For $i = 10 To 1 Step -1 ToolTip($i, 0, 0, "First Loop") GUISetCursor(9, 1, $hGUI) Sleep(500) GUISetCursor(2, 1, $hGUI) Next
×
×
  • Create New...