Jump to content
Dequality

Script wont do anything?

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
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

Share this post


Link to post
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)

 

Share this post


Link to post
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

  

 

Share this post


Link to post
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

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

  • Similar Content

    • By adjist
      Hello all! 
       
      Getting this error :
      (22) : ==> Variable used without being declared.: if $vNumber = 0 Then if ^ ERROR  
      But I'm sure I have defined the variable, as in the top of my script has 
      Global $vNumber = 0  
      How would I go about fixing this?
       
    • By MarkIT
      Hi AutoIT masters,
      Good day! Sorry to have bothered this forum but we really need help. We are working on an automation project that is running on VDI server. The BOTS are in .exe are running fine until AV detected them and deleted the files. The files were re-compiled and AV kept on deleting them. The copy of the .exe BOT deleted were sent to Symantec for whitelisting. After whitelisting, it is no longer deleted but no longer working as designed (showing Line script error). We checked the scripts and there were no issues since we run it using SciTE editor and it performed the desired task. Good thing we found on this thread the solution using .a3x and the BOTS worked fine and no longer deleted. Now, the problem is they are asking why the BOTS won't run in .EXE and what is the reason behind Symantec AV deleting them. We raised a case with Symantec but they cannot provide further information as they are always seeing the file as "False Positive". We even tested with Symantec turned off and those .EXE files are working fine, however, after re-enabling, it got deleted.
      Just seeking help on how to better convince them that it is really Symantec causing the issue and the .a3x file.
    • By AutoitMike
      Scite 3.4.4
      Win 10
      I click "Help" or press F1, there is no response
      If I use the file explorer and double click Autoit.chm or Autoit3.chm help opens.
      There is no dialog to check or uncheck "Always ask before opening this file" when clicking on these files.
       
      If you are curious as to why I dont have the latest version, I am creating a back up laptop that has a VERY extensive automation application that I have written over the past 15 years.
       
      An extremely potent, powerful, needed function has been deleted in the upgrade of Autoit in recent years that I can not do without. If my main laptop dies, which it almost did, I am in a very bad position. So I bought the exact same laptop and I am "cofiguring" it to work exactly the same as my main laptop. However, this one has been "Upgraded" to Win 10 which I hope is not the problem. 
      Thanks for any help
    • By dascondor
      So basically need to pull text from a .txt file or .sql and use that text to replace something within a different file.
       
      First File:
      jumps
       
      Or:
      Text1 = jumps
      Text2 = fence
      Second File:
      My Dog XXXXX over the YYYYY.
       
       
      After Script:
      My Dog jumps over the fence
       
      I have found a good start, I'm basic programmer at best, I have some experience but this gets out of my wheel house.
       
      Any help is appreciated.
       
       
    • By Pike
      Hey Everyone, I haven't been here in a while and recently picked up my old project. Still an FNG!
      To the point: I want to be able to push the button and either play an mp3, open a file, or open an exe program (all with the same button). The problem is that I don't know how to code for that at "case 1"
              Case 1                                                                                                                                             
                  Local $sRead = IniRead("config.ini", "Config", "One", "Default")                                
                  SoundPlay($sRead, @HotKeyPressed)                                                                     <-------------------------------
                  Run($sRead, @HotKeyPressed)                                                                                 <------------------------------- This 'Run' doesn't work even by itself!
      See code below for layout. If you need more information I will attach more code or answer any questions. Any help is greatly appreciated.
       
      Much Respect,
      Pike
       
      Func _HandleButton() $iClickCount += 1 $iTimer = TimerInit() AdlibRegister("CheckButtonPress", $CheckTime) EndFunc Func CheckButtonPress() If TimerDiff($iTimer) < $CheckTime Or $iTimer = 0 Then Return Switch $iClickCount Case 1 Local $sRead = IniRead("config.ini", "Config", "One", "Default") SoundPlay($sRead, @HotKeyPressed) Run($sRead, @HotKeyPressed) Case 2 MsgBox(0, "INFORMATION:", "Choose the file you want designated to this button") Local $sFileOpenDialog = FileOpenDialog(0, @ScriptDir & "\", "All (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") EndIf Local $sFileName = InputBox("INFORMATION:", "Please Name Your File?" & @CRLF _ & @CRLF _ & "6 Characters or Less", "") IniWrite(@ScriptDir & "\config.ini", "Config", "One", $sFileOpenDialog) IniWrite(@ScriptDir & "\config.ini", "Config", "NameOne", $sFileName) EndSwitch $iClickCount = 0 AdlibUnRegister() EndFunc  

×
×
  • Create New...