Jump to content

How to Change the Location of a Script


 Share

Recommended Posts

This is a Script someone wrote to create a crosshair on your screen:

HotKeySet("{ESC}","Quit"); Press ESC to quit

Global $CENTER_X = Int(@DesktopWidth/2)

Global $CENTER_Y = Int(@DesktopHeight/2)

$REFRESH = InputBox("DrawLines","Refresh time","5")

While 1

DrawLines()

Sleep(GUICtrlRead($REFRESH*1000))

WEnd

Func DrawLines()

$DC = DllCall ("user32.dll", "int", "GetDC", "hwnd", "")

For $INDEX = $Center_X - 25 To $CENTER_X + 25

DrawPixel($DC,$INDEX,$CENTER_Y,0x000000)

Next

For $INDEX = $CENTER_Y - 25 To $CENTER_Y + 25

DrawPixel($DC,$CENTER_X,$INDEX,0x000000)

Next

EndFunc

Func DrawPixel($hDC,$X,$Y,$COLOR)

DllCall ("gdi32.dll", "long", "SetPixel", "long", $hDC[0], "long", $X, "long", $Y, "long", $COLOR)

EndFunc

Func Quit()

Exit

EndFunc

How would I modify the location of this, for Example, I want to move the crosshair up

Edited by Hotwc
Link to comment
Share on other sites

I figured that, but what options do I have to Change it?

Like what would I replace $Center_X with?

With anything you want. It's up to your imagination. $CENTER_X, and $CENTER_Y are simply just the (x, y)-coordinate of the "crosshair".

The following script will move the "crosshair" from middle of the screen to the left after the given amount of time.

HotKeySet("{ESC}","Quit"); Press ESC to quit
Global $CENTER_X = Int(@DesktopWidth/2)
Global $CENTER_Y = Int(@DesktopHeight/2)
$REFRESH = InputBox("DrawLines","Refresh time","5")
While 1
DrawLines()
Sleep(GUICtrlRead($REFRESH*1000))
$CENTER_X -= 1 ;new line added
WEnd

Func DrawLines()
$DC = DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
For $INDEX = $Center_X - 25 To $CENTER_X + 25
DrawPixel($DC,$INDEX,$CENTER_Y,0x000000)
Next
For $INDEX = $CENTER_Y - 25 To $CENTER_Y + 25
DrawPixel($DC,$CENTER_X,$INDEX,0x000000)
Next
EndFunc

Func DrawPixel($hDC,$X,$Y,$COLOR)
DllCall ("gdi32.dll", "long", "SetPixel", "long", $hDC[0], "long", $X, "long", $Y, "long", $COLOR)
EndFunc

Func Quit()
Exit
EndFunc
Link to comment
Share on other sites

With anything you want. It's up to your imagination. $CENTER_X, and $CENTER_Y are simply just the (x, y)-coordinate of the "crosshair".

The following script will move the "crosshair" from middle of the screen to the left after the given amount of time.

HotKeySet("{ESC}","Quit"); Press ESC to quit
Global $CENTER_X = Int(@DesktopWidth/2)
Global $CENTER_Y = Int(@DesktopHeight/2)
$REFRESH = InputBox("DrawLines","Refresh time","5")
While 1
DrawLines()
Sleep(GUICtrlRead($REFRESH*1000))
$CENTER_X -= 1 ;new line added
WEnd

Func DrawLines()
$DC = DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
For $INDEX = $Center_X - 25 To $CENTER_X + 25
DrawPixel($DC,$INDEX,$CENTER_Y,0x000000)
Next
For $INDEX = $CENTER_Y - 25 To $CENTER_Y + 25
DrawPixel($DC,$CENTER_X,$INDEX,0x000000)
Next
EndFunc

Func DrawPixel($hDC,$X,$Y,$COLOR)
DllCall ("gdi32.dll", "long", "SetPixel", "long", $hDC[0], "long", $X, "long", $Y, "long", $COLOR)
EndFunc

Func Quit()
Exit
EndFunc

What you modified broke the script, it make multiple crosshairs

How do I define where the Origin is

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...