Jump to content

[NOT RESOLVED] make crosshair


FireFox
 Share

Recommended Posts

Hi,

I've made script for crosshair with some functions but only horizontal line of crosshair is visible :) here is my script :

#include <WindowsConstants.au3>
 #include <EditConstants.au3>
 #include <GUIConstantsEx.au3>
 #include <Constants.au3>
 #include <WinAPI.au3>
 Opt("GuiOnEventMode", 1)
 Opt("TrayOnEventMode", 1)
 Opt("TrayMenuMode", 1)
 
 $CHMENU = TrayCreateMenu("CH >>")
 TrayCreateItem("Global", $CHMENU)
 TrayItemSetOnEvent(-1, "_Global")
 $ON = TrayCreateItem("ON", $CHMENU)
 TrayItemSetOnEvent(-1, "_ON")
 $OFF = TrayCreateItem("OFF", $CHMENU)
 TrayItemSetOnEvent(-1, "_OFF")
 TrayItemSetState($OFF,$TRAY_CHECKED)
 TrayCreateItem("")
 TrayCreateItem("Exit")
 TrayItemSetOnEvent(-1, "_Exit")
 
 Local $HDL1, $HDL2, $win1, $win2, $RECT1, $RECT2
 Global $SHOW = True
 
 #Region Global --------------------------------------------------------------------------
 $win = GUICreate("Crosshair <d3montools>", 310, 130, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW))
 GUISetOnEvent($GUI_EVENT_CLOSE, "_HIDEWIN")
 
 GUICtrlCreateGroup("Transparency", 5, 80, 165, 45)
 $TRANS = GUICtrlCreateSlider(10, 94, 125, 25)
 GUICtrlSetLimit(-1, 255, 0)
 $TE = GUICtrlCreateEdit("", 135, 97, 25, 17, $ES_READONLY)
 
 GUICtrlCreateGroup("Panel", 175, 5, 130, 120)
 GUICtrlCreateLabel("Crosshair pos ", 185, 23)
 GUICtrlCreateButton("Check", 255, 20, 40, 20)
 GUICtrlSetOnEvent(-1, "_Auto")
 
 GUICtrlCreateLabel("Color I ", 185, 50)
 $CI = GUICtrlCreateEdit("", 225, 48, 70, 17, $ES_WANTRETURN)
 GUICtrlCreateLabel("Color II", 185, 72)
 $CII = GUICtrlCreateEdit("", 225, 70, 70, 17, $ES_WANTRETURN)
 
 GUICtrlCreateLabel("Title game", 185, 100)
 $Title = GUICtrlCreateEdit("", 240, 98, 55, 17, $ES_AUTOVSCROLL)
 
 GUICtrlCreateButton("SAVE", 100, 5, 50, 17)
 GUICtrlSetOnEvent(-1, "_SAVE")
 
 
 GUICtrlCreateTab(5, 5, 160, 75)
 GUICtrlCreateTabItem("CH 1")
 GUICtrlCreateLabel("Left :", 10, 37)
 $LEFT = GUICtrlCreateEdit("", 40, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Top :", 10, 57)
 $TOP = GUICtrlCreateEdit("", 40, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Width :", 90, 37)
 $WIDTH = GUICtrlCreateEdit("", 130, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Height :", 90, 57)
 $HEIGHT = GUICtrlCreateEdit("", 130, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 
 GUICtrlCreateTabItem("CH 2")
 GUICtrlCreateLabel("Left :", 10, 37)
 $LEFT2 = GUICtrlCreateEdit("", 40, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Top :", 10, 57)
 $TOP2 = GUICtrlCreateEdit("", 40, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Width :", 90, 37)
 $WIDTH2 = GUICtrlCreateEdit("", 130, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUICtrlCreateLabel("Height :", 90, 57)
 $HEIGHT2 = GUICtrlCreateEdit("", 130, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
 GUISetState(@SW_HIDE, $win)
 
 Func _Global()
     GUISetState(@SW_SHOW, $win)
     GUICtrlSetData($LEFT, FileReadLine(@TempDir & "\CH.txt", 1))
     GUICtrlSetData($TOP, FileReadLine(@TempDir & "\CH.txt", 2))
     GUICtrlSetData($WIDTH, FileReadLine(@TempDir & "\CH.txt", 3))
     GUICtrlSetData($HEIGHT, FileReadLine(@TempDir & "\CH.txt", 4))
     GUICtrlSetData($CI, FileReadLine(@TempDir & "\CH.txt", 5))
     GUICtrlSetData($TE, FileReadLine(@TempDir & "\CH.txt", 6))
     GUICtrlSetData($TRANS, FileReadLine(@TempDir & "\CH.txt", 6))
 
     GUICtrlSetData($LEFT2, FileReadLine(@TempDir & "\CH2.txt", 1))
     GUICtrlSetData($TOP2, FileReadLine(@TempDir & "\CH2.txt", 2))
     GUICtrlSetData($WIDTH2, FileReadLine(@TempDir & "\CH2.txt", 3))
     GUICtrlSetData($HEIGHT2, FileReadLine(@TempDir & "\CH2.txt", 4))
     GUICtrlSetData($CII, FileReadLine(@TempDir & "\CH2.txt", 5))
     GUICtrlSetData($Title, FileReadLine(@TempDir & "\CH2.txt", 6))
 EndFunc ;==>_Global
 
 If Not FileExists(@TempDir & "\CH.txt") Then
     _Global()
 EndIf
 
 Func _HIDEWIN()
     GUISetState(@SW_HIDE, $win)
 EndFunc ;==>_HIDEWIN
 
 Func _SAVE()
     FileDelete(@TempDir & "\CH.txt")
     FileDelete(@TempDir & "\CH2.txt")
     FileWrite(@TempDir & "\CH.txt", GUICtrlRead($LEFT))
     FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($TOP))
     FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($WIDTH))
     FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($HEIGHT))
     FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($CI))
     FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($TE))
 
     FileWrite(@TempDir & "\CH2.txt", GUICtrlRead($LEFT2))
     FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($TOP2))
     FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($WIDTH2))
     FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($HEIGHT2))
     FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($CII))
     FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($Title))
 EndFunc ;==>_SAVE
 
 Func _Auto()
     MsgBox(64, "Crosshair Auto Cursor", "Press Right mouse when cursor is where you want")
     Do;--------
         Sleep(50)
         $POS = MouseGetPos()
         GUICtrlSetData($LEFT, $POS[0])
         GUICtrlSetData($TOP, $POS[1])
     Until _IsPressed("02")
 EndFunc ;==>_Auto
 #EndRegion Global --------------------------------------------------------------------------
 
 #Region CROSSHAIR ACTIVE --------------------------------------------------------------------------
 Func _ON()
     TrayItemSetState($ON, $TRAY_CHECKED)
     TrayItemSetState($OFF, $TRAY_UNCHECKED)
     _ACTIVATE()
 EndFunc ;==>_ON
 
 Func _ACTIVATE()
     $HDL = WinGetHandle(FileReadLine(@TempDir & "\CH2.txt", 6), "")
 
   ;--------------------------------WIN1------------------------------------
     WinActivate(FileReadLine(@TempDir & "\CH2.txt", 6), "")
     WinWaitActive(FileReadLine(@TempDir & "\CH2.txt", 6), "", 30)
 
     $RECT1 = DllStructCreate($tagRECT)
     DllStructSetData($RECT1, "Left", FileReadLine(@TempDir & "\CH.txt", 1))
     DllStructSetData($RECT1, "Top", FileReadLine(@TempDir & "\CH.txt", 2))
     DllStructSetData($RECT1, "Right", FileReadLine(@TempDir & "\CH.txt", 3))
     DllStructSetData($RECT1, "Bottom", FileReadLine(@TempDir & "\CH.txt", 4))
 
     $L = FileReadLine(@TempDir & "\CH.txt", 1)
     $T = FileReadLine(@TempDir & "\CH.txt", 2)
     $W = FileReadLine(@TempDir & "\CH.txt", 3)
     $H = FileReadLine(@TempDir & "\CH.txt", 4)
 
     $win1 = GUICreate("", $W, $H, $L - $W / 2, $T - $H / 2, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $HDL)
     GUISetBkColor(FileReadLine(@TempDir & "\CH.txt", 5), $win1)
     WinSetTrans($win1, "", FileReadLine(@TempDir & "\CH.txt", 6))
     _Transparent($win1, 0xABCDEF)
     GUISetState(@SW_SHOW, $win1)
     GUISetState(@SW_DISABLE, $win1)
     $HDL1 = WinGetHandle($win1, "")
 
   ;--------------------------------WIN2------------------------------------
     WinActivate(FileReadLine(@TempDir & "\CH2.txt", 6), "")
     WinWaitActive(FileReadLine(@TempDir & "\CH2.txt", 6), "", 10)
 
     $RECT2 = DllStructCreate($tagRECT)
     DllStructSetData($RECT2, "Left", FileReadLine(@TempDir & "\CH2.txt", 1))
     DllStructSetData($RECT2, "Top", FileReadLine(@TempDir & "\CH2.txt", 2))
     DllStructSetData($RECT2, "Right", FileReadLine(@TempDir & "\CH2.txt", 3))
     DllStructSetData($RECT2, "Bottom", FileReadLine(@TempDir & "\CH2.txt", 4))
 
     $L2 = FileReadLine(@TempDir & "\CH2.txt", 1)
     $T2 = FileReadLine(@TempDir & "\CH2.txt", 2)
     $W2 = FileReadLine(@TempDir & "\CH2.txt", 3)
     $H2 = FileReadLine(@TempDir & "\CH2.txt", 4)
 
     $win2 = GUICreate("", $W2, $H2, $L2 - $W2 / 2, $T2 - $H2 / 2, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $HDL)
     GUISetBkColor(FileReadLine(@TempDir & "\CH.txt", 5), $win2)
     WinSetTrans($win2, "", FileReadLine(@TempDir & "\CH.txt", 6))
     _Transparent($win2, 0xABCDEF)
     GUISetState(@SW_SHOW, $win2)
     GUISetState(@SW_DISABLE, $win2)
     $HDL1 = WinGetHandle($win2, "")
 
     WinActivate(FileReadLine(@TempDir & "\CH2.txt", 6), "")
 EndFunc ;==>_ACTIVATE
 #EndRegion CROSSHAIR ACTIVE --------------------------------------------------------------------------
 
 #Region CROSSHAIR UNACTIVE ------------------------------------------------------------------------
 Func _OFF()
     TrayItemSetState($ON, $TRAY_UNCHECKED)
     TrayItemSetState($OFF, $TRAY_CHECKED)
     _UNACTIVATE()
 EndFunc ;==>_OFF
 
 Func _UNACTIVATE()
     Global $SHOW = True
     _WinAPI_ShowCursor(1)
     GUIDelete($win1)
     GUIDelete($win2)
 EndFunc ;==>_UNACTIVATE
 #EndRegion CROSSHAIR UNACTIVE ------------------------------------------------------------------------
 
 #Region While -------------------------------------------------------------------------------------
 While 1
     Sleep(10)
     $POS = MouseGetPos()
 
     If WinActive(FileReadLine(@TempDir & "\CH2.txt", 6), "") Then
         _WinAPI_RedrawWindow($HDL1, $RECT1 = 1, 0, $WM_PAINT)
         _WinAPI_RedrawWindow($HDL2, $RECT2 = 1, 0, $WM_PAINT)
 
         If _IsPressed("12") And _IsPressed("01") Then
             Do;----
                 Sleep(10)
             Until Not _IsPressed("12") Or Not _IsPressed("01")
         ElseIf _IsPressed("01") Then
             ControlClick(FileReadLine(@TempDir & "\CH2.txt", 6), "", "", "Left", 1, $POS[0], $POS[1])
         ElseIf _IsPressed("02") Then
             ControlClick(FileReadLine(@TempDir & "\CH2.txt", 6), "", "", "Right", 1, $POS[0], $POS[1])
         ElseIf _IsPressed("7B") Then
             If $SHOW = True Then
                 Global $SHOW = False
                 _WinAPI_ShowCursor(0)
             ElseIf $SHOW = False Then
                 Global $SHOW = True
                 _WinAPI_ShowCursor(1)
             EndIf
         EndIf
     EndIf
 
     If _IsPressed("74") Then
         _ON()
     ElseIf _IsPressed("75") Then
         _OFF()
     EndIf
 
     If WinActive($win, "") Then
         Sleep(250);----------------
         GUICtrlSetData($TE, GUICtrlRead($TRANS))
         GUICtrlSetColor($CI, GUICtrlRead($CI))
         GUICtrlSetColor($CII, GUICtrlRead($CII))
     EndIf
 WEnd
 #EndRegion While -------------------------------------------------------------------------------------
 
 
 #Region Func --------------------------------------------------------------------------------------
