Sign in to follow this  
Followers 0
VicTT

Drawing To The Current Window

16 posts in this topic

#1 ·  Posted (edited)

How would I go about drawing to the current window?I would need a function to draw a line from a certain X,Y position on the screen to another position...I think DllCalls can be used to achieve that but I'm not certain how...any help on the matter will be appreciated...

Edited by VicTT

[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites



That's kind of funny :think:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Now even though I appreciate irony from time to time, I can't help but notice the uselesness of your post..Don't get me wrong..Acting all elite and helpful in that you're teaching someone that signed up 5 days after you about the Search function without caring too much for what he asked for, just to prove a (stupid and false) point (i.e. that I haven't searched for any past posts on the matter before asking for help) is cool and all, but gets old after a while..Quoting from my original post:

How would I go about drawing to the current window?I would need a function to draw a line from a certain X,Y position on the screen to another position

It should be obvious that I'm not interested in GUI drawing functions, since the target window I'm attempting to draw to is not MY window..in fact..it can be any window, since I'm drawing to the screen, not to a specific window, let alone A GUI window...

So be it as funny as it may (SmOke_N), I'd still be interested in how to actually solve my problem, instead of post_number++...


[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites

Well, I think the point better made is... That you have been around for a while (not 5 days) so where is what you've tried to do? What's succeeded and what has failed?

Searching and Reading (comprehending) are 2 different things.

This thread:

http://www.autoitscript.com/forum/index.ph...indpost&p=71181

(that Valuater posted) and AnyGUI may be what your looking for.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

From my point of view, anything short of DllCalls is a waste of time, since the other two possible solutions (at least from where I stand) are:

a ) Making a huge invisible(transparent) GUI, and drawing to it...But that would make the current window lose focus, so whenever I would want to regain focus, I'd lose the drawing, with the minimization of the GUI

b ) SplashScreenOn which is the last-resort(I build a .bmp with the line to be drawn, and then SplashScreenOn it at the right coords)

As you can see, none of them are feasible..These are just MY ideas..if you have any revolutionary ones that don't involve DllCalls, DO tell!

"Searching and Reading (comprehending) are 2 different things"

Believe me, I've searched AND read and found nothing to help me..I THINK it can be done via BitBlt in Gdi32.dll, but I have no clue as to calling it...

The point being made was that, even though we signed up not far from each other (21,28 february 2005 and me: 3 april 2005), you both have 3000 posts..Searching through my posts will reveal the following aproximate composition:

a ) 50% - Valid bug-reports

b ) 50% - Helpful advice or comments + Posts asking for help

The kind of posts that say "Search the helpfile", or "Search the site" are not only annoying, but USELESS if the user being "taught" has already tried the above-mentioned methods of solving his problem..I'm still wondering why I only have 300 posts and you have +3000?:-?..Is it because you've been more active, helpful or otherwise BETTER than me, or is it just because I only post when it's neccesary, and don't hi-jack threads with RTFM posts without actually READING (comprehending) what the poster wanted to say...

Edited by VicTT

