Sign in to follow this  
Followers 0
Xenobiologist

Mousemove Incl. Cursorchange

7 posts in this topic

HI,

another stupid mouseMove script. :-)

An absolut unnecessary script, but ...

I'd love to have a func which is able to save the current systemCursor then change the cursor during a script and restore it before ending he script. (gafrost???)

Here is the script:

#include<Array.au3>
#include <math.au3>
HotKeySet("{esc}", "end")
HotKeySet("1", "moveRandom")
HotKeySet("2", "moveButterfly")

Global Const $OCR_APPSTARTING = "AppStarting"
Global Const $OCR_NORMAL = 32512
Global Const $OCR_CROSS = 32515
Global Const $OCR_HAND = 32649
Global Const $OCR_IBEAM = 32513
Global Const $OCR_NO = 32648
Global Const $OCR_SIZEALL = 32646
Global Const $OCR_SIZENESW = 32643
Global Const $OCR_SIZENS = 32645
Global Const $OCR_SIZENWSE = 32642
Global Const $OCR_SIZEWE = 32644
Global Const $OCR_UP = 32516
Global Const $OCR_WAIT = 32514
Dim $mouseFuncs = 0
Dim $cursorArray
$cursorArray = _ArrayCreate ("3dgarro.cur")

$search = FileFindFirstFile(@WindowsDir & "\cursors\*.*")
If $search = -1 Then
    MsgBox(0, "Error", "No Cursors found!")
    Exit
EndIf

While 1
    $cursor = FileFindNextFile($search)
    If @error Then ExitLoop
    _ArrayAdd($cursorArray, $cursor)
WEnd
FileClose($search)

While 1
    If Random(0, 1, 1) = 1 Then
        changeCursor()
    EndIf
    Sleep(1500)
WEnd

Func changeCursor()
    $nr = Random($cursorArray[0], UBound($cursorArray) - 1, 1)
    _SetCursor(@WindowsDir & "\cursors\" & $cursorArray[$nr], $OCR_NORMAL)
EndFunc  ;==>changeCursor

Func _SetCursor($s_file, $i_cursor)
    Local $newhcurs, $lResult
    $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file)
    If Not @error Then
        $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor)
        If Not @error Then
            $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0])
        Else
            MsgBox(0, "Error", "Failed SetSystemCursor")
        EndIf
    Else
        MsgBox(0, "Error", "Failed LoadCursorFromFile")
    EndIf
EndFunc  ;==>_SetCursor

Func end()
    exit (0)
EndFunc  ;==>end

Func restoreCursor()
    Run("control panel")
    Sleep(200)
    Send("m" & "{Enter}")
    Sleep(200)
    Send("+{Tab}" & "{RIGHT}")
    Sleep(200)
    Send("{Enter}")
    Sleep(50)
    WinClose("Systemsteuerung"); <- German -> "control panel"
EndFunc  ;==>restoreCursor

Func moveRandom()
    While 1
        MouseMove(Random(0, @DesktopWidth, 1), Random(0, @DesktopHeight, 1))
        If Random(0, 1, 1) = 1 Then
        changeCursor()
        EndIf
    WEnd
EndFunc  ;==>moveRandom

Func moveButterfly()
    Global Const $PI = 3.1415926535897932384626433832795
    Dim $t
    Dim $expr
    For $theta = 0 To 924 * $PI;ALSO MAKE THE LOOP GO LONGER
        $t = _Radian ($theta)
        $expr = Exp(Cos($t)) - 2 * Cos(4 * $t) - Sin($t / 12) ^ 5
        $x = 400 + 100 * Cos($t) * $expr
        $y = 400 + 100 * Sin($t) * $expr
        ConsoleWrite($x & "," & $y & @LF);Use for debugging with SciTE
        If Random(0, 80, 1) = 1 Then
        changeCursor()
        EndIf
        MouseMove($x, $y, 1)
    Next
EndFunc  ;==>moveButterfly

Func OnAutoItStart()
;saveCurrentCursor()
EndFunc  ;==>OnAutoItStart

Func OnAutoItExit()
    restoreCursor()
EndFunc  ;==>OnAutoItExit

Func saveCurrentCursor()
;DllCall...
EndFunc  ;==>saveCurrentCursor

You have to press 1 or 2 for the different MouseMoves and change the func restoreCursor to your language.

:)

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



Error

Line 94

$t = _Radian ($theta)

$t = ^ ERROR

--------

any1 plz him fix it.

Share this post


Link to post
Share on other sites

Error

Line 94

$t = _Radian ($theta)

$t = ^ ERROR

--------

any1 plz him fix it.

Could easily be fixed by you:

#include <math.au3>


[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

I noticed that you restore the cursor via control panel, by pressing M you select mouse, but in dutch when you press M map options appears first. Also, when you click the tray icon and press Exit it won't press M at all..

Share this post


Link to post
Share on other sites

Hi,

this is no good script, it was just to show that I do not know how to restore the cursor. I was hoping that someone could tell me how to do it, so that you can easily change the cursor in your own gui or soemthing and then restore it afterwards. :">

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

no because there is no func for it you have to start --> control panel --> mouse --> cursor and then just --> ok

That should reset the cursor.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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