below is my messy script that does something very simple - copy numbers/info in a IBM app > paste to excel > use that excel date to display other data in a GUI.
I would say it has a ~80% success rate, with the main issue being that the very first bit of data it copies. It makes it to excel just fine, but then does not show up in GUI, A. (titled "Bundle Size")
would anyone be able to skim through this mess and see if there is any glaring issues that could make it more consistent?
Code: Select all
setbatchlines, 2
CoordMode Pixel, Window
numpadenter::
send {enter}
sleep 50
ImageSearch, FoundX, FoundY, 696, 87, 1140, 319, C:\Users\(ommited)\Desktop\Picture1.bmp
if (ErrorLevel = 2)
{
}
else if (ErrorLevel = 1)
{
}
else
{
sendinput {down 6}{right 7}
sleep 100
sendinput {shift down}
sleep 100
send {right 8}
sleep 100
sendinput {shift up}
sleep 100
sendinput ^c
sleep 100
ex:=ComObjActive("Excel.Application")
ex.Visible := false
ex:=ComObjActive("Excel.Application")
clipboard := regexreplace(clipboard, "(\s+|,)", a_space)
ex.worksheets("BEAM").range("l2").pastespecial()
ex:=ComObjActive("Excel.Application")
value := ex.Range("q2").Value
ex:=ComObjActive("Excel.Application")
value1 := ex.Range("q12").Value
ex:=ComObjActive("Excel.Application")
value2 := ex.Range("q19").Value
Gui,A:destroy
a1:
Gui,A:default
Gui,A: +LastFound +AlwaysOnTop +ToolWindow -Caption -Border +E0x08000000
Gui,A: Font,s18 bold,Calibri
Gui,A: Color, Black
Gui,A: Font,s18 bold cWhite,Calibri
Gui,A:add,Text,x20 y10 ,%clipboard% Bundle Size:
Gui,A: Font,s18 bold cWhite,Calibri
Gui,A:add,Text,x10 y45 , Nucor - %value%
Gui,A:add,Text,x38 y75 , SDI - %value1%
Gui,A:add,Text,x1 y105 ,Gerdau - %value2%
Gui,A: Show, x100 y200 h210 NoActivate
send {f7}
send zz{enter}
sleep 100
sendinput {up 15}{left 3}
sleep 100
sendinput {shift down}
sendinput {right 9}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b2").pastespecial()
send {down 3}
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b3").pastespecial()
send {down 3}{shift down}{right 6}{shift up}
sendinput ^c
ex.worksheets("ZZ").range("b4").pastespecial()
send {down 3}
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b5").pastespecial()
sendinput {right 40}{up 9}
sleep 100
send {shift down}
sendinput {right 10}
sleep 50
sendinput {shift up}
sleep 50
sendinput ^c
ex.worksheets("ZZ").range("c2").pastespecial()
send {down 3}
send {shift down}
sendinput {right 10}
send {shift up}
sendinput ^c
ex.worksheets("ZZ").range("c3").pastespecial()
send {down 3}
sendinput {shift down}
sendinput {right 10}
send {shift up}
sendinput ^c
ex.worksheets("ZZ").range("c4").pastespecial()
send {down 3}
send {shift down}
sendinput {right 10}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("c5").pastespecial()
ex:=ComObjActive("Excel.Application")
value3 := ex.worksheets("ZZ").range("a2").Value
ex:=ComObjActive("Excel.Application")
value4 := ex.worksheets("ZZ").range("a3").Value
ex:=ComObjActive("Excel.Application")
value5 := ex.worksheets("ZZ").range("a4").Value
ex:=ComObjActive("Excel.Application")
value6 := ex.worksheets("ZZ").range("a5").Value
ex:=ComObjActive("Excel.Application")
value31 := ex.worksheets("ZZ").range("c2").text
ex:=ComObjActive("Excel.Application")
value41 := ex.worksheets("ZZ").range("c3").Text
ex:=ComObjActive("Excel.Application")
value51 := ex.worksheets("ZZ").range("c4").Text
ex:=ComObjActive("Excel.Application")
value61 := ex.worksheets("ZZ").range("c5").text
Gui,B:destroy
B1:
Gui,B:default
Gui,B: +LastFound +AlwaysOnTop +ToolWindow -Caption -Border +E0x08000000
Gui,B: Font,s18 bold,Calibri
Gui,B: Color, Black
Gui,B: Font,s18 bold cWhite,Calibri
Gui,B:add,Text,x60 y10 ,ZZ STOCK:
Gui,B: Font,s18 bold cWhite,Calibri
Gui,B:add,Text,x10 y45 ,%value3% -%value31%
Gui,B:add,Text,x10 y75 ,%value4% -%value41%
Gui,B:add,Text,x10 y105,%value5% -%value51%
Gui,B:add,Text,x10 y135,%value6% -%value61%
Gui,B: Show, x100 y410 w300 h210 NoActivate
send {tab}
send zf{enter}
sleep 100
sendinput {up 14}{left 9}
sleep 50
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b9").pastespecial()
send {down 2}
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b10").pastespecial()
send {down 2}
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b11").pastespecial()
send {down 2}
send {shift down}
sendinput {right 6}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("b12").pastespecial()
sendinput {right 58}{up 6}
sleep 100
send {shift down}
sendinput {right 10}
sendinput {shift up}
sendinput ^c
sleep 100
ex.worksheets("ZZ").range("c9").pastespecial()
send {down 2}
send {shift down}
sendinput {right 10}
sendinput {shift up}
sendinput ^c
sleep 100
ex.worksheets("ZZ").range("c10").pastespecial()
send {down 2}
send {shift down}{right 10}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("c11").pastespecial()
send {down 2}
send {shift down}
sendinput {right 10}
sendinput {shift up}
sendinput ^c
ex.worksheets("ZZ").range("c12").pastespecial()
send {f3}
send {f5}
ex:=ComObjActive("Excel.Application")
value7 := ex.worksheets("ZZ").range("a9").Value
ex:=ComObjActive("Excel.Application")
value8 := ex.worksheets("ZZ").range("a10").Value
ex:=ComObjActive("Excel.Application")
value9 := ex.worksheets("ZZ").range("a11").Value
ex:=ComObjActive("Excel.Application")
value10 := ex.worksheets("ZZ").range("a12").Value
ex:=ComObjActive("Excel.Application")
value71 := ex.worksheets("ZZ").range("c9").text
ex:=ComObjActive("Excel.Application")
value81 := ex.worksheets("ZZ").range("c10").Text
ex:=ComObjActive("Excel.Application")
value91 := ex.worksheets("ZZ").range("c11").Text
ex:=ComObjActive("Excel.Application")
value101 := ex.worksheets("ZZ").range("c12").text
c1:
Gui,B:default
;GUI,c:+ToolWindow -caption +border
Gui,c: +LastFound +AlwaysOnTop +ToolWindow -Caption -Border +E0x08000000
Gui,c: Font,s18 bold,Calibri
Gui,c: Color, Black
Gui,c: Font,s18 bold cWhite,Calibri
Gui,c:add,Text,x60 y10 ,FUTURE ROLLING:
Gui,c: Font,s18 bold cWhite,Calibri
Gui,c:add,Text,x10 y45 ,%value7% -%value71%
Gui,c:add,Text,x10 y75 ,%value8% -%value81%
Gui,c:add,Text,x10 y105,%value9% -%value91%
Gui,c:add,Text,x10 y135,%value10% -%value101%
Gui,c: Show, x50 y650 w400 h210 NoActivate
#WinActivateForce, Session A - [24 x 80]
}
return
`::
suspend
Gui,A:destroy
Gui,B:destroy
Gui,c:destroy
return