AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Same variable cannot be used for more than one control

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Sat Jul 07, 2007 3:01 pm    Post subject: Same variable cannot be used for more than one control Reply with quote

Hello,

Probably a dumb question but here it goes;
I get this error: Same variable cannot be used for more than one control
Specifically: vcount

How can I change my script so it won't 'remember' I used this variable before?

Code:
#µ::
IfWinActive, Microsoft Excel - Herstellingen 2007.xls
{
Gui, Add, Text, x15 y15 w100 h20 center, Hoeveel rijen?
Gui, Add, Edit, x15 y40 w100 h20 center vcount Number Limit2,
Gui, Add, UpDown, Range1-10, 2
Gui, Add, GroupBox, x6 y-3 w117 h102,
Gui, Add, Button, x40 y70 w50 h20 default, Ok
Gui, Show, h105 w128, Printen
Return

GuiClose:
GuiEscape:
Gui, Destroy
return

ButtonOk:
Gui, Submit

Loop, %count%
{
Send {Home}{LEFT}
...
Send {Down 5}{WheelDown 2}
}
return
}
return
Tnx
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Tarch



Joined: 23 Jun 2007
Posts: 87

PostPosted: Sat Jul 07, 2007 4:59 pm    Post subject: Reply with quote

Hi,
the problem is that the variable you use in the v option of gui add must be global, so you have to change the name of the variable in the previous control or in this.

Bye! Shocked Smile
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Mon Jul 09, 2007 1:23 pm    Post subject: Reply with quote

I've read a bit about global variables in the manual but I'm afraid I don't really get Embarassed
How would this look in this script?

Tnx
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Tarch



Joined: 23 Jun 2007
Posts: 87

PostPosted: Mon Jul 09, 2007 1:56 pm    Post subject: Reply with quote

Hi,
if what you posted is the entire script I doesn't see where is the problem. Otherwise assuming that you have another line like:
Code:

Gui, Add, WhatYouWant, ... vcount ..., ....

you should change it to something else e.g.:
Code:

Gui, Add, WhatYouWant, ... vcount1 ..., ....
.

In any case global means that that the variable is visible in any point of the script, you can access to it from any point, and change its value in any point.

Bye! Shocked Smile
Back to top
View user's profile Send private message
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Mon Jul 09, 2007 2:56 pm    Post subject: Reply with quote