; #############################################
; Function Name:   _WinAPI_SetLayeredWindowAttributes
; Author(s):       Prog@ndy
; #############################################

 Func _Transparent($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
     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 Else
             Return 1
     EndSelect
 EndFunc ;==>_Transparent
 
 Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
     Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
     If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
     Return 0
 EndFunc ;==>_IsPressed
 
 Func _Exit()
     Exit
 EndFunc ;==>_Exit
 #EndRegion Func --------------------------------------------------------------------------------------

Thanks for anyhelp !

Edited by FireFox
Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I don't understand your code, so I can't say, why the crosshair isn't shown properly. Possibly, because you draw 2 GUIs...

[OT]Why is everyone copying functions without author???

Please add following lines to _Transparent(...) ( original name: _WinAPI_SetLayeredWindowAttributes)

; #############################################
; You are NOT ALLOWED to remove the following lines
; Function Name:   _WinAPI_SetLayeredWindowAttributes
; Author(s):       Prog@ndy
; #############################################
[/OT]

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

explain how to use it

I understand that is difficult...

Lets start :) :

*First if global window isn't active you have to go on tray, select "CH >>" menu and click on "Global"

-You have now global window, on tabitem "CH 1" you have horizontal line of crosshair parameters so place left,top,width,height of line

-Same thing for tab item "CH 2" but its for vertical line of crosshair

