Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Drawing directly onto another application window

Would it be possible in VB.NET to draw text on another window?

I googled and found this example:
https://www.daniweb.com/programming/soft...ons-window

But it actually draws everywhere, any window, desktop,etc. I just want something drawn to a particular window. Maybe check if the process is running, then do stuff.

I'm assuming it will need some API or dll imports?
(Sep 22, 2015 10:24 AM)Vrekt Wrote:  Would it be possible in VB.NET to draw text on another window?

I googled and found this example:
https://www.daniweb.com/programming/soft...ons-window

But it actually draws everywhere, any window, desktop,etc. I just want something drawn to a particular window. Maybe check if the process is running, then do stuff.

I'm assuming it will need some API or dll imports?

lol, do not use 0 as the handle. you will need to get the handle of the control that you want to draw on.
I had to do this for a project I was working on quite a while ago now. I remember figuring it out was very easy if you just browsed a little around on pinvoke.

[Image: MmeIlGl.png]

Here's a snippet of code I wrote a while back to track the Skype "authenticate access" button for API requests. You can modify it to your liking.
It uses bad practices with putting it in an infinite loop, perhaps you should look at overlay forms instead if you plan on selling your product.
(Sep 22, 2015 10:44 AM)nathan72389 Wrote:  lol, do not use 0 as the handle. you will need to get the handle of the control that you want to draw on.

How would I go about finding the 'handle' for my application?
you can use the main window handle. it is inside the process class.
if you need to get more specific then you will have to enumerate through the controls to find the correct one that you are looking for and just use that one.
(Sep 22, 2015 11:43 AM)nathan72389 Wrote:  you can use the main window handle. it is inside the process class.
if you need to get more specific then you will have to enumerate through the controls to find the correct one that you are looking for and just use that one.

Ah I see thanks for the help.
here is a really simple example where i draw my name on the calculator

[Image: s5pdjre.png]
Nice example thanks, but now one question remains. When I draw the text it has a white background always, and it doesn't look to good on other things, any work around for this?

My code:

PHP Code

<?php 
For Each p As Process In Process.GetProcesses

            
If p.ProcessName = "javaw" And p.MainWindowTitle = "Minecraft 1.8.7" Then
                Dim gr 
As Graphics = Graphics.FromHwnd(p.MainWindowHandle)
                
gr.DrawString("TestApplication", New Font("Corbel", 12), Brushes.Black, New Point(0, 0))

            
End If

        
Next 
(Sep 22, 2015 12:21 PM)Vrekt Wrote:  Nice example thanks, but now one question remains. When I draw the text it has a white background always, and it doesn't look to good on other things, any work around for this?

Post your code, so it will be easier to pinpoint exact problem as nathan has already given you answer... ;)
BTC - bc1q3efew3yzfwhdz290dafykaw0a2w56g2j69g2c6
ETH - 0xf1c873217032468990D3313da6509D1b813c4671
USDT - 0xf1c873217032468990D3313da6509D1b813c4671
PP - [email protected]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Memento_MoriJan 18, 2022 07:09 PM 2 261 Jan 18, 2022 07:09 PM
Last Post: DDDealer
[C] by audeJan 17, 2021 06:29 AM 3 198 Jan 17, 2021 06:29 AM
Last Post: HFDone
[Java] by TennoFeb 3, 2019 04:49 AM 4 307 Feb 3, 2019 04:49 AM
Last Post: Tenno