JojjeK Posted January 3, 2019 Share Posted January 3, 2019 I have tried for a few days to get AutoIt to draw a square on my screen(not on a GUI, but on the windows screen). After some searching i found this post from 2008 which had enough information for me to learn how to draw a simple line on the screen. It works really well with drawing a line, but when i want to draw multiple lines to make a square shape the lines start to flicker. Here's my code where i can enable/disable the lines: expandcollapse popup#include <FileConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPIFiles.au3> #include <Misc.au3> #include <ButtonConstants.au3> $Test = GUICreate("ColorCheck") $Square = GUICtrlCreateCheckbox("On", 10, 90, 80, 30, $BS_PUSHLIKE) $Exit = GUICtrlCreateButton("EXIT",200,35,50,25) GUISetState(@SW_SHOW,$Test) While 1 _GDIPlus_Startup () Global $hDC = _WinAPI_GetWindowDC(0) Global $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) Switch GUIGetMsg() Case $Exit Exit EndSwitch Switch GUICtrlRead($Square) Case $GUI_CHECKED GUICtrlSetData($Square, "Off") _GDIPlus_GraphicsDrawLine($hGraphic, 760, 390, 1160, 390) _GDIPlus_GraphicsDrawLine($hGraphic, 760, 690, 1160, 690) _GDIPlus_GraphicsDrawLine($hGraphic, 760, 390, 760, 690) _GDIPlus_GraphicsDrawLine($hGraphic, 1160, 390, 1160, 690) Case Else GUICtrlSetData($Square, "On") EndSwitch Sleep(10) WEnd _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) _WinAPI_ReleaseDC(0, $hDC) _GDIPlus_Shutdown() And here is my code where i just draw the lines: #include <WindowsConstants.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> _GDIPlus_Startup () $hDC = _WinAPI_GetWindowDC(0) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) While 1 _GDIPlus_GraphicsDrawLine($hGraphic, 760, 390, 1160, 390) _GDIPlus_GraphicsDrawLine($hGraphic, 760, 690, 1160, 690) _GDIPlus_GraphicsDrawLine($hGraphic, 760, 390, 760, 690) _GDIPlus_GraphicsDrawLine($hGraphic, 1160, 390, 1160, 690) WEnd Is there anyway to draw a few lines, i am planning on drawing more lines so i really need to find a way, and keep them from flickering. The flickering gets even worse if i the screen updates e.g videos or games. Link to comment Share on other sites More sharing options...
careca Posted January 3, 2019 Share Posted January 3, 2019 (edited) Maybe you could use a transparent GUI behind, and then the lines could not be redrawn. But im not an expert on this. See this example: Maybe you can use the idea to make whatever you want. Edited January 3, 2019 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JojjeK Posted January 3, 2019 Author Share Posted January 3, 2019 I tried to create a transparent GUI behind it, but it still flickers even with the GUI on top and if i just do GUICtrlCreateGraphic it will be as transparent as the GUI. Link to comment Share on other sites More sharing options...
careca Posted January 3, 2019 Share Posted January 3, 2019 (edited) One option could be making your GUI the child window of whatever it is on top of it. Scratch that, thy this instead: _WinAPI_SetWindowPos($GUI, $HWND_TOP, 100, 100, $WX, $WY, $SWP_SHOWWINDOW) Edited January 3, 2019 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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