(you can put corsshair parameter with cursor with "Check" button)

*Transparency is for crosshair transparency of course ! Put it on 255 for crosshair will be visible

*Color I is for horizontal line of crosshair color

-Color II is for vertical line of crosshair color

*Put title of your window game in title edit

Keys :

-F5 Start crosshair

-F6 Stop crosshair

-F12 Start/Stop cursor

Thanks for help ^^

@ProgAndy

Sorry for that because I've got this function without any autor...i will edit it :)

Edited by FireFox
Link to comment
Share on other sites

_WinAPI_RedrawWindow($HDL1, $RECT1 = 1, 0, $WM_PAINT)

_WinAPI_RedrawWindow($HDL2, $RECT2 = 1, 0, $WM_PAINT)

what happens if you switch these lines?

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

_WinAPI_RedrawWindow($HDL1, $RECT1 = 1, 0, $WM_PAINT)

_WinAPI_RedrawWindow($HDL2, $RECT2 = 1, 0, $WM_PAINT)

what happens if you switch these lines?

Same thing :) ... only horizontal line is visible, perhaps 2nd window have problem... :)

Link to comment
Share on other sites

Already almost finished !

I have to fix two thing :

-Hexadecimal color of crosshair "0xFFFFFFFF" isn't same as hexadecimal color is use "0xFFFFFF"

