gamepin126 Posted June 7, 2007 Posted June 7, 2007 What I'm eventually trying to do is create a cross-hair overlay onto a game, windowed game. I can make the GIF transparent, that's not the issue. It's the window behind it. I pretty much just want the "red" to just be there, and nothing else. Everything I've seen so far from what I've searched (hours, and hours of searching/reading. I'm probably too fried to figure it out right now.) is how to set the gif transparent, and not the background. I've attempted GUICtrlSetBkColor($form, $GUI_BKCOLOR_TRANSPARENT) to no avail. So now I'm lost, and burnt out. Anyone think they can help me?Attached is the image (one of 'em) I plan to use. Opt("GUIONEVENTMODE", 1) #include <GUIConstants.au3> HotKeySet("{ESC}", "Ex") $file = @ScriptDir & "\T 1px.gif" $form = GUICreate("title", 47, 26, 30, 30,$WS_POPUP) $pic = GUICtrlCreatePic($file, 0, 0, 47, 26, $WS_EX_LAYERED) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "Ex") While 1 Sleep(100) WEnd Func Ex() Exit EndFunc ;==>Ex
Zedna Posted June 7, 2007 Posted June 7, 2007 (edited) Look at my Radar project it's in my signature.I draw the same crosshair over application by MoveTo/LineTo API functions.It's better way.EDIT:here is related code snippetFunc MalujKriz() ; vzdy po zmene obrazku If $ZobrazitKriz = 0 Then Return If $pocet = 0 Then Return If $kriz[0] = 1 Then Return $x = $kriz[2]*$velikost $y = $kriz[3]*$velikost $pic_hWnd = ControlGetHandle("Radar","Velikost = ",$pic) $user_dll = DllOpen("user32.dll") $gdi_dll = DllOpen("gdi32.dll") $l_hdc = DLLCall($user_dll,"int","GetDC","hwnd",$pic_hWnd) $pen = DLLCall($gdi_dll,"int","CreatePen","int",0,"int",$velikost,"int",0xFF) $obj_orig = DLLCall($gdi_dll,"int","SelectObject","int",$l_hdc[0],"int",$pen[0]) DLLCall($gdi_dll,"int","MoveToEx","int",$l_hdc[0],"int",$x,"int",$y-10*$velikost,"int",0) DLLCall($gdi_dll,"int","LineTo","int",$l_hdc[0],"int",$x,"int",$y+11*$velikost) ;vertical line DLLCall($gdi_dll,"int","MoveToEx","int",$l_hdc[0],"int",$x-10*$velikost,"int",$y,"int",0) DLLCall($gdi_dll,"int","LineTo","int",$l_hdc[0],"int",$x+11*$velikost,"int",$y) ;horizontal line DLLCall($gdi_dll,"int","SelectObject","int",$l_hdc[0],"int",$obj_orig[0]) DLLCall($gdi_dll,"int","DeleteObject","int",$pen[0]) $l_hdc = DLLCall($user_dll,"int","ReleaseDC","hwnd",$pic_hWnd,"int",$l_hdc[0]) DllClose($gdi_dll) DllClose($user_dll) EndFuncand http://www.autoitscript.com/fileman/users/Zedna/radar.gif is screenshot Edited June 7, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
smashly Posted June 7, 2007 Posted June 7, 2007 (edited) Crude Example of gamepin126 crosshair as bmp using BMP2RGN.dll (I don't know who's dll it is, maybe larry's? , sorry to the author.) Dump dll and bmp in the same dir as the script (dll & bmp attached to bottom of the post). expandcollapse popup#include <GUIConstants.au3> #Include <Misc.au3> $Main = GUICreate('Cross', 47, 26, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreatePic(".\crossh.bmp",0,0,47,26) GUICtrlSetState(-1, $GUI_DISABLE) $a = DLLCall(".\BMP2RGN.dll","int","BMP2RGN", "str", ".\crossh.bmp", "int", 0, "int", 0, "int", 0) SetWindowRgn($Main, $a[0]) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect if (_IsPressed(25)) Then $wgp = WinGetPos($Main) WinMove($Main, '', $wgp[0] -3, $wgp[1]) EndIf if (_IsPressed(26)) Then $wgp = WinGetPos($Main) WinMove($Main, '', $wgp[0], $wgp[1] -3) EndIf if (_IsPressed(27)) Then $wgp = WinGetPos($Main) WinMove($Main, '', $wgp[0] +3, $wgp[1]) EndIf if (_IsPressed(28)) Then $wgp = WinGetPos($Main) WinMove($Main, '', $wgp[0], $wgp[1] +3) EndIf WEnd Func SetWindowRgn($h_win, $rgn) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1) EndFunc Cheers Edit: Arrow Keys to move it around. Edited June 7, 2007 by smashly
gsb Posted June 7, 2007 Posted June 7, 2007 These are fine "work arounds" and should do nicely in this case. Bur the more general "Transparent GIF [image] on Transparent Background [GUI]" seems to be beyond the capabilities of AutoIt, no? gsb "Did you ever stop to think? ...and forget to restart!"
gamepin126 Posted June 7, 2007 Author Posted June 7, 2007 Thanks a lot guys. Smashly, that's exactly what I wanted. And Zedna, that's what I wanted to do initially just couldn't figure out how. Thanks for that post, I'll play with it.
gamepin126 Posted June 8, 2007 Author Posted June 8, 2007 (edited) Nevermind, I figured out what Velikost is. I've figured out your post, for the most part. However I'm not sure what to put the hwnd part of the call to. Since I'm not drawing to an App, like you are. I'm drawing to my desktop. The "$1_hdc[0]" part. Edited June 8, 2007 by gamepin126
gamepin126 Posted June 8, 2007 Author Posted June 8, 2007 (edited) Alright, after about a day of looking over it, I've figured out everything in Zedna's script. (never used DllCall() before, took me a while) Now, my only question is how do I make it so it's always on top, but I click through it? Seems to be an issue when overlaying it, it's sitting right on top of the cursor, in game, and it's making my cursor flash in and and out and sometimes focusing the script rather than keeping the game focused. Edited June 8, 2007 by gamepin126
gsb Posted June 11, 2007 Posted June 11, 2007 These are fine "work arounds" and should do nicely in this case. But the more general "Transparent GIF [image] on Transparent Background [GUI]" seems to be beyond the capabilities of AutoIt, no? So no answers I see. Well I did find a way to have a transparent gif as an independent desktop object on the screen w/o using the "regions" approach; and is much easier/flexible I think. It does allow the "click through" to the beneath content, so positioning is the remaining issue. I will solve that later I think, is Sunday night just now. gsb "Did you ever stop to think? ...and forget to restart!"
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