Jump to content

Script wont do anything?


 Share

Recommended Posts

error code 

>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\Scripts\Tests\Test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>16:23:40 AutoIt3.exe ended.rc:0
+>16:23:40 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.6734
HotKeySet("{F4}", _myExit())

Global $aCoordinates1[2] = [499, 582]

Global $aCoordinates2[2] = [672, 614]


While(1)


    $instrument = PixelSearch(602, 439, 601, 438, 0x434343, 1)

    if not(@error) Then

        $musicscore = PixelSearch(1185, 529, 1184, 528, 0xDDA03B, 1)
        If not(@error) Then
            MouseMove($musicscore[0], $musicscore[1], 3)
            Sleep(500)
            MouseClick("RIGHT", $musicscore[0], $musicscore[1], 1, 1)
        EndIf

    EndIf

    MouseClick("LEFT", random($aCoordinates1[0], $aCoordinates1[1]), Random($aCoordinates2[0], $aCoordinates2[1]))

   Sleep(Random(304000, 309043))

WEnd


Func _myExit()
    Exit
EndFunc

Any help are highly appreciatet... :-) 

 

Dequality.

Link to comment
Share on other sites

The issue is the way you set the hotkey, try this way:

HotKeySet("{F4}", '_myExit')

You were essencialy calling _myExit that way.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

5 hours ago, careca said:

The issue is the way you set the hotkey, try this way:

HotKeySet("{F4}", '_myExit')

You were essencialy calling _myExit that way.

Seems to work, only thing now is that it doesnt click inside the window when i start the script it goes to the top left corner of my screen & clicks there? :blink:

It doesnt actually click on the pixel its supposed to.. did i do something wrong with the area its searching? 

Edited by Dequality
Link to comment
Share on other sites

Put some debug messages in your script so can see what is going on (like consolewrite or msgbox).

Global $aCoordinates2[2] = [672, 614]

with random min MUST BE LOWER than the max otherwise you get 0 as a result...put some debug messages

  

Link to comment
Share on other sites