-Can I add transparency to crosshair ?

Here is script (thanks to jaenster)

For instructions please report to reply #44 [/!\ add "Alt" for all keys to activate or unactivate all functions]

;Thanks to jaenster for crosshair fonction
  
  #include <WindowsConstants.au3>
  #include <EditConstants.au3>
  #include <GUIConstantsEx.au3>
  #include <Constants.au3>
  #include <WinAPI.au3>
  Opt("GuiOnEventMode", 1)
  Opt("TrayOnEventMode", 1)
  Opt("TrayMenuMode", 1)
  
  $CHMENU = TrayCreateMenu("CH >>")
  TrayCreateItem("Global", $CHMENU)
  TrayItemSetOnEvent(-1, "_Global")
  $ON = TrayCreateItem("ON", $CHMENU)
  TrayItemSetOnEvent(-1, "_ON")
  $OFF = TrayCreateItem("OFF", $CHMENU)
  TrayItemSetOnEvent(-1, "_OFF")
  TrayItemSetState($OFF, $TRAY_CHECKED)
  TrayCreateItem("")
  TrayCreateItem("Exit")
  TrayItemSetOnEvent(-1, "_Exit")
  TraySetToolTip("Crosshair <d3montools>" & @CRLF & "Initializing...")
  
  Local $L, $T, $W, $H, $L2, $T2, $W2, $H2, $BK, $BK2
  Global $CUR = True
  Global $CH = False
  
  #Region Global --------------------------------------------------------------------------
  $win = GUICreate("Crosshair <d3montools>", 310, 130, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW))
  GUISetOnEvent($GUI_EVENT_CLOSE, "_HIDEWIN")
  
  GUICtrlCreateGroup("Transparency", 5, 80, 165, 45)
  $TRANS = GUICtrlCreateSlider(10, 94, 125, 25)
  GUICtrlSetLimit(-1, 255, 0)
  $TE = GUICtrlCreateEdit("", 135, 97, 25, 17, $ES_READONLY)
  
  GUICtrlCreateGroup("Panel", 175, 5, 130, 120)
  GUICtrlCreateLabel("Crosshair pos ", 185, 23)
  GUICtrlCreateButton("Check", 255, 20, 40, 20)
  GUICtrlSetOnEvent(-1, "_Auto")
  
  GUICtrlCreateLabel("Color I ", 185, 50)
  $CI = GUICtrlCreateEdit("", 225, 48, 70, 17, $ES_WANTRETURN)
  GUICtrlCreateLabel("Color II", 185, 72)
  $CII = GUICtrlCreateEdit("", 225, 70, 70, 17, $ES_WANTRETURN)
  
  GUICtrlCreateLabel("Title game", 185, 100)
  $Title = GUICtrlCreateEdit("", 240, 98, 55, 17, $ES_AUTOVSCROLL)
  
  GUICtrlCreateButton("SAVE", 100, 5, 50, 17)
  GUICtrlSetOnEvent(-1, "_SAVE")
  
  
  GUICtrlCreateTab(5, 5, 160, 75)
  GUICtrlCreateTabItem("CH 1")
  GUICtrlCreateLabel("Left :", 10, 37)
  $LEFT = GUICtrlCreateEdit("", 40, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Top :", 10, 57)
  $TOP = GUICtrlCreateEdit("", 40, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Width :", 90, 37)
  $WIDTH = GUICtrlCreateEdit("", 130, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Height :", 90, 57)
  $HEIGHT = GUICtrlCreateEdit("", 130, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  
  GUICtrlCreateTabItem("CH 2")
  GUICtrlCreateLabel("Left :", 10, 37)
  $LEFT2 = GUICtrlCreateEdit("", 40, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Top :", 10, 57)
  $TOP2 = GUICtrlCreateEdit("", 40, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Width :", 90, 37)
  $WIDTH2 = GUICtrlCreateEdit("", 130, 35, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUICtrlCreateLabel("Height :", 90, 57)
  $HEIGHT2 = GUICtrlCreateEdit("", 130, 55, 30, 17, $ES_WANTRETURN + $ES_NUMBER)
  GUISetState(@SW_HIDE, $win)
  
  Func _Global()
      GUISetState(@SW_SHOW, $win)
      GUICtrlSetData($LEFT, FileReadLine(@TempDir & "\CH.txt", 1))
      GUICtrlSetData($TOP, FileReadLine(@TempDir & "\CH.txt", 2))
      GUICtrlSetData($WIDTH, FileReadLine(@TempDir & "\CH.txt", 3))
      GUICtrlSetData($HEIGHT, FileReadLine(@TempDir & "\CH.txt", 4))
      GUICtrlSetData($CI, FileReadLine(@TempDir & "\CH.txt", 5))
      GUICtrlSetData($TE, FileReadLine(@TempDir & "\CH.txt", 6))
      GUICtrlSetData($TRANS, FileReadLine(@TempDir & "\CH.txt", 6))
  
      GUICtrlSetData($LEFT2, FileReadLine(@TempDir & "\CH2.txt", 1))
      GUICtrlSetData($TOP2, FileReadLine(@TempDir & "\CH2.txt", 2))
      GUICtrlSetData($WIDTH2, FileReadLine(@TempDir & "\CH2.txt", 3))
      GUICtrlSetData($HEIGHT2, FileReadLine(@TempDir & "\CH2.txt", 4))
      GUICtrlSetData($CII, FileReadLine(@TempDir & "\CH2.txt", 5))
      GUICtrlSetData($Title, FileReadLine(@TempDir & "\CH2.txt", 6))
  EndFunc;==>_Global
  
  If Not FileExists(@TempDir & "\CH.txt") Then
      _Global()
  EndIf
  
  Func _HIDEWIN()
      GUISetState(@SW_HIDE, $win)
  EndFunc;==>_HIDEWIN
  
  Func _SAVE()
      FileDelete(@TempDir & "\CH.txt")
      FileDelete(@TempDir & "\CH2.txt")
      FileWrite(@TempDir & "\CH.txt", GUICtrlRead($LEFT))
      FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($TOP))
      FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($WIDTH))
      FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($HEIGHT))
      FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($CI))
      FileWrite(@TempDir & "\CH.txt", @CRLF & GUICtrlRead($TE))
  
      FileWrite(@TempDir & "\CH2.txt", GUICtrlRead($LEFT2))
      FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($TOP2))
      FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($WIDTH2))
      FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($HEIGHT2))
      FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($CII))
      FileWrite(@TempDir & "\CH2.txt", @CRLF & GUICtrlRead($Title))
  EndFunc;==>_SAVE
  
  Func _Auto()
      MsgBox(64, "Crosshair Auto Cursor", "Press Right mouse when cursor is where you want")
      Do;--------
          Sleep(50)
          $POS = MouseGetPos()
          GUICtrlSetData($LEFT, $POS[0])
          GUICtrlSetData($TOP, $POS[1])
      Until _IsPressed("02")
  EndFunc;==>_Auto
  #EndRegion Global --------------------------------------------------------------------------
  
  #Region CROSSHAIR ACTIVE --------------------------------------------------------------------------
  Func _ON()
      TrayItemSetState($ON, $TRAY_CHECKED)
      TrayItemSetState($OFF, $TRAY_UNCHECKED)
      _ACTIVATE()
  EndFunc;==>_ON
  
  Func _ACTIVATE()
      Global $L = FileReadLine(@TempDir & "\CH.txt", 1)
      Global $T = FileReadLine(@TempDir & "\CH.txt", 2)
      Global $W = FileReadLine(@TempDir & "\CH.txt", 3)
      Global $H = FileReadLine(@TempDir & "\CH.txt", 4)
      Global $BK = FileReadLine(@TempDir & "\CH.txt", 5)
  
      Global $L2 = FileReadLine(@TempDir & "\CH2.txt", 1)
      Global $T2 = FileReadLine(@TempDir & "\CH2.txt", 2)
      Global $W2 = FileReadLine(@TempDir & "\CH2.txt", 3)
      Global $H2 = FileReadLine(@TempDir & "\CH2.txt", 4)
      Global $BK2 = FileReadLine(@TempDir & "\CH2.txt", 5)
  
      Global $CH = True
  
      WinActivate(FileReadLine(@TempDir & "\CH2.txt", 6), "")
  EndFunc;==>_ACTIVATE
  #EndRegion CROSSHAIR ACTIVE --------------------------------------------------------------------------
  
  #Region CROSSHAIR UNACTIVE ------------------------------------------------------------------------
  Func _OFF()
      TrayItemSetState($ON, $TRAY_UNCHECKED)
      TrayItemSetState($OFF, $TRAY_CHECKED)
      _UNACTIVATE()
  EndFunc;==>_OFF
  
  Func _UNACTIVATE()
      Global $CUR = True
      Global $CH = False
      _WinAPI_ShowCursor(1)
  EndFunc;==>_UNACTIVATE
  #EndRegion CROSSHAIR UNACTIVE ------------------------------------------------------------------------
  
  #Region While -------------------------------------------------------------------------------------
  While 1
      Sleep(10)
      $POS = MouseGetPos()
      TraySetToolTip("Crosshair <d3montools>" & @CRLF & "CH : " & $CH & @CRLF & "CUR : " & $CUR)
  
