Jump to content

TABs and funktions is getting ignored


Recommended Posts

Hi all,

I have a Problem with my script and I am new to AutoIt. What I want:

1. go to excel

2. copy a cell

3. go to my program

4. TAB 26 times to an specific field

5. paste the cell

6. go to Excel and to the next cell

7. start again

/Code in the End/

So it is all working, but sometimes my Script or PC or whatever is jumping only 25 times. Sometimes it doesn´t jump at all.

It is not all the time. Sometimes after 10 loots the jumps are wrong, sometimes after 160 , sometime everything goes well. So I have no idea how to figer it out. And what can couse this.

Something with Thread/Memory management or other Prozesses or just someting wrong in the script that couse it to crush sometimes.

I can not cominiicate with my program, so i can´t ask for field IDs or something like that.

Also mouse is not recomended.

For wrong jumps and errors  I am using Pixel CheckSums.

1. left, right, over and under the filed I want to paste someting in.

Maybe this is breaking the code in the rumetime ?

So here is my Script:

Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Umstellung Union", "Umstellung - UNION"

If $iAnswer = 7 Then
    MsgBox($MB_SYSTEMMODAL, "Bye bye", "OK.  Bye!")
    Exit
EndIf

Func jumpToUnion() ;My jump funktion
    AutoItSetOption("SendKeyDelay", 50)
    Send("{TAB 26}")
    sleepTime100()
EndFunc

Func sleepTime100()
    Sleep(100)
EndFunc

Func sleepTime20()
    Sleep(20)
EndFunc

;Funktions for the Pixel Check Sums 

Func checkPixelUpDown()

If $iCheckSumOben <> PixelChecksum(50, 200, 1230, 410) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Im oberen Fensterbereich ")
        Exit
EndIf
        
If $iCheckSumUnten <> PixelChecksum(50, 485, 1230, 780) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Im unteren Fensterbereich")
        Exit
EndIf       
EndFunc

Func checkPixelUnion()

If $iCheckSumUnionL <> PixelChecksum(50, 420, 620, 490) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Links vom Unionsfeld")
        Exit
EndIf       
If $iCheckSumUnionR <> PixelChecksum(930, 420, 1230, 490) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Rechts vom Unionsfeld")
        Exit
EndIf       
EndFunc

Func checkPixelNextPage()
If $iCheckSumNextPage <> PixelChecksum(50, 215, 100, 360) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Auf zweiter Seite gesprungen")
        Exit
EndIf
EndFunc

;Checkt für ungültiges Kammando
Func checkPixelWrongAction()
If $iCheckSumWrongAction <> PixelChecksum(150, 930, 270, 960) Then
        MsgBox($MB_SYSTEMMODAL, "", "Ungültige Änderung! Ungültige Eingaben, SICLID bleibt hängen --> Fehler")
        Exit
EndIf
EndFunc


Local $sAnswer = InputBox ( "Anzahl der Haendler", "Anzahl der HändlerNummern") ; getting the loops

For $i = 1 To $sAnswer

;Go to Excel
WinActivate("Microsoft Excel - TestExcelSource.xlsx")
sleepTime20()

;Copy active cell
Send("^c")
sleepTime20()

;Go to my Program
WinActivate("MyProgram]") ;TEST
sleepTime20()

;Safe the checksums
Local $iCheckSumOben  = PixelChecksum(50, 200, 1230, 410)
Local $iCheckSumUnten = PixelChecksum(50, 485, 1230, 780)

Local $iCheckSumWrongAction = PixelChecksum(150, 930, 270, 960)

Local $iCheckSumUnionL = PixelChecksum(50, 420, 620, 490)
Local $iCheckSumUnionR = PixelChecksum(930, 420, 1230, 490)

;my jump funktion
jumpToUnion() ;HERE SOMETHING GOES WRONG DONT KNOW WHAT

;Paste the cell
Send("^v")
sleepTime100()

;new checksum for trying to jump out of the current page
Local $iCheckSumNextPage = PixelChecksum(50, 215, 100, 360)


;use my check funktions
checkPixelUpDown()

checkPixelWrongAction()

checkPixelUnion()

Send("{ENTER}")
sleepTime20()

checkPixelNextPage()

;Back to excel
WinActivate("Microsoft Excel - TestExcelSource.xlsx")

;Go 1 cell down
Send("{DOWN}")

Next ;start the loop again

Exit

Thanks a lot for your time

Niksan

Link to comment
Share on other sites

Poor way to do this, you should be looking at _excel_*  functions in help file.

But is you insist I would add the sleep time in a loop.

Func jumpToUnion() ;My jump funktion

    AutoItSetOption("SendKeyDelay", 50)
    For $i = 1 To 26
        Send("{TAB}")
        sleepTime100()
    Next
EndFunc   ;==>jumpToUnion

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...