Sign in to follow this  
Followers 0
snoopy

need alittle help, im confused...

4 posts in this topic

#1 ·  Posted (edited)

need alittle help, im confused...

well first of all, all i really wanted to ask is how to make it randomly press alt+1 to -alt+9 , randomly from time to time, not very ofter, i acctually made alot of efford and couldent find it, and if i acctually did, it gave off lots of errors... this is as far as ive gotter, and i want it to do alt+1 to 9 randomly on these 2 boxchecks that i currently have done, thank you!

#AutoIt3Wrapper_Run_Debug_Mode=Y
#include <GUIConstants.au3>
#include<WindowsConstants.au3>

Global $f_Run = False, $f_AnyChecked = False

Global $Form1 = GUICreate("Form1", 625, 444, 189, 146)
$Pic1 = GUICtrlCreatePic("C:\Users\Snoopy\Desktop\art", 0, 0, 625, 441, 0)
GUISetState($GUI_DISABLE)
GUICtrlSetState($Pic1, $GUI_DISABLE)
Global $Credits = GUICtrlCreateButton("Credits", 0, 0, 153, 65, 0)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
Global $MyButton1 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0)
GUICtrlSetFont(-1, 15, 800, 0, "MS Serif")
GUICtrlSetBkColor(-1, 0xFFFFE1)
Global $MyButton2 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0)
GUICtrlSetFont(-1, 15, 800, 0, "MS Serif")
GUICtrlSetBkColor(-1, 0xFFFFE1)

$checkbox_dummy_start = GUICtrlCreateDummy()
Global $CheckBox1 = GUICtrlCreateCheckbox("Maggot", 520, 32, 100, 30, 0)
Global $CheckBox2 = GUICtrlCreateCheckbox("Bat", 520, 72, 100, 30, 0)
Global $CheckBox3 = GUICtrlCreateCheckbox("Snake", 520, 112, 100, 30, 0)
Global $CheckBox4 = GUICtrlCreateCheckbox("Spider", 520, 160, 100, 30, 0)
$checkbox_dummy_end = GUICtrlCreateDummy()
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Credits
            MsgBox(64, "Credits", "Snoopy")

        Case $MyButton1
            HotKeySet("{F5}", "_StopIt")
            $f_Run = True
            While $f_Run
                $f_AnyChecked = False
                If BitAND(GUICtrlRead($CheckBox1), $GUI_CHECKED) Then
                    $f_AnyChecked = True
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0xfdf9f8)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    $r = Random(0, 6, 1)
                    MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1)
                EndIf

            WEnd
        Case $MyButton2
            HotKeySet("{F5}", "_StopIt")
            $f_Run = True
            While $f_Run
                $f_AnyChecked = False
                If BitAND(GUICtrlRead($CheckBox2), $GUI_CHECKED) Then
                    $f_AnyChecked = True
                    Local $randomcoords[7][2] = [[289, 83],[200, 77],[200, 93],[200, 108],[200, 124],[200, 139],[200, 156]]
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    $r = Random(0, 6, 1)
                    MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1)
                EndIf
                If BitAND(GUICtrlRead($CheckBox3), $GUI_CHECKED) Then
                    $f_AnyChecked = True
                    MsgBox(64, "Checkbox 3", "CheckBox 3 is checked", 1)
                EndIf
                If BitAND(GUICtrlRead($CheckBox4), $GUI_CHECKED) Then
                    $f_AnyChecked = True
                    MsgBox(64, "Checkbox 4", "CheckBox 4 is checked", 1)
                EndIf
                If Not $f_AnyChecked Then ExitLoop
            WEnd
            HotKeySet("{F5}")
    EndSwitch
WEnd

Func _StopIt()
    $f_Run = False
EndFunc ;==>_StopIt


Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Switch $iIDFrom
        Case $checkbox_dummy_start To $checkbox_dummy_end
            For $i = $checkbox_dummy_start To $checkbox_dummy_end
                If $i <> $iIDFrom Then GUICtrlSetState($i, 4)
            Next
    EndSwitch
EndFunc ;==>WM_COMMAND
Edited by snoopy

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I wrote this simple function that will do the job.

I included an example.

You can use Adlib to have this automatically run in the background if you want.

-Kenny

;========== TESTING =============
HotKeySet("!" & "1", "Pressed1")
HotKeySet("!" & "6", "Pressed6")
Func Pressed1()
    MsgBox(0,"","ALT+1 Pressed")
EndFunc
Func Pressed6()
    MsgBox(0,"","ALT+6 Pressed")
EndFunc

;======== MAIN SCRIPT ===========
Global $LastNum
While 1
    Sleep(1000)
    RandomAltCombo()
WEnd

Func RandomAltCombo()
    $Num = Random(1, 9, 1)
    If $Num = $LastNum Then
        Do
            $Num = Random(1, 9, 1)
        Until $Num <> $LastNum
    EndIf
    Send("!" & $Num)
    $LastNum = $Num
EndFunc
Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

though still not sure where to put it, ive changed my script alittle .. here, any ideas?. thanks..

