Lenny 0 Posted July 31, 2008 Share Posted July 31, 2008 Hi! So ... I had the same idea and tried to make it like that: $dll = Dllopen("C:\Programme\Valve\gpcomms.dll") $posx = cs()/2-50 ; $posy = cs()/2+50; While 1 NewPicture("C:\Programme\Valve\fadenkreuz.tga",1,$posx,$posy) WEnd Func cs() Opt("WinTitleMatchMode", 3) Return WinGetHandle("Counter-Strike") If @error then exit EndFunc Func NewPicture($PathToFile="", $ShowIt=0, $PosX=0, $PosY=0) $return = DllCall($dll,"Int","GPPIC_LoadNewPicture","Str",$PathToFile) If @error > 0 Or $return = 0 Then SetError(1) Return(-1) EndIf $return = DllCall($dll, "Int", "GPPIC_ShowPicturePos", "Str", $ShowIt, "ushort", $PosX, "ushort", $PosY) If @error > 0 Or $return = 0 Then SetError(1) Return(-1) EndIf EndFunc ... Doesn't work ... but I think it was a tring'! Lenny Link to post Share on other sites
Zedna 355 Posted July 31, 2008 Share Posted July 31, 2008 time ago a made my own, bye, m. Here is your script changed to use GDI only (instead of GDI+) #include <WindowsConstants.au3> #include <WinAPI.au3> mycross(500,400,20) func mycross($start_x,$start_y,$mylenght) $hDC = _WinAPI_GetWindowDC(0) $Color = 0xFF $hPen = DLLCall("gdi32.dll","int","CreatePen","int",0,"int",2,"int",$Color) $hPen = $hPen[0] $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _GDI_DrawLine($hDC, $start_x - $mylenght, $start_y, $start_x - 5, $start_y);orizzontale dx _GDI_DrawLine($hDC, $start_x + $mylenght , $start_y, $start_x + 5, $start_y);orizzontale sx _GDI_DrawLine($hDC, $start_x, $start_y - $mylenght, $start_x, $start_y - 5);verticale up _GDI_DrawLine($hDC, $start_x, $start_y + $mylenght, $start_x, $start_y + 5);verticale down Sleep(3000) ; show red cross for 3s _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) _WinAPI_SelectObject($hDC, $obj_orig[0]) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc Func _GDI_DrawLine($DC, $x1, $y1, $x2, $y2) DLLCall("gdi32.dll","int","MoveToEx","int",$DC,"int",$x1,"int",$y1,"int",0) DLLCall("gdi32.dll","int","LineTo","int",$DC,"int",$x2,"int",$y2) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
OneillSG7 0 Posted November 22, 2009 Share Posted November 22, 2009 You could also simply create a gif file with a crosshair and then load it in a transparent GUI: Example: #include <WindowsConstants.au3> $x = @DesktopWidth/2 - 68/2 $y = @DesktopHeight/2 - 68/2 GUICreate("", 68, 68, $x, $y, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUICtrlCreatePic("crosshair.gif",0,0,68,68) GUISetState() While 1 Sleep(25) WEnd Regards EDIT: added a gif file. This works great, thank you! I was just wondering if there's a way to use an alpha-blended .png instead of a .gif, and a way to make it always on top, even for fullscreen applications? Link to post Share on other sites
IchBistTod 3 Posted November 22, 2009 Share Posted November 22, 2009 here expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <Constants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <sendmessage.au3> ;Global Const $LWA_ALPHA = 0x2 ;Global Const $LWA_COLORKEY = 0x1 HotKeySet("ESC", "_Exit") $x = @DesktopWidth/2-40 $y = @DesktopHeight/2-40 $hGUI = GUICreate("CROSSHAIR", 40, 40, $x, $y, bitor($WS_POPUP, $WS_CLIPSIBLINGS), bitor($WS_EX_LAYERED, $WS_EX_TOPMOST)) $hwnd = WinGetHandle("CROSSHAIR") WinSetOnTop("CROSSHAIR","", 1) WinSetOnTop("COD4","", 0) GUISetBkColor(0xABCDEF) GUICtrlCreatePic("ver.jpg", 20,0, 1, 40) GUICtrlCreatePic("hor.jpg", 0,20, 40, 1) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) GUISetState() While 1 $hwnd2 = WinGetHandle("COD4") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch sleep(50) $x = @DesktopWidth/2-40 $y = @DesktopHeight/2-40 _WinAPI_SetWindowPos($hWnd, bitor($HWND_TOP,$HWND_TOPMOST ) ,$x,$y, 40, 40, $SWP_SHOWWINDOW) WEnd Func _Exit() Exit EndFunc Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) ; ############################################# ; You are NOT ALLOWED to remove the following lines ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Author(s): Prog@ndy ; ############################################# If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes need the attached images, and i dunno COD4 title, so you will need to put it wherever the code says COD4, this should work. [center][/center][center]=][u][/u][/center][center][/center] Link to post Share on other sites
n0pcode 0 Posted March 22, 2010 Share Posted March 22, 2010 here expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <Constants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <sendmessage.au3> ;Global Const $LWA_ALPHA = 0x2 ;Global Const $LWA_COLORKEY = 0x1 HotKeySet("ESC", "_Exit") $x = @DesktopWidth/2-40 $y = @DesktopHeight/2-40 $hGUI = GUICreate("CROSSHAIR", 40, 40, $x, $y, bitor($WS_POPUP, $WS_CLIPSIBLINGS), bitor($WS_EX_LAYERED, $WS_EX_TOPMOST)) $hwnd = WinGetHandle("CROSSHAIR") WinSetOnTop("CROSSHAIR","", 1) WinSetOnTop("COD4","", 0) GUISetBkColor(0xABCDEF) GUICtrlCreatePic("ver.jpg", 20,0, 1, 40) GUICtrlCreatePic("hor.jpg", 0,20, 40, 1) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) GUISetState() While 1 $hwnd2 = WinGetHandle("COD4") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch sleep(50) $x = @DesktopWidth/2-40 $y = @DesktopHeight/2-40 _WinAPI_SetWindowPos($hWnd, bitor($HWND_TOP,$HWND_TOPMOST ) ,$x,$y, 40, 40, $SWP_SHOWWINDOW) WEnd Func _Exit() Exit EndFunc Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) ; ############################################# ; You are NOT ALLOWED to remove the following lines ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Author(s): Prog@ndy ; ############################################# If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes need the attached images, and i dunno COD4 title, so you will need to put it wherever the code says COD4, this should work. Works nicely, but only if the game is running windowed, when running fullscreen the crosshairs disappears, any trick to get it working fullscreen ? Link to post Share on other sites
hemdile 0 Posted March 27, 2014 Share Posted March 27, 2014 You could also simply create a gif file with a crosshair and then load it in a transparent GUI: Example: #include <WindowsConstants.au3> $x = @DesktopWidth/2 - 68/2 $y = @DesktopHeight/2 - 68/2 GUICreate("", 68, 68, $x, $y, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUICtrlCreatePic("crosshair.gif",0,0,68,68) GUISetState() While 1 Sleep(25) WEnd Regards EDIT: added a gif file. How do I do this? I don't know how to make or run a GUI file and also i don't know how to combine the GUI and GIF Link to post Share on other sites
Palestinian 13 Posted March 27, 2014 Share Posted March 27, 2014 How do I do this? I don't know how to make or run a GUI file and also i don't know how to combine the GUI and GIF Perhaps you should check the date of the last reply on this thread, and I'm wondering how come this thread was never locked considering the fact that its discussing games.. Link to post Share on other sites
Recommended Posts