Okay, so i threw in that MsgBox(0, "Damn!", "We didnt find it! Q_Q"), tried it @ 2 spots, after first set of "if not (@error) then", and 2nd spots is in the code on here, it pops up @ both places if the things are as they are supposed (first if it finds the pixel @ the coords, 2nd if there is a error and it should start next pixel search..  The part which aint going off is the $musicscore = PixelSearch :blink:

While(1)


    $instrument = PixelSearch(437, 438, 523, 524, 0xDB9D39, 1)

    if not(@error) Then
    ElseIf (@error) Then
    MsgBox(0, "Damn!", "We didnt find it! Q_Q")
    $musicscore = PixelSearch(551, 604, 1239, 1476, 0xDDA03B, 1)

            If not(@error) Then
                MouseMove($musicscore[0], $musicscore[1], 3)
                Sleep(500)
                MouseClick("RIGHT", $musicscore[0], $musicscore[1]+50, 1, 1)
                Sleep(1500)
            EndIf

    EndIf



;~  MouseClick("LEFT", Random(500, 619), Random(594, 668), 1, 1)

    Sleep(Random(304000, 309043))

WEnd

When i throw in the MsgBox @ this point... it doesnt show up .. so what is wrong with my second pixelsearch setup? :blink:

Spoiler

C3SzqAi.png

 

Edited by Dequality
Link to comment
Share on other sites

Can you try it this way?

While 1
    $instrument = PixelSearch(437, 438, 523, 524, 0xDB9D39, 1)
    If $instrument <> @error Then
    ElseIf $instrument = @error Then
        MsgBox(0, "Damn!", "We didnt find it! Q_Q")
        $musicscore = PixelSearch(551, 604, 1239, 1476, 0xDDA03B, 1)
        If $musicscore <> @error Then
            MouseMove($musicscore[0], $musicscore[1], 3)
            Sleep(500)
            MouseClick("RIGHT", $musicscore[0], $musicscore[1] + 50, 1, 1)
            Sleep(1500)
        EndIf
    EndIf
;~  MouseClick("LEFT", Random(500, 619), Random(594, 668), 1, 1)
    Sleep(Random(304000, 309043))
WEnd

This way the error corresponds to that specific function.

Read about how @error is set and you'll see what i mean.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

$instrument = PixelSearch(437, 438, 523, 524, 0xDB9D39, 1)
    If $instrument <> @error Then
    ElseIf $instrument = @error Then

That won't work.  PixelSearch return an array of postion (x and y) IF the color has been found. Otherwise @error is set to 1 and return is empty.

So the correct way to do it would be :

$instrument = PixelSearch(437, 438, 523, 524, 0xDB9D39, 1)
    If not @error Then
      ; do something here $instrument[0] and $instrument[1] are correctly set
    Else
      ; do otherthing here - do not use $instrument
    endif

 

Link to comment
Share on other sites

Ty @Nine , already got it running though now i went to the next step and wanted to convert it to a EXE file and make a GUI for it.. but im kinda confused.. 

How do i make it so that the values in "Input" field will automatically be filled into the pixelsearch coords? can't really figure it out.. tried several ways & youtube.. <.< 

This is how i would like the UI to look.. 

Spoiler

yLgsRCu.png

 

This is the code i tried.. but for some reason it wont move to the coord typed into "Top_Left" field i did e.g. 1310, 454 and hitted the start button.. 

Error code i get is @@ "C:\Users\Dequality\AppData\Local\Temp\test.au3" (30) : ==> Subscript used on non-accessible variable.:
$Button3 = MouseClick("LEFT", $Top_Left[0], $Top_Left[1], 1, 1)
$Button3 = MouseClick("LEFT", $Top_Left^ ERROR
->15:31:59 AutoIt3.exe ended.rc:1
+>15:31:59 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 5.18 @@

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Auto_Stuff", 259, 184, -1, -1)
Global $Top_Left = GUICtrlCreateInput("Top_Left", 72, 32, 113, 21)
Global $Label1 = GUICtrlCreateLabel("Coords", 112, 8, 37, 17)
Global $Button2 = GUICtrlCreateButton("Stop - F4", 144, 152, 75, 25)
Global $Button3 = GUICtrlCreateButton("Start - F5", 32, 152, 75, 25)
Global $Bottom_Right = GUICtrlCreateInput("Bottom_Right", 72, 56, 113, 21)
Global $Label2 = GUICtrlCreateLabel("Target_Pixel", 96, 88, 63, 17)
Global $Target_Pixel = GUICtrlCreateInput("Target_Pixel", 72, 112, 113, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



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

        Case $Top_Left
            $Coords1 = GUICtrlRead($Top_Left)

        Case $Button3
            $Button3 = MouseClick("LEFT", $Top_Left[0], $Top_Left[1], 1, 1)


    EndSwitch
WEnd

 

Edited by Dequality
Link to comment
Share on other sites

I would do something like this (based on the understanding I have of  your gui) :

Local $pos[2], $nMsg, $Started = False

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $Top_Left
            ; do something here is required

        Case $Button3
            $Started = True

        Case $Button2
            $Started = False
    EndSwitch

    if $Started then
        $Pos = Your_PixelSearch ()
        if not @error then GUICtrlSetData ($Top_Left, "Coords are " & $Pos[0] & " / " & $Pos[1]) 
    endif

WEnd

GuiDelete ($Form1)

 

Link to comment
Share on other sites

Btw, about the Random(MIN, MAX) how is that possible to do then? .. i just got a coordinate called 511, 429.. then i cant use it for random? .. second set is 565, 483

20 hours ago, Nine said:

Put some debug messages in your script so can see what is going on (like consolewrite or msgbox).

Global $aCoordinates2[2] = [672, 614]

with random min MUST BE LOWER than the max otherwise you get 0 as a result...put some debug messages

  

 

Link to comment
Share on other sites

15 minutes ago, Dequality said:

i just got a coordinate called 511, 429.. then i cant use it for random? .. second set is 565, 483

Doesn't make much sense to mix x and y in a single random.  You should random ($x1, $x2) and random ($y1, $y2).  In the examples you gave me, it would be random (511, 565) to obtain a new x and random (429,483) to obtain a new y , that would give you a random coordinate between the first 2.

Edited by Nine
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

×
×
  • Create New...