#include <GUIConstants.au3>
#include<WindowsConstants.au3>

Global $f_Run = False, $f_AnyChecked = False

Global $Form1 = GUICreate("Form1", 625, 444, 189, 146)
Global $MyButton1 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0)
GUICtrlSetFont(-1, 15, 800, 0, "MS Serif")
GUICtrlSetBkColor(-1, 0xFFFFE1)

; Create box
GUICtrlCreateGroup ( "Actions", 500, 30, 125, 170)
Opt("GUICoordMode",0); Relative coords
$hRadio1 = GUICtrlCreateRadio("Bat",      10, 20, 130, 30)
$hRadio2 = GUICtrlCreateRadio("Maggot",       -1, 30, 130, 30)
$hRadio3 = GUICtrlCreateRadio("Mountain Snake",       -1, 30, 130, 30)
$hRadio4 = GUICtrlCreateRadio("Fluffy",  -1, 30, 130, 30)
Opt("GUICoordMode",1); GUI coords

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MyButton1
            HotKeySet("{F5}", "_StopIt")
            $f_Run = True
            While $f_Run
                $f_AnyChecked = False
                For $i = $hRadio1 To $hRadio1 + 3
                    If BitAND(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then
                        $Ispressed = $i - $hRadio1 + 1; $Ispressed is now the number of the radio
                        ExitLoop                     ; Get out of the For...Next loop
                    EndIf
                Next
                
                Switch $Ispressed
                    Case 1
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    
                    
                    
                    Case 2
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeefee)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0xeeefee)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Case 3
                     $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0x473800)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0x473800)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Case 4
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xffffff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0xffffff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                EndSwitch

            WEnd
            HotKeySet("{F5}")
    EndSwitch
WEnd
        
Func _StopIt()
    $f_Run = False
EndFunc ;==>_StopIt

i understand that the Global has to be at the top, but where do i put the rest of the code?. tnx

Edited by snoopy

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here you go I added the function/variables and added two example locations in your script.

Another option I didn't list is you could also use the AdlibEnable() when Start is hit, and then AdlibDisable() when F5 is it.

#include <GUIConstants.au3>
#include<WindowsConstants.au3>

Global $f_Run = False, $f_AnyChecked = False, $LastNum

Global $Form1 = GUICreate("Form1", 625, 444, 189, 146)
Global $MyButton1 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0)
GUICtrlSetFont(-1, 15, 800, 0, "MS Serif")
GUICtrlSetBkColor(-1, 0xFFFFE1)

; Create box
GUICtrlCreateGroup ( "Actions", 500, 30, 125, 170)
Opt("GUICoordMode",0); Relative coords
$hRadio1 = GUICtrlCreateRadio("Bat",      10, 20, 130, 30)
$hRadio2 = GUICtrlCreateRadio("Maggot",    -1, 30, 130, 30)
$hRadio3 = GUICtrlCreateRadio("Mountain Snake",    -1, 30, 130, 30)
$hRadio4 = GUICtrlCreateRadio("Fluffy",  -1, 30, 130, 30)
Opt("GUICoordMode",1); GUI coords

;Use this line if you want the keys sent continuously while the script is running
;AdlibEnable("RandomAltCombo", 500)

;You can use this command to stop the above process later in the script
;AdlibDisable()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MyButton1
            HotKeySet("{F5}", "_StopIt")
            $f_Run = True
            While $f_Run
        ;You could place it here instead to only send the keys while $f_run is true
        ;RandomAltCombo()
                $f_AnyChecked = False
                For $i = $hRadio1 To $hRadio1 + 3
                    If BitAND(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then
                        $Ispressed = $i - $hRadio1 + 1; $Ispressed is now the number of the radio
                        ExitLoop                ; Get out of the For...Next loop
                    EndIf
                Next
                
                Switch $Ispressed
                    Case 1
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0x6d7d98)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    
                    
                    
                    Case 2
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeefee)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0xeeefee)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Case 3
                     $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0x473800)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0x473800)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Case 4
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xffffff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                    Sleep(100)
                    $pixelSearch = PixelSearch(153, 62, @DesktopWidth, @DesktopHeight, 0xffffff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                    EndIf
                EndSwitch

            WEnd
            HotKeySet("{F5}")
    EndSwitch
WEnd
        
Func _StopIt()
    $f_Run = False
EndFunc;==>_StopIt

Func RandomAltCombo()
    $Num = Random(1, 9, 1);Selects a random number between 1 and 9
    If $Num = $LastNum Then
        Do
            $Num = Random(1, 9, 1);Selects a new number in the even that the same number is recieved
        Until $Num <> $LastNum
    EndIf
    Send("!" & $Num)
    $LastNum = $Num
EndFunc

______________________________

Just as an FYI:

You can insert Func's anywhere you want other than a loop, because they only execute when called no matter where they are.

But always do it after you declare your variables or you can get errors from Au3Check.

I generally add them at the bottom of the script like you did, it's simpler when going over your code.

Thanks,

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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