Jump to content

Recommended Posts

Posted (edited)

I'm trying to run the loop below for 80 times, but it always exits much sooner.

Am i doing something wrong? It's been a while since i use AutoIt.

HotKeySet("{ESC}", "Exit")
HotKeySet("+;", "GenerateBarcode") ; Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func Exit()
    Exit
EndFunc   ;==>Exit

Func GenerateBarcode()
    For $i = 80 To 1 Step -1
        MouseWheel("down",50)
        MouseClick("left",171,296,1)
        MouseClick("left",171,316,1)
        MouseClick("left",171,336,1)
        MouseClick("left",171,356,1)
        MouseClick("left",171,376,1)
        MouseClick("left",171,396,1)
        MouseClick("left",171,416,1)
        MouseClick("left",171,436,1)
        MouseClick("left",171,456,1)
        MouseClick("left",171,476,1)
        Sleep(500)
        MouseClick("left",1256,170,1)
        MouseClick("left",1256,190,1)
        MouseClick("left",1256,210,1)
        Sleep(1000)
        MouseClick("left",1256,290,1)
    Next
        Exit
EndFunc   ;==>GenerateBarcode

 

Edited by telmob
Solved.
Posted (edited)
42 minutes ago, faustf said:

try this mod for your program bye

ShowMessage()
Func ShowMessage()
    For $i = 0 To 80
     ConsoleWrite ("de made ")
    Next
        Exit
EndFunc   ;==>GenerateBarcode

 

Ended at 14. The writing in the console worked, but not the mouseclick.

Edit: Thank you for your reply.

Edited by telmob
Posted
7 hours ago, FrancescoDiMuro said:

@telmob

Mouse* functions are not very reliable for automate applications.

Which application are you trying to automate? :)

My company's ERP in Chrome. I need to generate a barcode manually for each product, and those are the steps i need to take for each product. I said i need to loop it 80 times before, but it's actually more than 3300.

Posted
13 hours ago, telmob said:

Ended at 14. The writing in the console worked, but not the mouseclick.

Not sure I understand what you mean.  What exactly is working and what is not.  So you say it ended prematurely, unless there is code elsewhere, I do not think it is possible.

14 minutes ago, telmob said:

My company's ERP in Chrome

maybe look at :

 

Posted
22 minutes ago, Nine said:

Not sure I understand what you mean.  What exactly is working and what is not.  So you say it ended prematurely, unless there is code elsewhere, I do not think it is possible.

maybe look at :

 

Thanks for your help. The execution behaves erratically.

Below if the full code. This time it reached 16... go figure. Doesn't make any sense to me. Maybe it's stressing the system too much!? (which i doubt)

 

HotKeySet("{ESC}", "Exiter")
HotKeySet("+;", "GenerateBarcode") ; Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func Exiter()
    Exit
EndFunc   ;==>Terminate

Func GenerateBarcode()
    For $i = 0 to 80
        MouseWheel("down",50)
        MouseClick("left",171,296,1)
        MouseClick("left",171,316,1)
        MouseClick("left",171,336,1)
        MouseClick("left",171,356,1)
        MouseClick("left",171,376,1)
        MouseClick("left",171,396,1)
        MouseClick("left",171,416,1)
        MouseClick("left",171,436,1)
        MouseClick("left",171,456,1)
        MouseClick("left",171,476,1)
        Sleep(500)
        MouseClick("left",1256,170,1)
        MouseClick("left",1256,190,1)
        MouseClick("left",1256,210,1)
        Sleep(1000)
        MouseClick("left",1256,290,1)
        ConsoleWrite($i & " ")
    Next
        Exit
EndFunc   ;==>GenerateBarcode

I'll see if i can use WebDriver.

Posted

SOLVED! The freaking Antivirus was the problem. It stopped the script, for some reason.

Stopped the AV and now it's working perfectly. Oh well... Btw, i'm using Webroot SecureAnywhere. (was!)

Posted
4 minutes ago, Nine said:

Figure.  Don't know this particular AV, but with most of them, you can exclude (white list) some folders/files

That's a good idea. Thanks!

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
×
×
  • Create New...