Jump to content

Search the Community

Showing results for tags 'Crosshairs'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. CrossHairs (Full-Screen) This UDF utilizes GUI manipulation to simulate full-screen crosshairs. Example code is included. An additional UDF is bundled in the package: _MouseCursorFuncs (not a full-featured UDF, just one with functions I use now and then). Note that this would be better controlled using a Mouse Event Handler. *edits 3/26/2010: Added a new function to alter the properties of the Crosshairs (_XHairSetDisplayProps) - better than destroying/recreating the Crosshairs!Updated the example to show how the new function can be used. It also shows a way to deal with Screen-resolution changes.Example code: #include <_CrossHairs.au3> #include <_MouseCursorFuncs.au3> ; =============================================================================================================================== ; <TestCrossHairs.au3> ; ; Simple test of _Crosshairs UDF. Employs the _MouseCursorFuncs UDF as well ; ; Author: Ascend4nt ; =============================================================================================================================== ;#NoTrayIcon AutoItSetOption("TrayAutoPause",0) ; =============================================================================================================================== ; GLOBAL VARIABLES ; =============================================================================================================================== Global $bHKPressed=False,$bPropertyHKPressed=False,$iResolutionchangeMsg=0 ; =============================================================================================================================== ; HOTKEY FUNCTIONS ; =============================================================================================================================== ; ESC Key Pressed: Func _HotKeyPressed() $bHKPressed=True EndFunc ; ALT-P Pressed: Func _ChangeXHairProperties() ; 'Grow' the crosshairs and set them to Red, or alternately shrink them and set them to whitish If Not $bPropertyHKPressed Then _XHairSetDisplayProps(25,25,0xFF0000) Else _XHairSetDisplayProps(8,8,0xF0F0F0) EndIf $bPropertyHKPressed=Not $bPropertyHKPressed EndFunc ; =============================================================================================================================== ; WINDOWS MESSAGE HANDLER FUNCTIONS ; =============================================================================================================================== ; =============================================================================================================================== ; Func _Resolutionchanged($hWnd,$iMsg,$wParam,$lParam) ; ; Note this registers multiple-monitor settings changes too, but will only report on the primary monitor's resolution ; This is why we would need to call _WinAPI_GetSystemMetrics() to get the Virtual width/height ; =============================================================================================================================== Func _Resolutionchanged($hWnd,$iMsg,$wParam,$lParam) $iResolutionchangeMsg+=1 Return 'GUI_RUNDEFMSG' ; From <GUIConstantsEx.au3> Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG' EndFunc ; =================================================================================================================== ; START MAIN CODE ; =================================================================================================================== Dim $aNewMousePos ; Create the crosshairs (but don't make them visible yet) _XHairInit(11,11) HotKeySet("{ESC}","_HotKeyPressed") ; Alt-p switches between two alternate CrossHair properties HotKeySet("!p","_ChangeXHairProperties") ; ----------------------------------------------------------------------------------------------------| ; Register Display-Mode changes to our function. ; NOTE that a GUI (*any* GUI) MUST be created or else the WM_DISPLAYCHANGE message won't be received ; Luckily, we've just created four GUI's using _XHairInit() and don't need to create any further ; ALSO note that this is called for *every* GUI that is created (for *just* X-Hairs, thats 4 calls) ; ----------------------------------------------------------------------------------------------------| GUIRegisterMsg(0x007E,"_Resolutionchanged") ; WM_DISPLAYCHANGE 0x007E _MouseHideAllCursors() ;~ _MouseReplaceAllCursors() ; Alternatively replace all cursors with custom crosshair While Not $bHKPressed ; 4 Messages are sent, 1 for each GUI created If $iResolutionchangeMsg>=4 Then ; Call with no arguments so that it will retain old properties but adjust to new resolution _XHairSetDisplayProps() $iResolutionchangeMsg=0 EndIf $aNewMousePos=MouseGetPos() _XHairShow($aNewMousePos[0],$aNewMousePos[1]) Sleep(5) WEnd ; Unregister Display Mode change function GUIRegisterMsg(0x007E,"") ; WM_DISPLAYCHANGE 0x007E ; Destroy Crosshairs _XHairUnInit() ; And restore all system cursors back to normal _MouseRestoreAllCursors()Download the ZIP from my site Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
×
×
  • Create New...