Jump to content

not toggling...


Recommended Posts

Credit's aren't put in yet but they will be so don't get mad at me for that...

It works fine so far but it won't turn off or toggle... I plan on adding different shapes but here is the base code at the moment...

#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
Link to comment
Share on other sites

here ya go! :)

This probably is'nt the most efficient way of doing it... but it works. lol (considering it uses 100% CPU)

Fixed the 100% cpu usage problem :P

#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
Global $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")

$on = True
$off = False
$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 == True Then
      DrawXHair()
  ElseIf $on == False Then
      ;Do Nothing
      ;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)
    if ($a == false) then $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func TogXHair()
    DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
    Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   swap($on, $off)
EndFunc

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

Func Exitt()
   ;ProcessClose("explorer.exe")
   Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   MsgBox(0,"Simple Xhair","Made by DarkShadow. Please visit www.VACDisabled.net and www.DDCodingCrew.com")
   Sleep(500)
   Exit
EndFunc

Func pict1($x,$y)
     ;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 ^^^

   ;DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc
#endregion;end funcs
Edited by CHRIS95219
Link to comment
Share on other sites

toggles between crosshairs and rectangle:

for drawing other shapes with GDI.. check this out: http://windowssdk.msdn.microsoft.com/en-us...y/ms533282.aspx

#Include <Misc.au3>
#NoTrayIcon

HotKeySet("{PGUP}","TogXHair")
HotKeySet("{END}","Exitt")
Opt("ColorMode",0)
Global $dc
Global $x = @DesktopWidth/2
Global $y = @DesktopHeight/2
Global $color
Global $dll
Global $xhclr
Global $on
Global $off
Global $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")

$on = True
$off = False
$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 == True Then
      DrawXHair()
  ElseIf $on == False Then
      ;Do Nothing
      ;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($x,$y)
      Sleep(50)
   WEnd
EndFunc
Func swap(ByRef $a, ByRef $B)
    if ($a == false or $a == True) then $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func TogXHair()
    DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
    Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   swap($on, $off)
EndFunc

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

Func Exitt()
   ;ProcessClose("explorer.exe")
   Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   MsgBox(0,"Simple Xhair","Made by DarkShadow. Please visit www.VACDisabled.net and www.DDCodingCrew.com")
   Sleep(500)
   Exit
EndFunc

Func pict1($x,$y)
    ;To help you find it easier
    if ($on == true) Then ;draw this shape
     ;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 ^^^
 Else
     ;Draw This Shape!
     DLLCall("gdi32.dll", "none", "Rectangle", "long", $DC[0], "int", $x, "int", $y, "int", $x+25, "int", $y+25)

   ;DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
   EndIf
EndFunc
#endregion;end funcs

is that what you were looking for?

Edited by CHRIS95219
Link to comment
Share on other sites

So if I were to have more then two things should I set $on to be a number instead of 0/1 and instead of swapping $on and $off have it increment to the number of shapes I have then reset?

Like:

#Include <Misc.au3>
#NoTrayIcon

HotKeySet("{PGUP}","TogXHair")
HotKeySet("{END}","Exitt")
Opt("ColorMode",0)
Global $dc
Global $x = @DesktopWidth/2
Global $y = @DesktopHeight/2
Global $color
Global $dll
Global $xhclr
Global $on
Global $off
Global $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")

$on = True
$off = False
$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 == True Then
      DrawXHair()
  ElseIf $on == False Then
      ;Do Nothing
      ;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($x,$y)
    Sleep(50)
   WEnd
EndFunc
Func swap(ByRef $a, ByRef $B)
    if ($a == false or $a == True) then $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func TogXHair()
    DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
    Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   ;swap($on, $off)
   If $on >= 3 Then
       $on = $on + 1
   Else
       $on = 1
   EndIf
EndFunc

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

Func Exitt()
   ;ProcessClose("explorer.exe")
   Run("rundll32 user32.dll,UpdatePerUserSystemParameters")
   MsgBox(0,"Simple Xhair","Made by DarkShadow. Please visit www.VACDisabled.net and www.DDCodingCrew.com")
   Sleep(500)
   Exit
EndFunc

Func pict1($x,$y)
    ;To help you find it easier
    If $on = 1 Then ;draw this shape
    ;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 ^^^
 ElseIf $on = 2 Then ;Draw This Shape!
     ;DLLCall("gdi32.dll", "none", "Rectangle", "long", $DC[0], "int", $x-15, "int", $y-15, "int", $x+15, "int", $y+15)
    drawpix($dc,$x+2,$y+2,$xhclr)
    drawpix($dc,$x+3,$y+3,$xhclr)
    drawpix($dc,$x+4,$y+4,$xhclr)
    drawpix($dc,$x+5,$y+5,$xhclr)
    ;drawpix($dc,$x-1,$y,$xhclr)
    drawpix($dc,$x-2,$y-2,$xhclr)
    drawpix($dc,$x-3,$y-3,$xhclr)
    drawpix($dc,$x-4,$y-4,$xhclr)
    drawpix($dc,$x-5,$y-5,$xhclr)
    ;drawpix($dc,$x,$y+1,$xhclr)
    drawpix($dc,$x+2,$y-2,$xhclr)
    drawpix($dc,$x+3,$y-3,$xhclr)
    drawpix($dc,$x+4,$y-4,$xhclr)
    drawpix($dc,$x+5,$y-5,$xhclr)
    ;drawpix($dc,$x,$y-1,$xhclr)
    drawpix($dc,$x-2,$y+2,$xhclr)
    drawpix($dc,$x-3,$y+3,$xhclr)
    drawpix($dc,$x-4,$y+4,$xhclr)
    drawpix($dc,$x-5,$y+5,$xhclr)
    ;
    ;drawpix($dc,$x+2,$y+2,$xhclr)
ElseIf $on = 3 Then
    drawpix($dc,$x+2,$y+2,$xhclr)
    drawpix($dc,$x+3,$y+3,$xhclr)
    drawpix($dc,$x+4,$y+4,$xhclr)
    drawpix($dc,$x+5,$y+5,$xhclr)
    
    drawpix($dc,$x-2,$y-2,$xhclr)
    drawpix($dc,$x-3,$y-3,$xhclr)
    drawpix($dc,$x-4,$y-4,$xhclr)
    drawpix($dc,$x-5,$y-5,$xhclr)
    
    drawpix($dc,$x+2,$y-2,$xhclr)
    drawpix($dc,$x+3,$y-3,$xhclr)
    drawpix($dc,$x+4,$y-4,$xhclr)
    drawpix($dc,$x+5,$y-5,$xhclr)
    
    drawpix($dc,$x-2,$y+2,$xhclr)
    drawpix($dc,$x-3,$y+3,$xhclr)
    drawpix($dc,$x-4,$y+4,$xhclr)
    drawpix($dc,$x-5,$y+5,$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-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+2,$xhclr)
    drawpix($dc,$x,$y+3,$xhclr)
    drawpix($dc,$x,$y+4,$xhclr)
    drawpix($dc,$x,$y+5,$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)
   EndIf
EndFunc
#endregion;end funcs

(This doesn't work and I'm not sure why... would you mind explaining it?)

Edited by darkshadow791
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...