Reputation: 77
/**********************************
GUI
*/
Gui, Add, Edit, x12 y7 w163 h19 vLoopCount, Loopcount
Gui, Add, Edit, x12 y26 w163 h19 vCheckCount, ErrorCheck
Gui, Add, Button, x12 y55 w76 h19 gStart, Start
Gui, Show, w194 h80, Test
return
Start:
gui, submit, nohide
count := LoopCount
check_count_basic := CheckCount
gui, hide
check_count := check_count_basic
VarSetCapacity(vLoopCount,0)
VarSetCapacity(vCheckCount,0)
/**********************************
GUI
*/
Is a tiny part of My ahk script.
See, I not have 'ExitApp' method in Script. because i want use script without "Re-Run Script".
but, If i try second starting my Script.
"The Same variable cannot be used for more than one control"
I already Know Ahk's variable is not reusable. So i try using 'VarSetCapacity(vLoopCount,0)'. but isn't work what i think.
How can i do? It is really one way "use 'ExitApp' method"?
Upvotes: 1
Views: 991
Reputation:
If you want to reuse the exact same GUI within your code, you only need it in your code once. Use the GuiControl
command to update specific controls. For instance, should you need to clear out your "LoopCount" variable for a different set of code, you could do something like this:
LoopCount := 0
GuiControl ,, LoopCount , %LoopCount%
Gui , Show
The VarSetCapacity
function is used for setting how much memory your variable can use. In your case, even though you're clearing it out, it still exists as a name and cannot be used for more than one control since AHK uses this name as one means of identifying it.
From your code, it looks like you already understand how to use Gui , Hide
and Gui , Show
. I think that's really all you need to accomplish what you're asking.
Upvotes: 1