[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites

Again... Have you looked at AnyGUI.au3?

If you feel that the 3000+ posts are unwarranted, why not dig through them and see if they are for helping others... sure there are going to be a few hundred out of that many just BS but for the most part, they are helpful or intended to to be helpful.

You spent all of 2 minutes in the thread I posted, and probably haven't even looked at AnyGUI.au3 that does have the DLLCalls that you are saying are necessary.

I would quit concerning myself with what others are doing, and maybe concentrate on myself if I were in fact looking for an answer to something that I needed.

Now shall we continue being children at the playground, or find a viable solution for your issue?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#include "ANYGUIv2.6.au3"
$window=WinGetTitle("")
$handle=_GuiTarget($window)
$hgraph=_TargetAddGraphic(100,200,100,200,-1,$handle)
GUICtrlSetGraphic($hgraph[0],$GUI_GR_LINE,20,40)
while 1
wend

Result: not working

Question: Am I doing smth wrong?


[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites

To SmOke_N:

I've searched through your posts...the first two pages convinced me that you've at least in the past couple of days helped people...And I'm betting that if I dig deeper, I'll probably find similar posts...Which quite frankly contradicts my earlier opinion, even though you were not really the one the cannon-ball was aimed at..

I know Valuater has a line he copy&pastes whenever a newbie asks a question that's in the helpfile, and usually mistakes newbies that can't search a helpfile from people genuinely asking for help...

AnyGUI is probably what I'm looking for although the above example doesn't work for me...You kind of 'jumped in' to defend Valuaters' RTFM post, and I was a bit sloppy while looking at AnyGUI...That I apologize for..The only thing I need now is a WORKING example...


[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Draws line from 1:1 to 500:500

$HD = DLLCall("user32.dll","int","GetDC","hwnd",0)
DllCall("GDI32.dll","int","MoveToEx","hwnd",$HD[0],"int",1,"int",1,"int",0)
DllCall("GDI32.dll","int","LineTo","hwnd",$HD[0],"int",500,"int",500)   
DLLCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$HD[0])
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

#include "ANYGUIv2.6.au3"
$window=WinGetTitle("")
$handle=_GuiTarget($window)
$hgraph=_TargetAddGraphic(100,200,100,200,-1,$handle)
GUICtrlSetGraphic($hgraph[0],$GUI_GR_LINE,20,40)
while 1
wend

Result: not working

Question: Am I doing smth wrong?

$window=WinGetTitle("")

shouln't be necessary.

_GuiTarget( ) will return a handle to a window or control(which is itself a child window)

aside from that, you must use the beta version of autoit for Targetaddgraphic to work(as well as uncomment the _TargetaddGraphic( ) function itself )

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

... even though you were not really the one the cannon-ball was aimed at..

#include "test.au3"

MsgBox(0,"","This will not display")

Save this as test.au3 and voila..Nothing happens...You don't even get an error, or a warning...It's better than an endless loop but really....fix it please..

Oh lookie :think:..Undocumented keys..JUST the ones I'm looking for :(..

...

Now do I see that in _IsPressed?SHOULD I see that in _IsPressed?Oh gee, I guess so..

Just making you sure you can copy&paste a link..Cause if you can't...Here's a quote:

Tisk, tisk...how silly of me to ask for such things..

Dear mr. MHz, I never said that Decimal is incorrect...I just said I CAN'T BLOODY FIND IT!

Right..so instead of documenting it, as you should have, you preffered to talk about your kids...The problem is that your kids are of no interest to me whatsoever...The bug that is not yet fixed, or as you call it, the FEATURE that is not yet documented, and may be regarded as a bug, however is...

Oh..and do your kids know you have an account on a forum?They might not allow that you know...You should tell'em so that you won't get grounded..Just a friendly piece of advice for an experienced parent such as yourself...Power to the kids wink.gif

This post has been edited by VicTT: Feb 3 2006, 11:06 AM

...

If you think I shouldn't be asking for functionality to a UDF in the Bug Report forum then I'll just have to ask you why you've included F13-F24 keys if you didn't want functionality, and YET didn't take the time to include the above-mentioned keys...

Aha..you document that, label it "FIXED" and I'll shut up smile.gif

So you are telling me that if String($s) is in another string, it yields SOMETHING, and then, if it's all by itself, it yields something else?

Isn't that THE LEAST BIT confusing?This should be documented at least...It'll remain one of AutoIt's mysteries..

...

EDIT: But I also suppose that, apart from someone who might want to spend the next 30 minutes getting a head-ache by merely looking at my code, I might be the only one that understands the code...And therefore, I may be the only one able to modify it...I'll get on it.."eventually"..(It's 1:55 AM over here..some people need to sleep to survive)

Signature

QUOTE

Together we might live

Divided we must fall

Some people are just unhappy...

need I say more ( not )

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Well how about you stop taking things out of context and start giving people LINKS to those threads, so they can see exactly what that's about...But let's handle them on a case-by-case basis:

... even though you were not really the one the cannon-ball was aimed at..

Figurative speech should be forbidden when Valuater may not understand it..

#include "test.au3"

MsgBox(0,"","This will not display")

Save this as test.au3 and voila..Nothing happens...You don't even get an error, or a warning...It's better than an endless loop but really....fix it please..

Bug-reports should not have any explanation as to what the behaviour is...

Oh lookie :(..Undocumented keys..JUST the ones I'm looking for :)..

...

Now do I see that in _IsPressed?SHOULD I see that in _IsPressed?Oh gee, I guess so..

Just making you sure you can copy&paste a link..Cause if you can't...Here's a quote:

Tisk, tisk...how silly of me to ask for such things..

People should not get bitched at for not properly documenting UDF's that have been around for at least 20 beta versions..

Dear mr. MHz, I never said that Decimal is incorrect...I just said I CAN'T BLOODY FIND IT!

Thou shalt not ask a question without using a standard-form sentence with a "?"..Otherwise people will start to wonder if you're being ironic or not, and probably use it against you whenever it has no relevance to the matter at hand..It's just what unhappy people do..Search relevant posts, take'em out of context and copy&paste them, a ton at a time for added effect...

Right..so instead of documenting it, as you should have, you preffered to talk about your kids...The problem is that your kids are of no interest to me whatsoever...The bug that is not yet fixed, or as you call it, the FEATURE that is not yet documented, and may be regarded as a bug, however is...

Oh..and do your kids know you have an account on a forum?They might not allow that you know...You should tell'em so that you won't get grounded..Just a friendly piece of advice for an experienced parent such as yourself...Power to the kids wink.gif

This post has been edited by VicTT: Feb 3 2006, 11:06 AM

Bastard mode over here..There can only be 1 bastard on this forum, and it won't be Valik..Mea culpa, this time..

If you think I shouldn't be asking for functionality to a UDF in the Bug Report forum then I'll just have to ask you why you've included F13-F24 keys if you didn't want functionality, and YET didn't take the time to include the above-mentioned keys...

Proper argumentation of why I posted in the BUG Forum, got misunderstood, and got my thread moved when I was right all along about it being an undocumented feature...Damn relevant quote, Valuater..."8)"

Aha..you document that, label it "FIXED" and I'll shut up smile.gif

I can't even help but imagine why someone would get remotely pissed when it takes him 10 posts and explanations to persuade the devs to document a feature..."8)"

So you are telling me that if String($s) is in another string, it yields SOMETHING, and then, if it's all by itself, it yields something else?

Isn't that THE LEAST BIT confusing?This should be documented at least...It'll remain one of AutoIt's mysteries..

Oh no! :think: Figurative speech in relevant post again!How will Valuater ever keep up?

EDIT: But I also suppose that, apart from someone who might want to spend the next 30 minutes getting a head-ache by merely looking at my code, I might be the only one that understands the code...And therefore, I may be the only one able to modify it...I'll get on it.."eventually"..(It's 1:55 AM over here..some people need to sleep to survive)

Totally irrelevant..I was talking about a piece of MY code, and I was telling the member I coded it for (it was an Increment function for strings, I believe) that I was pretty sleepy when I did it, and I still am, and should get some sleep soon...

And of course, my signature, that, like all the above, proves and shows nothing..

Now as for the actual post:

quaizywabbit: What code should I have been using, then?The function is uncommented, yet won't work!I can't see any line..Should I set a color first?Could that be a problem?Please post an example that would simply draw a line somewhere on the screen, so that I can get what you're saying and learn something in the process...thank you..

JdeB: Thank you LOADS for your code-bit..Is there a way to set the color of the line?It's straight and to the point...Thank you ALOT!Any way I could refresh the screen after that?

Edited by VicTT

[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites

Is there a way to set the color of the line?It's straight and to the point...Thank you ALOT!Any way I could refresh the screen after that?

This sets color and linewidth. don't know about the refresh bit... You probably need RedrawWindow or something..

$LineColor = 0x0000ff; color BGR
$LineWidth = 10
$Sx = 1
$Sy = 1
$Ex = 500
$Ey = 100
$hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
$pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor)
DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$Sx, "int", $Sy, "int", 0)
DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Ex, "int", $Ey)
DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Dim $Mpos_1 = "", $Mpos_1A = "", $Mpos_2 = "", $Mpos_2A = "", $line = ""
$LineColor = 0x0000ff; color BGR
$LineWidth = 10

