Sign in to follow this  
Followers 0
twitchyliquid64

GDI Line on screen without a window?

9 posts in this topic

#1 ·  Posted (edited)

Hi all,

Im trying to make a line sweep down from the top of the users screen to the bottom to symbolise the end of a virus scan.

Obviously, It cannot be in a window.

To do this in a window it would be easy, create a window, create the drawing area from HWND, then draw the line, clear, and redraw.

But how would you do this NOT in a window?

Edited by hyperzap

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Another easy one =)

$hBarGUI=GUICreate("",@DesktopWidth,20,0,0,0x80000000,0x08000080)
GUISetBkColor(0xFF,$hBarGUI)
WinSetTrans($hBarGUI,'',0)
WinSetState($hBarGUI,'',@SW_SHOWNOACTIVATE)
WinMove($hBarGUI,'',0,-19)
WinSetTrans($hBarGUI,'',100)
For $i=-18 To @DesktopHeight Step 5
    WinMove($hBarGUI,'',0,$i)
    Sleep(10)
Next

*edit: sorry, not a GDI line - but it seemed like it would do the job

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

"create a window, create the drawing area from HWND, then draw the line, clear, and redraw."

Sorry I couldnt resist.

My apologies Mr One (sorry couldnt resist) I had an exam in 10 mins and I wanted to cram a bit more.

Ive updated the post.


ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Another easy one =)

$hBarGUI=GUICreate("",@DesktopWidth,20,0,0,0x80000000,0x08000080)
GUISetBkColor(0xFF,$hBarGUI)
WinSetTrans($hBarGUI,'',0)
WinSetState($hBarGUI,'',@SW_SHOWNOACTIVATE)
WinMove($hBarGUI,'',0,-19)
WinSetTrans($hBarGUI,'',100)
For $i=-18 To @DesktopHeight Step 5
    WinMove($hBarGUI,'',0,$i)
    Sleep(10)
Next

*edit: sorry, not a GDI line - but it seemed like it would do the job

I dont understand; You dont write it in GDI. Are you saying I should just do

$hBarGUI=GUICreate("",@DesktopWidth,20,0,0,0x80000000,0x08000080)
GUISetBkColor(0xFF,$hBarGUI)
WinSetTrans($hBarGUI,'',0)
WinSetState($hBarGUI,'',@SW_SHOWNOACTIVATE)
WinMove($hBarGUI,'',0,-19)
WinSetTrans($hBarGUI,'',100)

and that will make all objects in the window operate with transperancy around them?

Also what are those GUI styles?

Edited by hyperzap

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

Well it was my bad for not realizing you wanted to do it with GDI. You can certainly go that route - but you'll need to save the background and possibly just use it as a full-screen GUI image to draw your GDI lines on.. its just much more easier to simulate 'hovering' boxes, circles, lines and whatnot using these simple 'popup' style windows.

Here's the styles for that GUI:

; Basic: WS_POPUP (0x80000000), Extended: WS_EX_NOACTIVATE 0x08000000 + WS_EX_TOOLWINDOW (0x80)

The rest of the code is just working with the GUI background and transparency. No GUI controls are needed.

Share this post


Link to post
Share on other sites

Well it was my bad for not realizing you wanted to do it with GDI. You can certainly go that route - but you'll need to save the background and possibly just use it as a full-screen GUI image to draw your GDI lines on.. its just much more easier to simulate 'hovering' boxes, circles, lines and whatnot using these simple 'popup' style windows.

Here's the styles for that GUI:

; Basic: WS_POPUP (0x80000000), Extended: WS_EX_NOACTIVATE 0x08000000 + WS_EX_TOOLWINDOW (0x80)

The rest of the code is just working with the GUI background and transparency. No GUI controls are needed.

Hmm.

Even with your GUI styles, Its still not transparent.

Heres my code. It just make it not have the title bar, but how do you make the whitespace transparent to show the window behind?"

#include <GuiConstantsEx.au3>

#include <GDIPlus.au3>

;Opt('MustDeclareVars', 1)

HotKeySet( "q", "it")

$val = 0

_Main()

Func _Main()

    Local $hGUI, $hGraphic, $hPen

    ; Create GUI

    $hGUI = GUICreate("GDI+", 400, 300, 0, 100, 0x80000000, 0x08000000 + 0x80);, -1, 0x00CF0000);0x00080000);0x00000020)

    GUISetState()

    ; Draw line

    _GDIPlus_Startup ()

    global  $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    draw( 30)

    Do

    draw( $val + Random( -2, 2, 1))

    Sleep(10)

    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources

    _GDIPlus_PenDispose ($hPen)

    _GDIPlus_GraphicsDispose ($hGraphic)

    _GDIPlus_ShutDown ()

EndFunc   ;==>_Main



Func draw( $xval)

    $val = $xval

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $calcy = 200-Sqrt( (150*150)-($xval*$xval));-900 So basically, the formula for a circle is radius = x*x + y*y

    _GDIPlus_GraphicsDrawArc ($hGraphic, 50, 50, 300, 330, -179.9, 180)

    $hPen = _GDIPlus_PenCreate ()

    _GDIPlus_GraphicsDrawLine ($hGraphic, $xval+200, $calcy, 200, 200, $hPen)

EndFunc



Func it()

    $it = InputBox( "Gauge", "enter the value", "")

    draw( $it)

EndFunc

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Here is a crude and very poor example using winapi udf, is crap but might give you an idea.

#include <WindowsConstants.au3>
#include <WinAPI.au3>


_line()

Func _line()
    Local $hDC, $hPen, $obj_orig, $x1 = 0, $x2 = @DesktopWidth, $y1 = 0, $y2 = 0
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x00ff)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
    While $y1 < @DesktopHeight
        _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1)
        _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
        $y1 += 1
        WEnd
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Hmm.

Even with your GUI styles, Its still not transparent.

Heres my code. It just make it not have the title bar, but how do you make the whitespace transparent to show the window behind?"

...

You wanted a horizontal line that moved from the top to the bottom of the screen, I gave you the alternate option to do it without any graphics drawing. You can't then add graphics to it and expect it to work. Try my code as it was posted, and you'll see the effect. Otherwise, just go the harder/slower/flickering route of using line-drawing/erasing. I think JohnOne gave you something that might work.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0