Jump to content

Anyway to draw over games?


Recommended Posts

Is there a DLL call I can do to draw inside the games I play?

I got TextOut to work in GDI but it doesn't show up in Starcraft, any ideas?

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

Func SetPixel ($handle, $x, $y, $color)
    $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", $handle)
    $setpixel= DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)
    $realesedc= DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc

should work, but the pixel will be very small :lmao:

FootbaG
Link to comment
Share on other sites

Alright I'll try that, but I'm pretty sure that's what I was just doing... and I'm trying to draw text, not just pixels.

EDIT:

Works, but I need to find the same method, but drawing text instead.

Edited by Insolence
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

you could create a GUI with the ALWAYS_ON_TOP setting, let me dig something up :lmao:

#include <GUIConstants.au3>
$Msg_Gui = GUICreate("Test", 11, 11, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$pic= GUICtrlCreateLabel ("Text", 1, 0, 10, 10) 
GuiSetState ()

while 1
 sleep (100)
Wend

it should work, i just made the label off the top of my head, it was a pic at first o:)

FootbaG
Link to comment
Share on other sites

Great idea, but didn't work.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

then i hate to tell you :lmao: your going to have to get every single coord of the way you want your text to be and then use SetPixel... unless there is another way... cause textout should work and so should the GUI... i dont know what to say o:)

FootbaG
Link to comment
Share on other sites

The GUI shouldn't really work, I wouldn't think

The solution is to get the DC each time, although I have no idea why:

While 1
   PixelDrawConstructor($PixelDrawhwnd)
   TextDraw($PixelDrawhwnd, 15, 15, "OMFG", 0xFFFFFF)
   Sleep ( 1 )
   
WEnd

Works like a friggen charm.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

Not really a problem, but I'd like to know how to change the font of TextOut... researching it right now.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

  • 4 months later...

Hi im sorry for bringing up a pretty old post but I need to do something really similar actually write status text over the game window so I have an idea of what my script is doing instead of using msgboxes and bieng forced out of full screen in a alt-tab fasion.

this is what i gathered from the topic

#include <GUIConstants.au3>
$Msg_Gui = GUICreate("Test", 11, 11, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$pic= GUICtrlCreateLabel ("Text", 1, 0, 10, 10) 
GuiSetState ()

While 1
   PixelDrawConstructor($PixelDrawhwnd)
   TextDraw($PixelDrawhwnd, 15, 15, "OMFG", 0xFFFFFF)
   Sleep ( 1 )
   
WEnd

The PixelDrawConstructor is an unknown function for me im running on latest beta. If you guys could give me any help Id greatly apreciate it thanks!

Link to comment
Share on other sites

Link to comment
Share on other sites

No sir dont know what it is I am new to autoit i picked it up pretty easy sine I know C++, Java and Batch script and VB. I dont know them 100% but I know enough about each one to keep it as a simple hobby and pass it in school. Any help would GREATLY be apreciated. Ill look at the function list to see if theres a function that can help me out

Link to comment
Share on other sites

Thanks for the code but it doesnt go ontop of the game screen also when I test it out using textpad it works over textpad but when I minimize textpad the script just stops. But thanks for the help! Mr CL... uh Larry :) Ill play around with it I called the function like 6 times in game and nothing.

Link to comment
Share on other sites

$x = 100

$y = 100

$text = "Testing this Shiite"

While 1

TextOut($x,$y,$text)

WEnd

Func TextOut($x,$y,$text)

$hdc = DllCall("user32.dll","int","GetDC","hwnd",0)

$hdc = $hdc[0]

DllCall("gdi32.dll","int","TextOut","int",$hdc,"int",$x,"int",$y,"str",$text,"int",StringLen($text))

DllCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$hdc)

EndFunc

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

have you tried...

$x = 100
$y = 100
$text = "Testing this Shiite"

TextOut($x,$y,$text)

Func TextOut($x,$y,$text)
    $hdc = DllCall("user32.dll","int","GetDC","hwnd",0)
    $hdc = $hdc[0]
    DllCall("gdi32.dll","int","TextOut","int",$hdc,"int",$x,"int",$y,"str",$text,"int",StringLen($text))
    DllCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$hdc)
EndFunc

<{POST_SNAPBACK}>

@Larry

This is probably a stupid question, but how can you erase the text? One workaround would be drawing something to that position (x,y) after textout, but I suspect there is more elegant way.

Link to comment
Share on other sites

$x = 100

$y = 100

$text = "Testing this Shiite"

While 1

TextOut($x,$y,$text)

WEnd

Func TextOut($x,$y,$text)

    $hdc = DllCall("user32.dll","int","GetDC","hwnd",0)

    $hdc = $hdc[0]

    DllCall("gdi32.dll","int","TextOut","int",$hdc,"int",$x,"int",$y,"str",$text,"int",StringLen($text))

    DllCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$hdc)

EndFunc

<{POST_SNAPBACK}>

It works to an extent the main problem I see is updating text. It works in game although it flickers alot. Since its an infinite loop I dont see I way I could do this. Hmmm I can probally figure out a way to write it for 30secs then stop. Thanks for this
Link to comment
Share on other sites

Thanks for the code but it doesnt go ontop of the game screen also when I test it out using textpad it works over textpad but when I minimize textpad the script just stops. But thanks for the help! Mr CL... uh Larry :) Ill play around with it I called the function like 6 times in game and nothing.

<{POST_SNAPBACK}>

Can't test it with a game because I'm at work, but Larry's code worked nice in Windows Media Player in full screen mode.

It looks like the text is lost whenever the section of the screen it's in is redrawn. You might have to put it back every frame if you're drawing over a section of the game thats getting redrawn... :evil:

Link to comment
Share on other sites

The main thing is could I update the info bieng drawn? Thanks for all the help so far you guys have been great

edit: is there a loop that I can create that would run for x amount of seconds? that should be enough to solve me problems

[edit2]

$x = 700
$y = 80
$a = 1
$b = 30000
$text = "Test the shittie"

While $a < $b
$a = $a + 1
TextOut($x,$y,$text)
WEnd

Func TextOut($x,$y,$text)
    $hdc = DllCall("user32.dll","int","GetDC","hwnd",0)
    $hdc = $hdc[0]
    DllCall("gdi32.dll","int","TextOut","int",$hdc,"int",$x,"int",$y,"str",$text,"int",StringLen($text))
    DllCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$hdc)
EndFunc

This is an ok solution for now. If anyone could tell me how to make the backround of the text transparant and change the color of the font I'd love you for ever!

[/edit2]

Edited by Revo
Link to comment
Share on other sites

Working with the loop only, you could have conditional loops within your primary data loop.

#region Primary Data Loop

While 1
   Select
      Case condition 1
          $a = 1
          $b = 30000
          While $a < $b
              $a = $a + 1
              TextOut()
          WEnd
      Case condition 2
          $a = 1
          $b = 30000
          While $a < $b
              $a = $a + 1
              TextOut()
          WEnd
   EndSelect
Wend

#EndRegion

I'm guessing that the colour change would be buried inside the gdi32.dll, but I doubt that the background could be made transparent. Best bet would be to place it on a similar coloured background to give it the illusion of transparency.

Edit: I stand corrected. See next post.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...