這是我的 AHK 腳本:
Gui, Add, Edit, x77 y15 w100 h30 vMyvar gEdit1 ;first edit box, there can be entered any value.
Gui, Add, Edit, x237 y15 w100 h30 vNewvar Disabled, %Newvar% ;second edit box it shows the result by multiplying the first edit box's value by 100.
Gui, Add, Edit, x72 y60 w100 h30 vMyv gEdit2 ;third edit box, there can be entered any value.
Gui, Add, Edit, x242 y60 w100 h30 vNewv Disabled, %Newv% ;fourth edit box it shows the result by multiplying the second edit box's value by 50
Gui, Add, Edit, x242 y110 w100 h30 vTotal Disabled ;this edit box shows the total of %Newvar% and %Newv% i.e. second edit box and fourth edit box.
Gui, Add, ListView, x282 y200 w100 h300 , 100|50|total ;listview box which lists the values of first edit box and third edit box
Gui, Add, Button, x62 y120 w100 h30 gNext, NEXT ;next botton which when pressed lists the values of first edit box and third edit box and also clears the second edit box and fourth edit box everytime it pressed.
Gui, Show, w473 h373, Untitled GUI
return
Edit1:
Gui, Submit, NoHide
NewVar := Myvar * 100
GuiControl,, Newvar, %Newvar%
gosub, SetTotal
return
Edit2:
Gui, Submit, NoHide
NewV := Myv * 50
GuiControl,, Newv, %Newv%
gosub, SetTotal
return
SetTotal:
Total := 0
if NewVar is number
Total += NewVar
if Newv is number
Total += Newv
GuiControl,, Total, %Total%
return
Next:
Gui, Submit, NoHide
LV_Insert(1,, Myvar, Myv, Total)
Newvar := ""
Newv := ""
Total := ""
GuiControl,, Newvar, %Newvar%
GuiControl,, Newv, %Newv%
GuiControl,, Total, %Total%
return
我希望將這些控制項新增到此 GUI 中:
Gui, Add, ListView, x62 y170 w200 h300 , s no|100|50|total ; this listview box is for negative values and i added s no column also in it which should contain the serial no as the negative values are entered in this box.
Gui, Add, ListView, x282 y170 w200 h300 , s no|100|50|total ; same listview box for positive values.
Gui, Add, Text, x402 y20 w130 h20 , no of negative values
Gui, Add, Text, x402 y50 w130 h20 , total of negative value
Gui, Add, Edit, x542 y20 w100 h20 , ;in this edit box i want that there should come only the total no of negative values. say there are 10 nagative values in negative listview box then it should contain only no 10
Gui, Add, Edit, x542 y50 w100 h20 , ; in this edit box i want that it should contain the total of all the negative values i.e. if the total of all 10 negative value is say 50000 then it should contain 50000.
GuiClose:
ExitApp
因為我想要兩個列表視圖框,其中第一個應該列出正值,另一個應該列出負值,因為總數(因為第三個編輯框顯示%Newvar%和%Newv%的總數)是正數,那麼它應該是列在正值列表視圖框中,總計為負數,則應列在負值列表視圖框中。此外,負列表視圖框和正列表視圖框都應該有“無”(序號)列。我又製作了兩個編輯框,其中我希望應該出現負值的數量,而在另一個編輯框中應該出現所有負值的總數。
答案1
聽起來你的程式流程如下:
- 在 GUI 1 中,使用者輸入項目,點擊下一步,然後將它們新增到表中
- 在 GUI 2 中,GUI 1 表中的項目被分類為表 A(正)和表 B(負)
聽起來您可能需要做的是進行以下調整:
- 對於 GUI1,新增另一個按鈕以繼續到 GUI2。我們將其稱為“繼續”按鈕。
- 當按下“繼續”按鈕時...
- 隱藏圖形使用者介面1
- 循環遍歷最終 GUI1 表中的所有值
- 對於每個值,根據其是負數還是正數將其添加到 GUI2 表之一(或將寫入該表的變數)
- 所有數字都處理成對應的表格後,顯示GUI2
- 您需要重構上面的程式碼,使 GUI2 成為第二個 GUI(使用多個 GUI 時,請根據需要參閱說明文件——基本上,您只需在所有命令前面添加 GUI 編號即可)