AutoHotkey Community

It is currently May 25th, 2012, 10:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: July 7th, 2007, 4:01 pm 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 5:59 pm 
Offline

Joined: June 23rd, 2007, 12:23 pm
Posts: 87
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! :shock: :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2007, 2:23 pm 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
I've read a bit about global variables in the manual but I'm afraid I don't really get :oops:
How would this look in this script?

Tnx

_________________
In a world without walls and fences, who needs Windows and Gates?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2007, 2:56 pm 
Offline

Joined: June 23rd, 2007, 12:23 pm
Posts: 87
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! :shock: :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2007, 3:56 pm 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2007, 4:18 pm 
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.


Report this post
Top
  
Reply with quote  
PostPosted: July 9th, 2007, 4:19 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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
..


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2007, 4:26 pm 
Offline

Joined: February 9th, 2006, 10:39 am
Posts: 33
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: [VxE], Google [Bot], just me and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group