OneillSG7 Posted November 22, 2009 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?
IchBistTod Posted November 22, 2009 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]
n0pcode Posted March 22, 2010 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 ?
hemdile Posted March 27, 2014 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
Palestinian Posted March 27, 2014 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..
Recommended Posts