HotKeySet( "{ESC}", "Get_Exit")
HotKeySet("{F1}", "Get_pos_one")
HotKeySet("{F2}", "Get_pos_two")
HotKeySet( "{F3}", "Get_drawing")

MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line")

While 1
    Sleep(100)
WEnd

Func Get_pos_one()
    GUICtrlDelete($line)
    $Ms_In = MouseGetPos()
    $Mpos_1 = $Ms_In[0]
    $Mpos_2 = $Ms_In[1]
    
EndFunc  ;==>Get_pos_one

Func Get_pos_two()
    GUICtrlDelete($line)
    $Ms_In2 = MouseGetPos()
    $Mpos_1A = $Ms_In2[0]
    $Mpos_2A = $Ms_In2[1]
    
EndFunc  ;==>Get_pos_two

Func Get_drawing()
    
    If $Mpos_1 = "" Or $Mpos_1A = "" Then
        MsgBox(0, "Draw Error", " Two points of reference are required")
        MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line")
        Return
    EndIf
    $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $Mpos_1, "int", $Mpos_2, "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Mpos_1A, "int", $Mpos_2A)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])
    
EndFunc  ;==>Get_drawing

Func Get_Exit()
    Exit
EndFunc  ;==>Get_Exit

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Valuater: good example...don't see where GUICtrlDelete($line) goes though..since $line is never assigned a value..neither through DllCall or direct assignment..Happens to me to sometimes..

JdeB: Thank you a whole lot...the example was great...if anyone were to help me refresh the screen, it would completely solve my problem..Thanks to everyone for your feedback, and code...it has helped me immensely..


[quote]Together we might liveDivided we must fall[/quote]

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