Jump to content
Sign in to follow this  
CyNDeR

Trying to get this script to run minimized.

Recommended Posts

CyNDeR

I wrote a script to randomly paint in mspaint using airbrush, but i cant get it to work unless the window has focus. Is there any way to get this to work without having focus and while being minimized? Here is the script:

HotKeySet("{ESC}", "End")
Run("mspaint.exe")
WinWaitActive("[CLASS:MSPaintApp]")
Setup()
While 1
    PickBrush()
    PickColor()
    Draw()
WEnd
Func Setup()
    ControlClick("", "", 59415, "left", 1, 43, 42)
    ControlClick("", "", 59416, "left", 1, 41, 15)
    ControlClick("", "", "[CLASS:Afx:1000000:8]")
    ControlClick("", "", 59415, "left", 1, 18, 116)
EndFunc   ;==>Setup
Func PickBrush()
    $Brush = Random(1, 3, 1)
    Switch $Brush
        Case 1
            ControlClick("", "", 59415, "left", 1, 19, 227)
        Case 2
            ControlClick("", "", 59415, "left", 1, 39, 227)
        Case 3
            ControlClick("", "", 59415, "left", 1, 30, 259)
    EndSwitch
EndFunc   ;==>PickBrush
Func PickColor()
    $color = Random(1, 28, 1)
    Switch $color
        Case 1
            ControlClick("", "", 59416, "left", 1, 41, 15)
        Case 2
            ControlClick("", "", 59416, "left", 1, 56, 15)
        Case 3
            ControlClick("", "", 59416, "left", 1, 72, 15)
        Case 4
            ControlClick("", "", 59416, "left", 1, 88, 15)
        Case 5
            ControlClick("", "", 59416, "left", 1, 104, 15)
        Case 6
            ControlClick("", "", 59416, "left", 1, 120, 15)
        Case 7
            ControlClick("", "", 59416, "left", 1, 136, 15)
        Case 8
            ControlClick("", "", 59416, "left", 1, 152, 15)
        Case 9
            ControlClick("", "", 59416, "left", 1, 169, 15)
        Case 10
            ControlClick("", "", 59416, "left", 1, 185, 15)
        Case 11
            ControlClick("", "", 59416, "left", 1, 200, 15)
        Case 12
            ControlClick("", "", 59416, "left", 1, 216, 15)
        Case 13
            ControlClick("", "", 59416, "left", 1, 232, 15)
        Case 14
            ControlClick("", "", 59416, "left", 1, 248, 15)
        Case 15
            ControlClick("", "", 59416, "left", 1, 41, 32)
        Case 16
            ControlClick("", "", 59416, "left", 1, 56, 32)
        Case 17
            ControlClick("", "", 59416, "left", 1, 72, 32)
        Case 18
            ControlClick("", "", 59416, "left", 1, 88, 32)
        Case 19
            ControlClick("", "", 59416, "left", 1, 104, 32)
        Case 20
            ControlClick("", "", 59416, "left", 1, 120, 32)
        Case 21
            ControlClick("", "", 59416, "left", 1, 136, 32)
        Case 22
            ControlClick("", "", 59416, "left", 1, 152, 32)
        Case 23
            ControlClick("", "", 59416, "left", 1, 169, 32)
        Case 24
            ControlClick("", "", 59416, "left", 1, 185, 32)
        Case 25
            ControlClick("", "", 59416, "left", 1, 200, 32)
        Case 26
            ControlClick("", "", 59416, "left", 1, 216, 32)
        Case 27
            ControlClick("", "", 59416, "left", 1, 232, 32)
        Case 28
            ControlClick("", "", 59416, "left", 1, 248, 32)
    EndSwitch
EndFunc   ;==>PickColor
Func Draw()
    $Rnd = Random(2, 500, 1)
    For $i = 1 To $Rnd
        $x = Random(3, 959, 1)
        $y = Random(3, 608, 1)
        ControlClick("", "", "[CLASS:Afx:1000000:8]", "left", 1, $x, $y)
    Next
EndFunc   ;==>Draw
Func End()
    Exit
EndFunc   ;==>End

My scripts: Random Painter

Share this post


Link to post
Share on other sites
Richard Robertson

The problem is that you are using "" for the window parameter on all the calls. If you set that to the paint window, it will work just fine.

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  

×