Sign in to follow this  
Followers 0
lolp1

How to draw corsshair to the screen?

9 posts in this topic

I've seen one or two auto-it programs that draw a cross hair to the screen (Much like a Counter-strike cross hair) How are they doing this, I researched a bit and couldent find any dirt on it:D.

Share this post


Link to post
Share on other sites



just a few posts down from this one is a perfect example: from DarkShadow

#Include <Misc.au3>
#NoTrayIcon

HotKeySet("{PGUP}","TogXHair")
HotKeySet("{END}","Exitt")
Opt("ColorMode",0)
Global $dc
Global $x
Global $y
Global $on
Global $color
Global $dll
Global $xhclr
Global $on
Global $off
$on = 1
$off = 0
$xhclr = 0x0000FF
;$xhclr = "0xFF9986"
$dll = DllOpen("user32.dll")



MsgBox(0,"Simple Xhair","Welcome to Simple Xhair." & @LF & "" & @LF & "PGUP: Toggle XHair On/Off" & @LF & "END: Exit" & @LF & "" & @LF & "" & @LF & "Made by DarkShadow" & @LF & "www.vacdisabled.net" & @LF & "www.ddcodingcrew.com")

While 1
   If $on = 1 Then
      DrawXHair()
   ElseIf $on = 0 Then
      NoXHair()
   EndIf
  ;Sleep(5)
WEnd


#region; funcs
Func drawpix($dc,$x,$y,$color)
   DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)
EndFunc

Func DrawXHair()
   While 1
      pict1(@DesktopWidth / 2,@DesktopHeight / 2)
      Sleep(50)
   WEnd
EndFunc
Func swap(ByRef $a, ByRef $B)
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func TogXHair()
   swap($on, $off)
EndFunc

Func NoXHair()
While 1
   Sleep(1000)
WEnd
EndFunc

Func Exitt()
   MsgBox(0,"Simple Xhair","Made by DarkShadow. Please visit www.VACDisabled.net and www.DDCodingCrew.com")
   Sleep(500)
   Exit
EndFunc

Func pict1($x,$y)
   $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
   While 1
     ;drawpix($dc,$x+1,$y,$xhclr)
      drawpix($dc,$x+2,$y,$xhclr)
      drawpix($dc,$x+3,$y,$xhclr)
      drawpix($dc,$x+4,$y,$xhclr)
      drawpix($dc,$x+5,$y,$xhclr)
     ;drawpix($dc,$x-1,$y,$xhclr)
      drawpix($dc,$x-2,$y,$xhclr)
      drawpix($dc,$x-3,$y,$xhclr)
      drawpix($dc,$x-4,$y,$xhclr)
      drawpix($dc,$x-5,$y,$xhclr)
     ;drawpix($dc,$x,$y+1,$xhclr)
      drawpix($dc,$x,$y+2,$xhclr)
      drawpix($dc,$x,$y+3,$xhclr)
      drawpix($dc,$x,$y+4,$xhclr)
      drawpix($dc,$x,$y+5,$xhclr)
     ;drawpix($dc,$x,$y-1,$xhclr)
      drawpix($dc,$x,$y-2,$xhclr)
      drawpix($dc,$x,$y-3,$xhclr)
      drawpix($dc,$x,$y-4,$xhclr)
      drawpix($dc,$x,$y-5,$xhclr)
     ;this is the plus ^^^
      
   WEnd
   DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc
#endregion;end funcs

hope this helps you..

Share this post


Link to post
Share on other sites

just a few posts down from this one is a perfect example: from DarkShadow

#Include <Misc.au3>
#NoTrayIcon

HotKeySet("{PGUP}","TogXHair")
HotKeySet("{END}","Exitt")
Opt("ColorMode",0)
Global $dc
Global $x
Global $y
Global $on
Global $color
Global $dll
Global $xhclr
Global $on
Global $off
$on = 1
$off = 0
$xhclr = 0x0000FF
;$xhclr = "0xFF9986"
$dll = DllOpen("user32.dll")
MsgBox(0,"Simple Xhair","Welcome to Simple Xhair." & @LF & "" & @LF & "PGUP: Toggle XHair On/Off" & @LF & "END: Exit" & @LF & "" & @LF & "" & @LF & "Made by DarkShadow" & @LF & "www.vacdisabled.net" & @LF & "www.ddcodingcrew.com")

While 1
   If $on = 1 Then
      DrawXHair()
   ElseIf $on = 0 Then
      NoXHair()
   EndIf
  ;Sleep(5)
WEnd
#region; funcs
Func drawpix($dc,$x,$y,$color)
   DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)
EndFunc

Func DrawXHair()
   While 1
      pict1(@DesktopWidth / 2,@DesktopHeight / 2)
      Sleep(50)
   WEnd
EndFunc
Func swap(ByRef $a, ByRef $B)
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func TogXHair()
   swap($on, $off)
EndFunc

Func NoXHair()
While 1
   Sleep(1000)
WEnd
EndFunc

Func Exitt()
   MsgBox(0,"Simple Xhair","Made by DarkShadow. Please visit www.VACDisabled.net and www.DDCodingCrew.com")
   Sleep(500)
   Exit
EndFunc

Func pict1($x,$y)
   $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
   While 1
     ;drawpix($dc,$x+1,$y,$xhclr)
      drawpix($dc,$x+2,$y,$xhclr)
      drawpix($dc,$x+3,$y,$xhclr)
      drawpix($dc,$x+4,$y,$xhclr)
      drawpix($dc,$x+5,$y,$xhclr)
     ;drawpix($dc,$x-1,$y,$xhclr)
      drawpix($dc,$x-2,$y,$xhclr)
      drawpix($dc,$x-3,$y,$xhclr)
      drawpix($dc,$x-4,$y,$xhclr)
      drawpix($dc,$x-5,$y,$xhclr)
     ;drawpix($dc,$x,$y+1,$xhclr)
      drawpix($dc,$x,$y+2,$xhclr)
      drawpix($dc,$x,$y+3,$xhclr)
      drawpix($dc,$x,$y+4,$xhclr)
      drawpix($dc,$x,$y+5,$xhclr)
     ;drawpix($dc,$x,$y-1,$xhclr)
      drawpix($dc,$x,$y-2,$xhclr)
      drawpix($dc,$x,$y-3,$xhclr)
      drawpix($dc,$x,$y-4,$xhclr)
      drawpix($dc,$x,$y-5,$xhclr)
     ;this is the plus ^^^
      
   WEnd
   DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc
#endregion;end funcs

hope this helps you..

His was the one I was refering to, but this is amazingly simple, and I've known how to do this. Was looking for something alot more complex.

Share this post


Link to post
Share on other sites

His was the one I was refering to, but this is amazingly simple, and I've known how to do this. Was looking for something alot more complex.

Doubtful

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

lolp1 you could've asked me yourself :):P

How exactly do you want it to be complex? You can do a lot if you put your mind to it using that base. (Using fractions based off of a screen's resolution, converting it, etc. - that's what's going to go into my next release)

Edited by darkshadow791

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I've already set my mind, and put my project to work... you'll probably see it on the forums some time soon. Your missing key things, such as only applying the cross hair to key screens, EG: it only shows on certian game screens, as well as checks game screen size to make sure it's in the ceneter.

Edited by lolp1

Share this post


Link to post
Share on other sites

Doubtful

It's rare that I actually LOL on the computer, let alone on a coding forum,...but maannnnn...that really caught me off guard.

Share this post


Link to post
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
Sign in to follow this  
Followers 0