Jump to content

Herb191

Active Members
  • Posts

    215
  • Joined

  • Last visited

Everything posted by Herb191

  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
  14. ​Am a missing something basic here? If he wants to show a message box a still continue on with the script why wouldn’t this work? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_CancelButton ConsoleWrite("Hello - 1" & @CRLF) MakeMsgBox() ConsoleWrite("Hello - 3" & @CRLF) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $g_CancelButton ExitLoop EndSwitch WEnd Func MakeMsgBox() $hMsgBoxGUI = GUICreate("", 248, 168) GUISetBkColor(0xFFFFFF) $SaveButton = GUICtrlCreateButton("Save", 32, 120, 75, 25) $g_CancelButton = GUICtrlCreateButton("Cancel", 145, 120, 75, 25) $Label1 = GUICtrlCreateLabel("Some text", 24, 64, 114, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) $Label2 = GUICtrlCreateLabel("Save this Search", 9, 16, 223, 36) GUICtrlSetFont(-1, 20, 800, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) GUISetState(@SW_SHOW) EndFunc ;==>MakeMsgBox
  15. I just make a custom message box. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hMsgBoxGUI = GUICreate("", 248, 168) GUISetBkColor(0xFFFFFF) $SaveButton = GUICtrlCreateButton("Save", 32, 120, 75, 25) $CancelButton = GUICtrlCreateButton("Cancel", 145, 120, 75, 25) $Label1 = GUICtrlCreateLabel("Some text", 24, 64, 114, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) $Label2 = GUICtrlCreateLabel("Save this Search", 9, 16, 223, 36) GUICtrlSetFont(-1, 20, 800, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd
  16. I have a script that changes cursor types in IE. It works fine without flashing until the window is resized. I am not sure why it’s happening or how to stop it. Is the only solution to completely reload the image? Example: #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) 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") $oIE.document.body.style.cursor = "move" Sleep(500) $oIE.document.body.style.cursor = "n-resize" Next ;change window size WinSetState($hGUI, "", @SW_MAXIMIZE) ;second loop flashes once there is change in the window size For $i = 10 To 1 Step -1 ToolTip($i, 0, 0, "Second Loop With Flashing") $oIE.document.body.style.cursor = "move" Sleep(500) $oIE.document.body.style.cursor = "n-resize" Next
  17. I played with that option but the selector/border will actually be over the top of some image controls so labels don’t always display properly. The button control itself will be hidden. I am just using the button control to calculate the dimensions of the selector/border when the window gets resized. Also, I need the width of the selector’s border to stay the same even when the area is changing size.
  18. Thanks @argumentum for taking a shot at it. Unfortunately I need to just show a border around a control because most of the time the control will actually be hidden. Anyway, I came up with this. I was hoping to avoid splitting it into more then one script but I don't see a way around it for what I need. Example GUI #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GuiOnEventMode", 1) Opt("MustDeclareVars", 1) Global $g_hGUI, $g_idDummy $g_hGUI = GUICreate("test", 500, 500, -1, -1, $WS_SIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_COMPOSITED) $g_idDummy = GUICtrlCreateButton("", 250, 250, 50, 50) GUICtrlSetResizing($g_idDummy, $GUI_DOCKAUTO) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "WinEvents", $g_hGUI) SelectControl($g_hGUI, "[INSTANCE:1]", 5, "0xFF0000") While 1 Sleep(250) WEnd Func SelectControl($hGUI, $idControl, $iBorderWidth, $iBorderColor) Run(@ScriptDir & "\Selector.exe " & $hGUI & " " & $idControl & " " & $iBorderWidth & " " & $iBorderColor) EndFunc ;==>SelectControl Func WinEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>WinEvents Selector script (needs to be compiled to work). #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("TrayIconHide", 1) Opt("MustDeclareVars", 1) ;will exit if not ran with all parameters If $CmdLine[0] <> 4 Then Exit EndIf Global $g_hSelectorGUI, $g_aMainWinCtrlPos, $g_iBorderWidth, $g_hWinHandle, $g_idControl, $g_iBorderWidth, $g_iBorderColor $g_hWinHandle = $CmdLine[1] $g_idControl = $CmdLine[2] $g_iBorderWidth = $CmdLine[3] $g_iBorderColor = $CmdLine[4] Dim $g_aMainWinCtrlPos[4] $g_hSelectorGUI = GUICreate("Selector", 0, 0, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) GUISetBkColor($g_iBorderColor) GUISetState(@SW_SHOW, $g_hSelectorGUI) ;updates the selector AdlibRegister("UpdateSelector") While 1 Sleep(250) WEnd Func UpdateSelector() ;exits if the main program closes If Not WinExists($g_hWinHandle) Then Exit Local $aPos, $hInner_rgn, $hOuter_rgn $aPos = ControlRelativeToDesktop($g_hWinHandle, $g_idControl) If $aPos[0] = $g_aMainWinCtrlPos[0] And $aPos[1] = $g_aMainWinCtrlPos[1] And $aPos[2] = $g_aMainWinCtrlPos[2] And $aPos[3] = $g_aMainWinCtrlPos[3] Then Return $g_aMainWinCtrlPos = $aPos $g_aMainWinCtrlPos = ControlRelativeToDesktop($g_hWinHandle, $g_idControl) WinMove($g_hSelectorGUI, "", $g_aMainWinCtrlPos[0] - $g_iBorderWidth, $g_aMainWinCtrlPos[1] - $g_iBorderWidth, $g_aMainWinCtrlPos[2] + $g_iBorderWidth * 2, $g_aMainWinCtrlPos[3] + $g_iBorderWidth * 2) $hInner_rgn = _WinAPI_CreateRectRgn($g_aMainWinCtrlPos[0], $g_aMainWinCtrlPos[1], $g_aMainWinCtrlPos[0] + $g_aMainWinCtrlPos[2], $g_aMainWinCtrlPos[1] + $g_aMainWinCtrlPos[3]) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_aMainWinCtrlPos[2] + $g_iBorderWidth * 2, $g_aMainWinCtrlPos[3] + $g_iBorderWidth * 2) $hInner_rgn = _WinAPI_CreateRectRgn($g_iBorderWidth, $g_iBorderWidth, $g_aMainWinCtrlPos[2] + $g_iBorderWidth, $g_aMainWinCtrlPos[3] + $g_iBorderWidth) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hOuter_rgn) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($g_hSelectorGUI, $hCombined_rgn) EndFunc ;==>UpdateSelector 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
  19. Darn. I just tested it on another computer and had the same problem. I have been going at it all day. I will try to fix it tomorrow. Unless anyone knows why its not working.
  20. ​Interesting. I just copied the code from the forum and it worked for me. What do you mean when you say its "not working"?
  21. I got it working after messing with it for a few days. It still has an annoying flash but it works. Here is the code for anyone that might be interested. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt("GuiOnEventMode", 1) Opt("MustDeclareVars", 1) Global $g_hGUI, $g_idDummy, $g_hChildGui $g_hGUI = GUICreate("", 500, 500, -1, -1, $WS_SIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_COMPOSITED) $g_idDummy = GUICtrlCreateButton("", 250, 250, 50, 50) GUICtrlSetResizing($g_idDummy, $GUI_DOCKAUTO) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "WinEvents", $g_hGUI) GUISetOnEvent($GUI_EVENT_RESIZED, "UpdateSelector", $g_hGUI) GUIRegisterMsg($WM_SIZE, "UpdateSelector") DrawSelector("Selector", $g_idDummy) While 1 Sleep(250) WEnd Func DrawSelector($sSelectorTitle, $idControl) Local $hBitmap, $hGraphic, $aMainGUIPos, $GuiSize = 70, $hWnd, $hDC, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend, $hPen Local $iOpacity = 255, $aControlPos If WinExists($sSelectorTitle, "") Then GUIDelete(WinGetHandle($sSelectorTitle, "")) EndIf $aControlPos = ControlGetPos($g_hGUI, "", $idControl) $aMainGUIPos = WinGetClientSize($g_hGUI) $g_hChildGui = GUICreate($sSelectorTitle, $aControlPos[0], $aControlPos[1], 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) DllCall("user32.dll", "int", "SetParent", "hwnd", $g_hChildGui, "hwnd", $g_hGUI) _GDIPlus_Startup() $hWnd = _WinAPI_GetDC($g_hGUI) $hDC = _WinAPI_CreateCompatibleDC($hWnd) $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd, $aMainGUIPos[0], $aMainGUIPos[1]) _WinAPI_SelectObject($hDC, $hBitmap) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 5) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $aMainGUIPos[0]) DllStructSetData($tSize, "Y", $aMainGUIPos[1]) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _GDIPlus_GraphicsDrawRect($hGraphic, $aControlPos[0], $aControlPos[1], $aControlPos[2], $aControlPos[3], $hPen) _WinAPI_UpdateLayeredWindow($g_hChildGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) GUISetState(@SW_SHOW, $g_hChildGui) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_ReleaseDC(0, $hWnd) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hDC) _GDIPlus_Shutdown() EndFunc ;==>DrawSelector Func UpdateSelector($hWnd, $iMsg, $wparam, $lparam) WinMove($g_hChildGui,"",-1000,-1000) DrawSelector("Selector", $g_idDummy) EndFunc Func WinEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>WinEvents
  22. I would be appreciative of any help. I wouldn't ask if I wasn't stuck.
×
×
  • Create New...