way1000

array variable error

4 posts in this topic

i have a script that works but gives results and errors randomly

dzuwrp.png

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Date.au3>

Global $result1s[5]=["a", "b", "c", "d", "e"]
Global $result2s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"]
Global $result3s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"]
Global $result4s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"]
Global $result5s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"]
_Main()

Func _Main()

    Local $button1
    Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5
    Local $file = FileOpen("test.txt", 1)

    GUICreate("test", 600, 200, -1, -1)
    $button1 = GUICtrlCreateButton("Result", 460, 110, 50, 30)
    $output1 = GUICtrlCreateInput("", 60, 10, 450, 20, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlCreateLabel("1", 5, 12)
    $output2 = GUICtrlCreateInput("", 60, 30, 450, 20, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlCreateLabel("2", 5, 12)
    $output3 = GUICtrlCreateInput("", 60, 50, 450, 20, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlCreateLabel("3", 5, 32)
    $output4 = GUICtrlCreateInput("", 60, 70, 450, 20, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlCreateLabel("4", 5, 52)
    $output5 = GUICtrlCreateInput("", 60, 90, 450, 20, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlCreateLabel("5", 5, 72)

    GUICtrlCreatePic("", 0, 0, 600, 200)
    GUICtrlCreateLabel("Sample Pic", 75, 1, 53, 15)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFFFFF)

    $die = GUICtrlCreateLabel("", 700, 500, 700, 20, $SS_SUNKEN)
    GUICtrlSetFont($output, 8, 800, "", "Verdana")
    GUISetState()



    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button1
                $results1 = Random(1, 5, 1)
                GUICtrlSetData($output1, $result1s[$results1])
                $read1 = GUICtrlRead($output1)

                $results2 = Random(1, 19, 1)
                GUICtrlSetData($output2, $result2s[$results2])
                $read2 = GUICtrlRead($output2)

                $results3 = Random(1, 19, 1)
                GUICtrlSetData($output3, $result3s[$results3])
                $read3 = GUIctrlRead($output3)

               $results4 = Random(1, 19, 1)
                GUICtrlSetData($output4, $result4s[$results4])
                $read4 = GUICtrlRead($output4)

                $results5 = Random(1, 19, 1)
                GUICtrlSetData($output5, $result5s[$results5])
                $read5 = GUICtrlRead($output5)

            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read2)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read3)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read4)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read5)

            FileClose($file)
        EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>_Main

 

 

how to fix it?

Share this post


Link to post
Share on other sites



 

AuitoIt  arrays are zero based so for example your $result1s array has valid index values $result1s[0] to $result1s[4]

A quick simple way to fix your code is to subtract 1 from the value returned by the random function as shown below or alternatively change $results1 = Random(1, 5, 1) to $results1 = Random(0, 4, 1)

 

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button1
                $results1 = Random(1, 5, 1)
                GUICtrlSetData($output1, $result1s[$results1 - 1])
                $read1 = GUICtrlRead($output1)

                $results2 = Random(1, 19, 1)
                GUICtrlSetData($output2, $result2s[$results2 - 1])
                $read2 = GUICtrlRead($output2)

                $results3 = Random(1, 19, 1)
                GUICtrlSetData($output3, $result3s[$results3 - 1])
                $read3 = GUIctrlRead($output3)

               $results4 = Random(1, 19, 1)
                GUICtrlSetData($output4, $result4s[$results4 - 1])
                $read4 = GUICtrlRead($output4)

                $results5 = Random(1, 19, 1)
                GUICtrlSetData($output5, $result5s[$results5 - 1])
                $read5 = GUICtrlRead($output5)

            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read2)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read3)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read4)
            FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read5)

            FileClose($file)
        EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

 


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This returns a value between 1 and 5:

$results1 = Random(1, 5, 1)

and this creates an Array of 5 elements 0 to 4: 

Global $result1s[5]=["a", "b", "c", "d", "e"]