;~   If WinActive(FileReadLine(@TempDir & "\CH2.txt", 6), "") Then
  
      If $CH = True Then
          _CH($L, $T, $W, $H)
          _CH2($L2, $T2, $W2, $H2)
      EndIf
  
      If _IsPressed("12") And _IsPressed("01") Then
          Do;----
              Sleep(10)
          Until Not _IsPressed("12") Or Not _IsPressed("01")
      ElseIf _IsPressed("01") Then
          ControlClick(FileReadLine(@TempDir & "\CH2.txt", 6), "", "", "Left", 1, $POS[0] - 50, $POS[1] + 50)
      ElseIf _IsPressed("02") Then
          ControlClick(FileReadLine(@TempDir & "\CH2.txt", 6), "", "", "Right", 1, $POS[0] - 50, $POS[1] + 50)
      ElseIf _IsPressed("12") And _IsPressed("7B") Then
          If $CUR = True Then
              Global $CUR = False
              _WinAPI_ShowCursor(0)
          ElseIf $CUR = False Then
              Global $CUR = True
              _WinAPI_ShowCursor(1)
          EndIf
      EndIf
;~   EndIf
  
      If _IsPressed("12") And _IsPressed("74") Then
          _ON()
      ElseIf _IsPressed("12") And _IsPressed("75") Then
          _OFF()
      EndIf
  
      If WinActive($win, "") Then
          Sleep(250);----------------
          GUICtrlSetData($TE, GUICtrlRead($TRANS))
          GUICtrlSetColor($CI, GUICtrlRead($CI))
          GUICtrlSetColor($CII, GUICtrlRead($CII))
      EndIf
  WEnd
  #EndRegion While -------------------------------------------------------------------------------------
  
  
  #Region Func --------------------------------------------------------------------------------------
  Func _CH($L, $T, $W, $H)
  
      For $Pixelx = 1 To $W
          $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", "")
          _drawpixel($dc, $L - $W / 2 + $Pixelx, $T - $H / 2, $BK)
          DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
      Next
  
      For $Pixely = 1 To $H
          $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", "")
          _drawpixel($dc, $L - $W / 2, $T - $H / 2 + $Pixely, $BK)
          DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
      Next
  EndFunc;==>_CH
  
  Func _CH2($L2, $T2, $W2, $H2)
      For $Pixelx2 = 1 To $W2
          $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", "")
          _drawpixel($dc, $L2 - $W2 / 2 + $Pixelx2, $T2 - $H2 / 2, $BK2)
          DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
      Next
  
      For $Pixely2 = 1 To $H2
          _drawpixel($dc, $L2 - $W2 / 2, $T2 - $H2 / 2 + $Pixely2, $BK2)
          DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
      Next
  EndFunc;==>_CH2
  
  Func _drawpixel($dc, $L, $T, $C)
      DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $L, "long", $T, "long", $C)
  EndFunc;==>_drawpixel
  
  Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
      Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
      If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
      Return 0
  EndFunc;==>_IsPressed
  
  Func _Exit()
      Exit
  EndFunc;==>_Exit
  #EndRegion Func --------------------------------------------------------------------------------------
Edited by FireFox
Link to comment
Share on other sites

Not sure if this will help you or not, but take a look through. I might be way off base though.

http://www.autoitscript.com/forum/index.ph...=66740&st=0

I've already make crosshair, thanks.

I just want to fix two things in my script :

-Hexadecimal color of crosshair "0xFFFFFFFF" isn't same as hexadecimal color is use "0xFFFFFF"

-Can I add transparency to crosshair ?

Link to comment
Share on other sites

It should be: 0x00FFFFFF = 0xFFFFFF :)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It should be: 0x00FFFFFF = 0xFFFFFF :)

Ok but for example I use GuiCtrlsetColor and for color i have if i want to take color of crosshair with 8caracters instead of 6caracters what ive to do ? Perhaps Hex or another thing to convert to good color

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