Insolence Posted February 7, 2005 Posted February 7, 2005 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.
layer Posted February 7, 2005 Posted February 7, 2005 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 FootbaG
Insolence Posted February 7, 2005 Author Posted February 7, 2005 (edited) 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 February 7, 2005 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.
layer Posted February 7, 2005 Posted February 7, 2005 you could create a GUI with the ALWAYS_ON_TOP setting, let me dig something up #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 FootbaG
Insolence Posted February 7, 2005 Author Posted February 7, 2005 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.
layer Posted February 7, 2005 Posted February 7, 2005 then i hate to tell you 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 FootbaG
Insolence Posted February 7, 2005 Author Posted February 7, 2005 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.
layer Posted February 7, 2005 Posted February 7, 2005 ohhh ok, well its a lot better then getting all those coords FootbaG
Insolence Posted February 7, 2005 Author Posted February 7, 2005 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.
Revo Posted June 27, 2005 Posted June 27, 2005 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!
blindwig Posted June 27, 2005 Posted June 27, 2005 just an idea - have you tried the tooltip function? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
Revo Posted June 27, 2005 Posted June 27, 2005 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
Blue_Drache Posted June 27, 2005 Posted June 27, 2005 have you tried...$text = "Testing this Shiite"<{POST_SNAPBACK}>ROFL!!!We are a quirky bunch, eh? Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Revo Posted June 27, 2005 Posted June 27, 2005 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.
w0uter Posted June 27, 2005 Posted June 27, 2005 $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
tuape Posted June 27, 2005 Posted June 27, 2005 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}>@LarryThis 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.
Revo Posted June 27, 2005 Posted June 27, 2005 $x = 100$y = 100$text = "Testing this Shiite"While 1 TextOut($x,$y,$text)WEndFunc 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
mother9987 Posted June 27, 2005 Posted June 27, 2005 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...
Revo Posted June 28, 2005 Posted June 28, 2005 (edited) 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 June 28, 2005 by Revo
Blue_Drache Posted June 28, 2005 Posted June 28, 2005 (edited) 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 June 28, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
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