so whenever the first line's result = 5 the error will occur.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Please check the Arrays section in the wiki for a very detailed description.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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

    • hcI
      By hcI
      Hello everyone !
      I have a little problem
      I would like to do a little program who analyse an array and return the 1st line of the array who is empty
      For example :
      Global $aArray[5] = "abc","def","ghi","","mno" ; And Then, (maybe a For loop who) return in a variable "4" ; because the 4th case of the array is empty I've took a look in helpfile but found nothing intrusting..
      If someone have already done this or have idea how to proceed..
      Hci
    • BJJ
      By BJJ
      Hello everyone,
      I have huge problem with "Recurison level has been exceeded - AutoIt will quit to prevent stack overflow" in my own Bot.
      I have no idea how rebuild my loops for eliminate this type of error.
       
      Here is my code 
       
      #Region #AutoIt3Wrapper_Icon=C:\Users\barbosa\Desktop\autoIt\produkcja\angelica.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Run_Obfuscator=y #EndRegion #Region ; GUI generated by GUIBuilderNxt Prototype 1.0 #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> ;#include <nomad.au3> HotKeySet("{end}","stop") ;end for app kill Local Const $sFont = "Open Sans" ;font variable Local $sFile = "angelica.ico" ;icon variable Global $MainStyle = BitOR($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_MINIMIZEBOX, $FW_SEMIBOLD = 600) Global $info_task = "[ Waiting for calibration ]",$info_battlelist = "None",$info_empty = "None",$info_hotkeys = "INACTIVE",$info_100 = "None",$info_mana = "None",$info_food = "None",$info_blank = "None",$info_drop = "None",$info_hand = "None" Global $hMain = GuiCreate("Auto_Angela_Beta_1.0", 330, 559, -1, -1, $MainStyle) GUISetIcon($sFile) $label_100 = GuiCtrlCreateLabel("[F4] Mana Point "&" "&$info_100, 20, 40, 170, 20,-1) $label_mana = GuiCtrlCreateLabel("[F5] Mana Bar "&" "&$info_mana, 20, 60, 170, 20,-1) $label_empty = GuiCtrlCreateLabel("[F6] Nothing "&" "&$info_empty, 20, 80, 170, 20,-1) $label_battlelist = GuiCtrlCreateLabel("[F7] Battle List "&" "&$info_battlelist, 20, 100, 170, 20,-1) $label_food = GuiCtrlCreateLabel("[F8] Food "&" "&$info_food, 20, 120, 170, 20,-1) $label_blank = GuiCtrlCreateLabel("[F9] Blank "&" "&$info_blank, 20, 140, 170, 20,-1) $label_drop = GuiCtrlCreateLabel("[F10] Drop "&" "&$info_drop, 20, 160, 170, 20,-1) $label_hand = GuiCtrlCreateLabel("[F11] Hand "&" "&$info_hand, 20, 180, 170, 20,-1) $Group_11 = GuiCtrlCreateGroup("Configuration", 10, 10, 190, 220,-1) $Group_12 = GuiCtrlCreateGroup("Setup", 210, 10, 110, 220,-1) $btn_setting = GuiCtrlCreateButton("Setup", 220, 40, 70, 30,-1) $btn_load = GuiCtrlCreateButton("Load", 220, 100, 70, 30,-1) $btn_save = GuiCtrlCreateButton("Save", 220, 140, 70, 30,-1) $label_hotkeys = GuiCtrlCreateLabel("Status: "&$info_hotkeys, 220, 190, 90, 20,-1) $input_spell = GuiCtrlCreateInput("Adura Vita", 20, 270, 120, 20,-1) $box_house_mode = GuiCtrlCreateCheckbox("House mode", 20, 300, 90, 20,-1) $box_pk_mode = GuiCtrlCreateCheckbox("Anty PK", 20, 330, 90, 20,-1) $Checkbox_20 = GuiCtrlCreateCheckbox("Alarms", 20, 360, 90, 20,-1) $Checkbox_21 = GuiCtrlCreateCheckbox("Anty Idle", 20, 390, 90, 20,-1) $btn_auto = GuiCtrlCreateButton("Start", 200, 360, 70, 30,-1) $btn_refiler = GuiCtrlCreateButton("Rune thrower", 200, 400, 70, 20,-1);$btn_manual = GuiCtrlCreateButton("Start", 200, 360, 70, 30,-1) $Input_22 = GuiCtrlCreateInput("down", 140, 300, 60, 20,-1) $Input_23 = GuiCtrlCreateInput("up", 210, 300, 60, 20,-1) $Group_24 = GuiCtrlCreateGroup("Mode", 10, 250, 310, 180,-1) GUISetFont(9, $FW_SEMIBOLD) ;white color and bigger font ;$label_task = GuiCtrlCreateLabel($info_task, 10, 450, 370, 24,-1) GUICtrlSetColor($label_task, 0xffffff) GUISetFont(9, $FW_MEDIUM) $Label_28 = GuiCtrlCreateLabel("Auto_Angela_Beta 1.1 @ Medivia 2016", 60, 530, 370, 20,-1) Global $way_one Global $way_one Global $food_pos_x,$food_pos_y Global $hand_pos_x,$hand_pos_y Global $drop_pos_x,$drop_pos_y Global $blank_pos_x, $blank_pos_y Global $RunOrNot Global $pid Global $hotkeys = 0 ;By default hotkeys are disabled Global $mana_color, $battle_color Global $mana_100_x,$mana_100_y Global $mana_pixel_x, $mana_pixel_y Global $empty_pixel_x = 000, $empty_pixel_y = 000 Global $battle_pixel_x, $battle_pixel_y Global $is_break ;Global $MapClickEscape_x, $MapClickEscape_y ;GUICtrlSetDefColor(0xFF0000) GUISetBkColor(0x788190) ; will change background color ;GUICtrlSetBkColor($label_hand, 0xF0F4F9) GuiSetState(@SW_SHOWNORMAL) Do Switch GuiGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn_setting _EnableDisable() ;function which make hotkeys enable/disable Case $btn_auto IF $info_food <> "None" OR $info_blank <> "None" OR $info_drop <> "None" OR $info_hand <> "None" OR $info_100 <> "None" OR $info_mana <> "None" Then ;simple validation data in possitions variables check_mana() ;Function is first in chain for making runes Else MsgBox(0, "Error", "You must setup coordinations") EndIf Case $btn_load load_from_file() ;load data from text file Case $btn_save save_to_file() ;dave data in text file Case $btn_refiler refiler() ;for fast refile EndSwitch Until False #EndRegion ;Func uher() ;x,y postaci = F10 DROP ;x,y uha w plecaku = F9 Blank ;kolor uha pobrany przy ustawieniu ;kolor plecaka = F6 BP Color ;odpowienio przygotowane staki plecakow ;co 400ms sprawdza czy jest dosc hp na uha ;jesli trzeba sie uchnac to sprawdza czy w miejscu na uha jest niebieska runa ;jesli nie ma to sprawdza czy jest yellow bp jesli nie ma to sygnal dzwiekowy bledu i kill uhera ;jesli jest to otwiera plecak i sprawdza czy jest niebieska runa jak nie ma to error i kill uhera ;jesli jest to ja przeciaga na postac bardzo szybko ;EndFunc Func refiler() local $i = 20 While $i > 0 MouseClickDrag($MOUSE_CLICK_LEFT, $blank_pos_x, $blank_pos_y, $drop_pos_x, $drop_pos_y, 1) $i = $i - 1 WEnd EndFunc Func save_to_file() $file = FileOpen("angela_memory.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to save data.") Else FileWrite($file, $mana_100_x & @CRLF) FileWrite($file, $mana_100_y & @CRLF) FileWrite($file, $mana_pixel_x & @CRLF) FileWrite($file, $mana_pixel_y & @CRLF) FileWrite($file, $empty_pixel_x & @CRLF) FileWrite($file, $empty_pixel_y & @CRLF) FileWrite($file, $battle_pixel_x & @CRLF) FileWrite($file, $battle_pixel_y & @CRLF) FileWrite($file, $food_pos_x & @CRLF) FileWrite($file, $food_pos_y & @CRLF) FileWrite($file, $blank_pos_x & @CRLF) FileWrite($file, $blank_pos_y & @CRLF) FileWrite($file, $drop_pos_x & @CRLF) FileWrite($file, $drop_pos_y & @CRLF) FileWrite($file, $hand_pos_x & @CRLF) FileWrite($file, $hand_pos_y & @CRLF) MsgBox(0, "Done", "Settings saved.") EndIf EndFunc Func load_from_file() $file = FileOpen("angela_memory.txt", $FO_READ) If $file = -1 Then MsgBox(0, "Error", "Unable to load data.") Else ;wczytywanie segmentow $mana_100_x = FileReadLine($file, 1) $mana_100_y = FileReadLine($file, 2) $info_100 = "X: "&$mana_100_x&" "&"Y: "&$mana_100_y GUICtrlSetData($label_100, "[F4] Mana point "&" "&$info_100) ;;;; $mana_pixel_x = FileReadLine($file, 3) $mana_pixel_y = FileReadLine($file, 4) $info_mana = "X: "&$mana_pixel_x&" "&"Y: "&$mana_pixel_y GUICtrlSetData($label_mana, "[F5] Mana Bar "&" "&$info_mana) ;;;; $empty_pixel_x = FileReadLine($file, 5) $empty_pixel_y = FileReadLine($file, 6) $info_empty = "X: "&$empty_pixel_x&" "&"Y: "&$empty_pixel_y GUICtrlSetData($label_empty, "[F6] Nothing "&" "&$info_empty) ;;;; $battle_pixel_x = FileReadLine($file, 7) $battle_pixel_y = FileReadLine($file, 8) $info_battlelist = "X: "&$battle_pixel_x&" "&"Y: "&$battle_pixel_y GUICtrlSetData($label_battlelist, "[F7] Battle List "&" "&$info_battlelist) ;;;; $food_pos_x = FileReadLine($file, 9) $food_pos_y = FileReadLine($file, 10) $info_food = "X: "&$food_pos_x&" "&"Y: "&$food_pos_y GUICtrlSetData($label_food, "[F8] Food "&" "&$info_food) ;;;; $blank_pos_x = FileReadLine($file, 11) $blank_pos_y = FileReadLine($file, 12) $info_blank = "X: "&$blank_pos_x&" "&"Y: "&$blank_pos_y GUICtrlSetData($label_blank, "[F9] Blank "&" "&$info_blank) ;;;; $drop_pos_x = FileReadLine($file, 13) $drop_pos_y = FileReadLine($file, 14) $info_drop = "X: "&$drop_pos_x&" "&"Y: "&$drop_pos_y GUICtrlSetData($label_drop, "[F10] Drop "&" "&$info_drop) ;;;; $hand_pos_x = FileReadLine($file, 15) $hand_pos_y = FileReadLine($file, 16) $info_hand = "X: "&$hand_pos_x&" "&"Y: "&$hand_pos_y GUICtrlSetData($label_hand, "[F11] Hand "&" "&$info_hand) ;;;; FileClose($file) MsgBox(0, "Done", "Settings loaded") EndIf EndFunc Func stop() Exit EndFunc Func kill() Exit 0 EndFunc ;functions checking if checkbox checked Func _IsChecked_pk_mode($box_pk_mode) Return BitAND(GUICtrlRead($box_pk_mode), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func _IsChecked_house_mode($box_house_mode) Return BitAND(GUICtrlRead($box_house_mode), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func floor_maker() ;GUICtrlSetData($label_task, "[ Burning rune.. ]") $spell_name = GUICtrlRead($input_spell) $way_one = GUICtrlRead($Input_22) $way_two = GUICtrlRead($Input_23) If _IsChecked_house_mode($box_house_mode) Then ControlSend("Medivia","","", "{" & $way_one & "}" ) EndIf Sleep(1000) MouseClickDrag($MOUSE_CLICK_LEFT, $blank_pos_x, $blank_pos_y, $hand_pos_x, $hand_pos_y, 2) ControlSend("Medivia","","",$spell_name) ControlSend("Medivia","","","{enter}") MouseClickDrag($MOUSE_CLICK_LEFT, $hand_pos_x, $hand_pos_y, $drop_pos_x, $drop_pos_y, 2) Sleep(300) MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4, 10) Sleep(400) MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4, 10) Sleep(300) If _IsChecked_house_mode($box_house_mode) Then ControlSend("Medivia","","", "{" & $way_two & "}" ) EndIf Beep(1000, 150) check_mana() EndFunc Func _EnableDisable() If $hotkeys = 0 Then HotKeySet("{F4}", "mana_100") HotKeySet("{F5}", "mana_get_color") ;HotKeySet("{F6}", "MapClickEscape") HotKeySet("{F7}", "battle_get_color");Pobiera kolor do zmiennej $battle_color HotKeySet("{F8}", "mouse_pos_food") HotKeySet("{F9}", "mouse_pos_blank") HotKeySet("{F10}", "mouse_pos_drop") HotKeySet("{F11}", "mouse_pos_hand") $hotkeys = 1 $info_hotkeys = "ACTIVE" GUICtrlSetData($label_hotkeys, "Status: "&" "&$info_hotkeys) GUICtrlSetData($label_task, "[ Calibration in progress ]") Else HotKeySet("{F4}") HotKeySet("{F5}") HotKeySet("{F6}") HotKeySet("{F7}") HotKeySet("{F8}") HotKeySet("{F9}") HotKeySet("{F10}") HotKeySet("{F11}") $hotkeys = 0 $info_hotkeys = "INACTIVE" GUICtrlSetData($label_hotkeys, "Status: "&" "&$info_hotkeys) GUICtrlSetData($label_task, "[ End of calibration ]") EndIf EndFunc Func check_mana() ;sleep(700) ;IsSafty() $current_color = PixelGetColor($mana_100_x,$mana_100_y) ;Taking current color from defined mana break point on maan bar $BattleListColor = PixelGetColor($battle_pixel_x, $battle_pixel_y) ;Taking current color from defined posiotion on battle list If _IsChecked_pk_mode($box_pk_mode) Then ;only if pk_mode checkbox is checked If $BattleListColor = $battle_color Then ;If collor on battle list point didnt change, means nothing (player/monster) enter on out screen $RunOrNot = True Else $RunOrNot = False EndIf EndIf If Not ($RunOrNot = False) Then ;If variable RunOrNot are not false it mean is true = is safe If $mana_color = $current_color Then ;If mana color flood mana bar break point floor_maker() ;rune making function Else ;GUICtrlSetData($label_task, "[ Waiting for mana.. ]") Sleep(1000) check_mana() ;Mana arnt ready so back to mana checking EndIf Else ;If not safty then run escape function runforestrun() EndIf EndFunc Func runforestrun() $way_one = GUICtrlRead($Input_22) $way_two = GUICtrlRead($Input_23) ControlSend("Medivia","","", "{" & $way_one & "}" ) Sleep(5000) Do ;GUICtrlSetData($label_task, "[ Not safty outside!! ]") Beep(700,300) Beep(200,500) Sleep(5000) ;IsSafty() $BattleListColor = PixelGetColor($battle_pixel_x, $battle_pixel_y) If $BattleListColor = $battle_color Then $RunOrNot = True Else $RunOrNot = False EndIf Until $RunOrNot = True MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4) Sleep(1000) ControlSend("Medivia","","", "{" & $way_two & "}" ) Sleep(2000) check_mana() EndFunc Func mana_100() $pos = MouseGetPos() $mana_100_x = $pos[0] $mana_100_y = $pos[1] $info_100 = "X: "&$mana_100_x&" "&"Y: "&$mana_100_y GUICtrlSetData($label_100, "[F4] Mana point "&" "&$info_100) EndFunc Func mana_get_color() $pos = MouseGetPos() $mana_pixel_x = $pos[0] $mana_pixel_y = $pos[1] $mana_color = PixelGetColor($mana_pixel_x, $mana_pixel_y) $info_mana = "X: "&$mana_pixel_x&" "&"Y: "&$mana_pixel_y GUICtrlSetData($label_mana, "[F5] Mana Bar "&" "&$info_mana) EndFunc Func battle_get_color() $pos = MouseGetPos() $battle_pixel_x = $pos[0] $battle_pixel_y = $pos[1] $battle_color = PixelGetColor($battle_pixel_x, $battle_pixel_y) $info_battlelist = "X: "&$battle_pixel_x&" "&"Y: "&$battle_pixel_y GUICtrlSetData($label_battlelist, "[F7] Battle List "&" "&$info_battlelist) EndFunc Func mouse_pos_food() $pos = MouseGetPos() $food_pos_x = $pos[0] $food_pos_y = $pos[1] $info_food = "X: "&$food_pos_x&" "&"Y: "&$food_pos_y GUICtrlSetData($label_food, "[F8] Food "&" "&$info_food) EndFunc Func mouse_pos_hand() $pos = MouseGetPos() $hand_pos_x = $pos[0] $hand_pos_y = $pos[1] $info_hand = "X: "&$hand_pos_x&" "&"Y: "&$hand_pos_y GUICtrlSetData($label_hand, "[F11] Hand "&" "&$info_hand) EndFunc Func mouse_pos_drop() $pos = MouseGetPos() $drop_pos_x = $pos[0] $drop_pos_y = $pos[1] $info_drop = "X: "&$drop_pos_x&" "&"Y: "&$drop_pos_y GUICtrlSetData($label_drop, "[F10] Drop "&" "&$info_drop) EndFunc Func mouse_pos_blank() $pos = MouseGetPos() $blank_pos_x = $pos[0] $blank_pos_y = $pos[1] $info_blank = "X: "&$blank_pos_x&" "&"Y: "&$blank_pos_y GUICtrlSetData($label_blank, "[F9] Blank "&" "&$info_blank) EndFunc Func afk() ControlSend("Medivia","","","{ctrldown}{down}{ctrlup}") Sleep(350) ControlSend("Medivia","","","{ctrldown}{up}{ctrlup}") EndFunc  
    • TheDcoder
      By TheDcoder
      Hello everyone, I discovered a bug yesterday and I posted it at the bug tracker:
      I also made a simple script which can be used to reproduce the bug:
      CreateVariable() ConsoleWrite($sGlobalVariable & @CRLF) Func CreateVariable() Global $sGlobalVariable = "Foobar" EndFunc The bug was closed by @BrewManNH:
      While I partially agree with the above statement, My code was not practical enough... so @mLipok advised me to create a thread on the forums with practical code (Thanks!). That is the point of this thread, I am going to provide the code where I experience this bug/problem .
      I discovered this bug when I was working on one of my projects called "ProxAllium". When the main script finishes execution, Au3Check throws a nasty warning about "variable possibly used before declaration":

      As you can see, the variable is indeed being used after calling the function in which the variable is declared... The warning won't appear if I declare the function ABOVE the variable. As @BrewManNH said, Au3Check reads line by line... I think this should be changed, Au3Check should not throw warnings if the interpreter is able to run the code, at least most of the time anyway!
      So what do you guys think? Is this a valid bug?... and I request those who participate in the discussion not to discuss the code being "poor", that is another thing/thread in itself
      P.S I had already written this once but the forum editor decided to mess up and when I undid (Ctrl + Z) something... This is a poorly written version of that article, I was very frustrated while writing this!
    • TMelanson
      By TMelanson
      Hi folks,
      I'm hoping someone can help me out here.
      Background:
      I have the need to run a program with admin credentials (#RequireAdmin), and then get the SID of the locally logged in account. Not the admin account.
      If you look at the attached script, Line 16 uses the @UserName variable and returns the SID for the admin account I used to launch the app.
      I want to use line 17 which passes the result of the _GetUsername function which is a username using  ($UserName) to the WMIService.
      I'm getting " The requested action with this object has failed.:" error message.
      Any suggestions would be appreciated!
       
      test1.au3
    • jonson1986
      By jonson1986
      Hey I searched code on autoit forum and modify it according to my needs and try to translate text from Russian to English in return I'm getting error such as "Error 411 (Length Required)!!1"
      Both my autoit codes and error I got are given below, please help me to solve this issue, Thanks
      Autoit codes to translate text form Russian to English;
      #include <urlencode.au3> $File1 = @ScriptDir & "\russian_text.txt" $txt = FileRead($File1) ; Try to convert line breaks with .....so final URL looks simpler $txt = StringReplace($txt, @CRLF, '...........') $txt = StringReplace($txt, @LF, '.............') $txt = StringReplace($txt, @CR, '.............') FileWrite (@scriptdir & '\russian_text2.txt', $txt) $openfile = @ScriptDir & "\russian_text2.txt" $mytext = FileRead ($openfile) $encoding = urlencode ($mytext) FileWrite (@scriptdir & '\enooding.txt', $encoding) $from = "ru" $to = "en" $url = "https://translate.googleapis.com/translate_a/single?client=gtx" $url &= "&sl=" & $from & "&tl=" & $to & "&dt=t&q=" & $encoding $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $url, False) $oHTTP.Send() $sData = $oHTTP.ResponseText $sData = StringRegExpReplace($sData, '.*?\["(.*?)(?<!\\)"[^\[]*', "$1" & @crlf) FileWrite (@scriptdir & '\errorcode.txt', $sData) Msgbox(0,"", $sData) In response of above codes, I'm getting below error;
       
      <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 411 (Length Required)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>411.</b> <ins>That’s an error.</ins> <p>POST requests require a <code>Content-length</code> header. <ins>That’s all we know.</ins>