script not calculating the cell below it properly HELP PLEASE

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
danny1236
Posts: 43
Joined: 16 Aug 2016, 03:48

script not calculating the cell below it properly HELP PLEASE

19 Sep 2016, 07:39

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

4::
Reload
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
IfMsgBox, Yes, Edit
return

$2::
v99 := "C:\users\public\Desktop\Saturn.lnk"
xl1 := ComObjactive("Excel.Application")
xl  := xl1.workbooks("CR Creation.xlsx").worksheets("sheet1")
Row := "2"
Next := row + 1
Columns := Object(1,"A",2,"B",3,"C",4,"D",5,"E",6,"F",7,"G",8,"H",9,"I",10,"J",11,"K",12,"L",13,"M",14,"N",15,"O",16,"P",17,"Q")
xl.range("A"row).copy
Run %v99%
sleep, 2500
send 1hxha
Sleep, 1000
send {enter}
sleep, 3000
send gayboy30
Sleep, 1000
send {enter}
Sleep, 5000
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
Sleep, 18000
send {down}
sleep, 1000
send {enter}
sleep, 1000
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 1000
send {enter}
sleep, 1500




login:
Send, CI
send {enter}
sleep, 500
Send, CI
send {enter}
sleep, 500
send {enter}
sleep, 500
send, CR
sleep, 500
send {enter}
xl.range("B"row).copy
sleep, 1000
send, {Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
if xl.range("C"row).value= "I"
{
send I
SEND {enter}
}
else if xl.range("C"row).value= "B"
{
send B
send {enter}
sleep, 500
Send {right}
sleep, 500
send {enter}
sleep, 500
send {enter}
}
xl.range("D"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 1000
xl.RANGE("E"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 1000
Send {enter}
xl.range("F"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 1000
send {enter}
sleep, 500
send {enter}
sendinput, A
sleep, 500
send {enter}
sleep, 500
xl.range("G"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
xl.range("H"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
xl.range("I"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
send {enter}
sleep, 500
send {enter}
if xl.range("J"row).value = "MULTI"
{
sleep, 500
send {enter}
}
send, N
send {enter}
sleep, 500
MsgBox, 4,, Would you like to press enter? (press Yes or No)
IfMsgBox Yes
{
Send {enter}
}
else ifmsgbox No
{
sleep, 500
}
sleep, 500
Send {right}
sleep, 500
send,{enter}
send,{enter}
sleep, 500
If xl.range("K"row).VALUE > 500
{
Send {right}
sleep, 500
send,{enter}
}

if xl.range("D"row).value = xl.range("D"next).value
{
goto Sameinvoice
}
else if xl.range("D"row).value <> xl.range("D"next).value
{
goto Newinvoice
}

Sameinvoice:
row := row + 1
next := row + 1
sleep, 1000
xl.range("G"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
xl.range("H"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
xl.range("I"row).copy
send,{Shiftdown}{ctrldown}v{Shiftup}{ctrlup}
sleep, 500
send {enter}
sleep, 500
send {enter}
if xl.range("J"row).value = "MULTI"
{
sleep, 500
send {enter}
}
send, N
sleep, 500
send {enter}
sleep, 500
MsgBox, 4,, Would you like to press enter? (press Yes or No)
IfMsgBox Yes
{
Send {enter}
}
else ifmsgbox No
{
Sleep, 500
}
sleep, 500
Send {right}
sleep, 500
send,{enter}
sleep, 500
send,{enter}
Sleep 1000
if xl.range("D"row).value = xl.range("D"next).value
{
goto Sameinvoice
return
}
else if xl.range("D"row).value <> xl.range("D"next).value
{
goto Newinvoice
return
}


Newinvoice:
send {f9}
Sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send {enter}
sleep 500
send 00.00
sleep 500
send {enter}
MsgBox, 4,, Confirm CR is correct? (Yes=correct or No=stopscript)
IfMsgBox Yes
{
Send {enter}
}
else ifmsgbox No
{
Return
}
sleep 500
if xl.range("A"row).value < 1
{
return
}
row := row + 1
goto Login



I have a spreadsheet which it inputs codes to our system however when on the same invoice it adds the next line in even though it is not part of the same invoice. have i done something wrong using my variables?

example of excel spreadsheet:-

Branch AccountNoCreditReasonOriginalInvoice OriginalDate CustomerOrder ProductCode Quantity UnitValue Unit>1 IS >500 DiscrepancyNo
3490 HXIB360 B 12186(invoice number) 06/09/16 230990 IF189B03 5 1.37 MULTI 6.85 DISAH394 ORDER PROCESSED CORRECTLY
3490 IBT3069 B 12216(invoice number) 05/09/16 218388 AS910101 7 2.33 MULTI 16.31 DISAH388 SCRIPT INPUTS FIRST PRODUCT CODE
3490 IBT3069 B 12159(invoice number) 30/08/16 218217 ALTEF028 1 1.16 MULTI 1.16 DISHAH297 SCRIPT THINKS THIS HAS SAME INVOICE NUMBER AND INPUTS IT WHY???


any help is appreciated.

dan

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mebelantikjaya and 296 guests