Jump to content

Need help with a script.


helpme
 Share

Recommended Posts

I have a script for a game, it's very nearly there, just need some help on an error I'm receiving.

I'm basically making a script to scan for 2D monsters on a game, in window mode, to attack(click on them) until the monster has died. Whenever I run the script in-game it returns that error, anyone have any idea?

Here is the error..

Posted Image

If you could speak on MSN or something, I could explain the whole scenario and hopefully you can come up with an answer as I've literally been stuck at it for hours and hours.

Thank you.

Edited by helpme
Link to comment
Share on other sites

I recommend posting your code and typing out the exact error message.

It may be on my end (behind work firewall) but I cannot get your error message image.

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

I recommend posting your code and typing out the exact error message.

It may be on my end (behind work firewall) but I cannot get your error message image.

The code is pretty long and I don't really want to open release it, in a way.

I can type the error message,

Line 247 (My script location)
MouseMove(($POS[0] + $POS[2] / 2),($POS[1] + $POS[3] / 2)+10, 0)
MouseMove(($POS^ ERROR

Error: Subscript used with non-Array variable.
Link to comment
Share on other sites

The error message tells you that you want to access an "array" that is no array. I usually get this error when a a previous call to a function that should return an array fails.

Best way to help you is to post your code - or at least the lines where "array" $POS is populated.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The error message tells you that you want to access an "array" that is no array. I usually get this error when a a previous call to a function that should return an array fails.

Best way to help you is to post your code.

I can PM you it or over msn, if you like.
Link to comment
Share on other sites

Post the portion of the code that starts with:

$pos =

the problem has to do with how you set the data for $pos...

Since i have made the type of program you are talking about before im guessing your using:

$pos = pixelsearch($x1,$y1,$x2,$y2)

if this is correct then you have to find out of the function that does pixel search is being called.

Edited by Negative1

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

In case of an error WinGetPos returns 0 and sets @error to 1 if window is not found. Could you change your code and post the result:

$POS = WinGetPos($WINTIT)
ConsoleWrite("Error for WinGetPos: " & @error & @CRLF)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$POS = WinGetPos($WINTIT)

Instead of

$POS = WinGetPos($WINTIT)

use

msgbox(0,"",$WINTIT)

in the same place. If the message box does not pop up then you know that the func is not being called and therefore $pos never gets set.

If the message box does pop up the text on the message box should match the window you are trying to get the position of.

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

Instead of

$POS = WinGetPos($WINTIT)

use

msgbox(0,"",$WINTIT)

in the same place. If the message box does not pop up then you know that the func is not being called and therefore $pos never gets set.

If the message box does pop up the text on the message box should match the window you are trying to get the position of.

I was ingame, then I pressed the hotkey to start the bot and it worked, in a sense that the box opened and said 0

ToolTip("Initialising", 0, 0)
    $title = iniread ("hacks.ini" , "Windowtitle" , "title","")
    $WINTIT = WinGetTitle($title)
    $POS = msgbox(0,"",$WINTIT)
    $SIZE = WinGetClientSize($WINTIT)
    CENTER()
Link to comment
Share on other sites

I can only find a window with a title, but the window I want my script to find has no title... is there an alternative I can use so it can retrieve the $POS correctly, as it's not finding the window.

Also its myth of soma.

Edited by helpme
Link to comment
Share on other sites

I was ingame, then I pressed the hotkey to start the bot and it worked, in a sense that the box opened and said 0

ToolTip("Initialising", 0, 0)
    $title = iniread ("hacks.ini" , "Windowtitle" , "title","")
    $WINTIT = WinGetTitle($title)
    $POS = msgbox(0,"",$WINTIT)
    $SIZE = WinGetClientSize($WINTIT)
    CENTER()

My guess is that your problem is in line:

$title = iniread ("hacks.ini" , "Windowtitle" , "title","")

follow it up with

msgbox(0,"",$title)

My bet is the $title is = "" due to iniread failing.

I would also guess that the problem is with "hacks.ini"

if hacks.ini is in the same directory as the script you are running use:

iniread (@scriptdir&"\hacks.ini" , "Windowtitle" , "title","")

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

I can only find a window with a title, but the window I want my script to find has no title... is there an alternative I can use so it can retrieve the $POS correctly, as it's not finding the window.

Also its myth of soma.

If the window has no title it will probably still have a class. Check the au3 window info tool for the class name. You can then use:

$WINTIT = WinGetTitle("[CLASS:classname]")

Change the bold "classname" to whatever the window info tool tells you.

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

If the window has no title it will probably still have a class. Check the au3 window info tool for the class name. You can then use:

$WINTIT = WinGetTitle("[CLASS:classname]")

Change the bold "classname" to whatever the window info tool tells you.

I like your style, that part is working fine now, it was just the fact it couldn't find what window to go too, using the class found it. :)

Few more things to fix now, if I need help I know exactly where to go, you guys are great.

Thank you.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...