It's the only v var & there is only 1 GUI.
It works once but when I use it again (press #µ) I get the error.
Reload helps so it seems it remembers that I used the var before, is there a way to make it forget besides reloading the script (sorry for the crappy English)?

Code:
#NoTrayIcon

#c::
Process, priority, ntvdm.exe, Low
return
; -------------------------------------------
#O::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, BETALING NETTO CONTANT OP REKENING
Send, {ENTER}
Sleep, 100
Send, ING 320-0683206-08
Send, {ENTER 2}
Sleep, 100
Send, PDW
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
#B::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, ONTVANGEN BC
Send, {ENTER 2}
Send, PDW
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
#K::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, ONTVANGEN CASH
Send, {ENTER 2}
Send, PDW
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
!O::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, BETALING NETTO CONTANT OP REKENING
Send, {ENTER}
Sleep, 100
Send, ING 320-0683206-08
Send, {ENTER 2}
Sleep, 100
Send, DO
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
!B::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, ONTVANGEN BC
Send, {ENTER 2}
Send, DO
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
!K::
IfWinActive, ahk_class ConsoleWindowClass
{
Sleep, 500
SetKeyDelay, 5
Send, ONTVANGEN CASH
Send, {ENTER 2}
Send, DO
Send, {ENTER}
Send, {Esc 2}{ENTER 8}
}
return
; -------------------------------------------
#i::
IfWinActive, ahk_class ConsoleWindowClass
{
; Send, {ENTER}
Send, IMEI:
Send {Space}
}
return
; -------------------------------------------
#n::
IfWinActive ahk_class ConsoleWindowClass
{
Send, DIV
Send, {ENTER}
Send, GSM NOKIA
Send {Space}
KeyWait, ENTER, D
Send, 705110
Send, {ENTER}
}
return
; -------------------------------------------
#r::
IfWinActive ahk_class ConsoleWindowClass
{
Send, REC GSM
; Send, {ENTER 2}
; KeyWait, ENTER, D
; Send, 0.17
Send, {ENTER}
}
return
; -------------------------------------------
#s::
IfWinActive ahk_class ConsoleWindowClass
{
Send, DIV
Send, {ENTER}
Send, GSM SAMSUNG
Send {Space}
KeyWait, ENTER, D
Send, 705113
Send, {ENTER}
}
return
; -------------------------------------------
^µ::
IfWinActive, Microsoft Excel - Herstellingen 2007.xls
{
Send {Home}{LEFT}
Send ^c
Sleep, 500
ClipSaved := ClipboardAll
Sleep, 500
Send ^m
Sleep, 250
Send ^p
WinWaitActive, Afdrukken
Send {SHIFT Down}{TAB 3}{SHIFT Up}
Send, 1   
Send {TAB}
Send, 1
Send {TAB 2}{UP}
WinWaitClose, Afdrukken
Sleep, 500
WinWaitActive, Afdrukken
WinWaitClose, Afdrukken
Sleep, 500
Send ^l
Sleep, 500
Send ^g
Sleep, 500
Send, A
Sleep, 500
Clipboard := ClipSaved
Send ^v
Send {Enter}
Send {Down 5}{WheelDown 2}
}
return
; -------------------------------------------
#µ::
IfWinActive, Microsoft Excel - Herstellingen 2007.xls
{
Gui, Add, Text, x15 y15 w100 h20 center, Hoeveel rijen?
Gui, Add, Edit, x15 y40 w100 h20 center vtel Number Limit2,
Gui, Add, UpDown, Range1-10, 2
Gui, Add, GroupBox, x6 y-3 w117 h102,
Gui, Add, Button, x40 y70 w50 h20 default, Ok
Gui, Show, h105 w128, Printen
Return

GuiClose:
GuiEscape:
Gui, Destroy
return

ButtonOk:
Gui, Submit

Loop, %tel%
{
Send {Home}{LEFT}
Send ^c
Sleep, 500
ClipSaved := ClipboardAll
Sleep, 500
Send ^m
Sleep, 250
Send ^p
WinWaitActive, Afdrukken
Send {SHIFT Down}{TAB 3}{SHIFT Up}
Send, 1   
Send {TAB}
Send, 1
Sleep, 250
Send {ENTER}
WinWaitClose, Afdrukken
Sleep, 500
WinWaitActive, Afdrukken
WinWaitClose, Afdrukken
Sleep, 500
Send ^l
Sleep, 500
Send ^g
Sleep, 500
Send, A
Sleep, 500
Clipboard := ClipSaved
Send ^v
Send {Enter}
Sleep, 250
Send {Down 5}{WheelDown 2}
Sleep, 2000
}
return
}
return
; -------------------------------------------
#p::
IfWinActive, Microsoft Excel - Herstellingen 2007.xls
{
FormatTime, DateTime, , dd-MM-yy
Send, % DateTime
Send {Right}
Send, Peter
Send {Right}
}
return
; -------------------------------------------
#d::
IfWinActive, Microsoft Excel - Herstellingen 2007.xls
{
FormatTime, DateTime, , dd-MM-yy
Send, % DateTime
Send {Home}
}
return
; -------------------------------------------
^!r::Reload


Tnx
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Helpy
Guest





PostPosted: Mon Jul 09, 2007 3:18 pm    Post subject: Reply with quote

This message often appears when you try to re-create a GUI without destroying the previous instance.
You have to either use Gui Destroy, or re-display the GUI, not re-create it.
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Mon Jul 09, 2007 3:19 pm    Post subject: Re: Same variable cannot be used for more than one control Reply with quote

Whitespliff wrote:
How can I change my script so it won't 'remember' I used this variable before?


Add Gui, Destroy as the first line, Like:

Code:
..
#µ::
Gui, Destroy
..


Smile
Back to top
View user's profile Send private message Send e-mail
Whitespliff



Joined: 09 Feb 2006
Posts: 33

PostPosted: Mon Jul 09, 2007 3:26 pm    Post subject: Reply with quote

This works, I did forgot to destroy the GUI, tnx a lot!

And tnx for telling me about these global var, didn't knew that Wink
_________________
In a world without walls and fences, who needs Windows and Gates?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group