Hi, i'm currently updating a script to make it better
it's a GUI i should fill some text in(e.g date, number etc)
while it's completed, it will create a new workbook, then fill&save&exit >
Reload the GUI and do the same job(with different values)
the orginal function is like this:
enter the values1(a1, b1, c1) > store them > create a new workbook, then fill in values1(a1, b1, c1) &save&exit
> reload the GUI
enter the values2(a2, b2, c2) > store them > create a new workbook, then fill in values2(a2, b2, c2) &save&exit
> reload the GUI
enter the values3(a3, b3, c3) > store them > create a new workbook, then fill in values3(a3, b3, c3) &save&exit
> reload the GUI
... ...(more and more)
here is my thought, it will be more fast:
enter the values1(a1, b1, c1) > store them > reload the GUI >
enter the values2(a2, b2, c2) > store them > reload the GUI >
enter the values3(a3, b3, c3) > store them > reload the GUI >
... ...(more and more)
create a new workbook, then fill in values1(a1, b1, c1) &save&exit
create a new workbook, then fill in values2(a2, b2, c2) &save&exit
create a new workbook, then fill in values3(a3, b3, c3) &save&exit
... ...(more and more)
so how can i do to modify my script more reliable to realize? thanks everyone!
Store multiple values then invoke them 1by1
Re: Store multiple values then invoke them 1by1
Code: Select all
Entries := []
Gui, 1:New, +Resize, Example
Gui, Margin, 0, 0
Gui, Add, Edit, vED
Gui, Add, Button, ys gAdd, Add text
Gui, Add, Edit, xs vText ReadOnly Multi
Gui, Add, Button, xs gWorkbooks, Make workbooks
Gui, Show, AutoSize
GuiControlGet, BPos, Pos, Button1
return
GuiClose:
ExitApp
return
GuiSize:
GuiControl, Move, ED, % "w" A_GuiWidth - BPosW
GuiControl, Move, Button1, % "x" A_GuiWidth - BPosW
GuiControl, Move, Text, % "w" A_GuiWidth " h" A_GuiHeight - 2*BPosH
GuiControl, Move, Button2, % "w" A_GuiWidth " y" A_GuiHeight - BPosH
return
Enter::
Add:
Gui, Submit, NoHide
Entries.Push(ED)
GuiControl, , Text, % ED "`n" Text
GuiControl, , ED,
GuiControl, Focus, ED
return
Workbooks:
for i, val in Entries {
GenerateWorkBook(val)
}
return
GenerateWorkBook(text) {
MsgBox, % text
}
Please excuse my spelling I am dyslexic.
Re: Store multiple values then invoke them 1by1
Hi, @Capn Odin Thanks for your reply. i think there might be some misunderstanding(sorry for my English )Capn Odin wrote:Code: Select all
Entries := [] Gui, 1:New, +Resize, Example Gui, Margin, 0, 0 Gui, Add, Edit, vED Gui, Add, Button, ys gAdd, Add text Gui, Add, Edit, xs vText ReadOnly Multi Gui, Add, Button, xs gWorkbooks, Make workbooks Gui, Show, AutoSize GuiControlGet, BPos, Pos, Button1 return GuiClose: ExitApp return GuiSize: GuiControl, Move, ED, % "w" A_GuiWidth - BPosW GuiControl, Move, Button1, % "x" A_GuiWidth - BPosW GuiControl, Move, Text, % "w" A_GuiWidth " h" A_GuiHeight - 2*BPosH GuiControl, Move, Button2, % "w" A_GuiWidth " y" A_GuiHeight - BPosH return Enter:: Add: Gui, Submit, NoHide Entries.Push(ED) GuiControl, , Text, % ED "`n" Text GuiControl, , ED, GuiControl, Focus, ED return Workbooks: for i, val in Entries { GenerateWorkBook(val) } return GenerateWorkBook(text) { MsgBox, % text }
Let's say i put a1 b1 c1 d1 in the gui, the gui will store them and reload after i click on a button, then i will do the same (store a2 b2 c2 d2 and reload the gui, ... ...)
after certain loops(maybe after i click on another button to trigger), starts the next step: to open/create a new microsoft excell, fill a1 b1 c1 d1 in specified cells and save&close, then create a new file, do the same (fill a2 b2 c2 d2 in specified cells and save&close)
i know the way to relize the parts: how to save each values, how to open/create a microsoft excel, how to fill values to cells, how to close.
but my query was: which way can i store the values in each gui i got, in order to invoke them one by one(a1 b1 c1 d1 to workbook1.xlsx > a2 b2 c2 d2 to workbook2.xlsx >a3 b3 c3 d3 to workbook3.xlsx)
Re: Store multiple values then invoke them 1by1
You can put them in an array like I did in my exampleand loop through them
Code: Select all
Entries.Push([var1, var2, var3])
Code: Select all
for i, v in Entries {
GenerateWorkBook(v[1], v[2], v[3])
}
Please excuse my spelling I am dyslexic.
Re: Store multiple values then invoke them 1by1
Hi, Capn Odin, this is an script example i'm using now, i want the values (DDL, M1, NTOW, IncrementalSearch) stored and ready for use laterCapn Odin wrote:You can put them in an array like I did in my exampleand loop through themCode: Select all
Entries.Push([var1, var2, var3])
Code: Select all
for i, v in Entries { GenerateWorkBook(v[1], v[2], v[3]) }
my purpose: store values(first round from GUI) > Reload the GUI > store values(Second round from GUI) > Reload the GUI > store values(Third round from GUI) > Reload the GUI >>> Open specified .xls file, fill with values, Save&Close (First round) > Open specified .xls file, fill with values, Save&Close (Second round) > Open specified .xls file, fill with values, Save&Close (Third round)
Code: Select all
SetTitleMatchMode, 2
DetectHiddenWindows, On
SendMode Input
#SingleInstance Force
Gui, font, S13
Gui, Add, Text, x10 y2, a:
Gui, Add, Text, x10 y27, b:
Gui, Add, Text, x10 y52, c:
Gui, Add, Text, x10 y77, d:
Gui, Add, DropDownList, x85 y0 w211 vDDL gDDL, RIGHT||GOLDEN|HONG|SUCC
Gui, font, S10, WST_Engl
Gui, Add, Edit, Limit4 x85 y28 W70 h20 number vMyEdit gM1
Gui, Add, Edit, x85 y52 w70 h20 Number vAHK_MAX_UINT64 gNTOW,
Gui Add, Edit, x85 y77 w70 h20 vsearchedString gIncrementalSearch
Gui, Add, Button, x305 y402 W80 h24 gCalculate, CALCULATE
Gui, Show, , SPRING
DDL:
GuiControlGet, DDL
return
M1:
GuiControlGet, MyEdit
return
NTOW:
GuiControlGet, AHK_MAX_UINT64
return
IncrementalSearch:
GuiControlGet, searchedString
return
Calculate:
Loop C:\Users\iViLL\1\*.xls
{
If ( A_LoopFileName >= Name )
{
File1 := A_LoopFileLongPath
Filename := A_LoopFileName
}
}
Sleep 300
run, %File1%
WinWait, CON
WinWaitActive, CON
Sleep 500
XL := Excel_Get()
XL.Range["B8"].value := DDL
XL.Range["B8"].value := MyEdit
XL.Range["B8"].value := AHK_MAX_UINT64
XL.Range["B8"].value := searchedString
XL.ActiveWorkbook.SaveAs(... ...) ;Please ignore the SaveAs detail
Sleep 500
XL.WorkBooks.Close()
XL.quit
Sleep 500
Loop C:\Users\iViLL\2\*.xls
{
If ( A_LoopFileName >= Name )
{
File1 := A_LoopFileLongPath
Filename := A_LoopFileName
}
}
Sleep 300
run, %File1%
WinWait, CON
WinWaitActive, CON
Sleep 500
XL := Excel_Get()
XL.Range["C8"].value := DDL
XL.Range["C8"].value := MyEdit
XL.Range["C8"].value := AHK_MAX_UINT64
XL.Range["C8"].value := searchedString
XL.ActiveWorkbook.SaveAs(... ...) ;Please ignore the SaveAs detail
Sleep 500
XL.WorkBooks.Close()
XL.quit
Sleep 500
Loop C:\Users\iViLL\3\*.xls
{
If ( A_LoopFileName >= Name )
{
File1 := A_LoopFileLongPath
Filename := A_LoopFileName
}
}
Sleep 300
run, %File1%
WinWait, CON
WinWaitActive, CON
Sleep 500
XL := Excel_Get()
XL.Range["D8"].value := DDL
XL.Range["D8"].value := MyEdit
XL.Range["D8"].value := AHK_MAX_UINT64
XL.Range["D8"].value := searchedString
XL.ActiveWorkbook.SaveAs(... ...) ;Please ignore the SaveAs detail
Sleep 500
XL.WorkBooks.Close()
XL.quit
Sleep 500
Reload ;Reload the GUI
;... ... Repeat the steps from the start with x times
Re: Store multiple values then invoke them 1by1
I have extended the GUI to satisfy your requirements, but you will still need to implement the function GenerateWorkBook(Workbook, M1, NTOW, IS).
Code: Select all
Entries := []
Gui, 1:New, +Resize +HwndGuiHwnd, GUI Example
Gui, Margin, 0, 0
Gui, Add, Text, x5, M1:
Gui, Add, Edit, xs vM1
Gui, Add, Text, xs, NTOW:
Gui, Add, Edit, xs vNTOW
Gui, Add, Text, xs, IncrementalSearch:
Gui, Add, Edit, xs vIS
Gui, Add, DDL, xs y+5 Section vWorkbook, RIGHT||GOLDEN|HONG|SUCC
Gui, Add, Button, ys-1 gAdd vAdd, Add text
Gui, Add, Edit, xs y+5 vDisplay ReadOnly Multi
Gui, Add, Button, xs y+5 gWorkbooks vMake, Make workbooks
Gui, Show, Hide AutoSize
GuiControlGet, AddPos, Pos, Add
GuiControlGet, MakePos, Pos, Make
GuiControlGet, DisplayPos, Pos, Display
Gui, Show, w400 h600
return
GuiClose:
ExitApp
return
GuiSize:
Critical
GuiControl, Move, M1, % "w" A_GuiWidth - 5*2
GuiControl, Move, NTOW, % "w" A_GuiWidth - 5*2
GuiControl, Move, IS, % "w" A_GuiWidth - 5*2
GuiControl, Move, Workbook, % "w" A_GuiWidth - AddPosW - 5*3
GuiControl, Move, Add, % "x" A_GuiWidth - AddPosW - 5
GuiControl, Move, Make, % "w" A_GuiWidth - 5*2 " y" A_GuiHeight - MakePosH - 5
GuiControlGet, MakePos, Pos, Make
GuiControl, Move, Display, % "w" A_GuiWidth - 5*2 " h" MakePosY - DisplayPosY - 5
return
~Enter::
Add:
Gui, Submit, NoHide
Entries.Push([Workbook, M1, NTOW, IS])
GuiControl, , Display, % Workbook ", " M1 ", " NTOW ", " IS "`n" Display
GuiControl, , M1
GuiControl, , NTOW
GuiControl, , IS
GuiControl, Focus, M1
return
Workbooks:
for i, entry in Entries {
GenerateWorkBook(entry[1], entry[2], entry[3], entry[4])
}
return
GenerateWorkBook(Workbook, M1, NTOW, IS) {
MsgBox, % "WorkBook:`t`t" Workbook "`nM1:`t`t`t" M1 "`nNTOW:`t`t`t" NTOW "`nIncremental Search:`t" IS
}
Please excuse my spelling I am dyslexic.
Who is online
Users browsing this forum: No registered users and 386 guests