Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Error: The same variable cannot be used more than once


  • Please log in to reply
5 replies to this topic
Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004
Hello all,
I have been trying to develop my TreePad script further for sending different types of emails. To do this I had set up radio buttons in the following script (which only outlines the first 2 radio buttons):

; USE RIGHT MOUSE BUTTON TO SEND SELECTED NODE ARTICLE TO EMAIL
^RButton::
MyRadio = 
Gui, add, radio, vMyRadio, Email as plain text
Gui, add, radio,, Email as rtf text
Gui, add, radio,, Email as text attachment
Gui, add, radio,, Email as rtf attachment
Gui, add, button, default xm, OK  ; xm puts it at the bottom left corner.
Gui, show
return

ButtonOK:
GuiClose:
GuiEscape:
Gui, submit
MsgBox You entered:`n%MyRadio%
gosub, %MyRadio%
return

; SEND SELECTED NODE ARTICLE TO EMAIL AS PLAIN TEXT
1:
Send,^a+^c
Run, mailto:
WinWaitActive, New Message
Send,{Tab 3}^v
WinMaximize, New Message
Send,^a!oy{enter}^{Home}
return


; SEND SELECTED NODE ARTICLE TO EMAIL AS RTF
2:
Send,^a^c
Run, mailto:
WinWaitActive, New Message
Send,{Tab 3}^v
WinMaximize, New Message
Send,^a!oy{enter}^{Home}
return


This works fine the first time I run it, but when I run it again I get the following error message:

"Error: The same variable cannot be used for more than one control per window

Specifically vMyRadio

and points to:
Gui, add, radio, vMyRadio, Email as plain text"

I have read the help file but I cannot see any solution. Perhaps someone might be able to point me in the right direction.

Many thanks,
Martin O'Neill

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
the problem is that u're adding the same controls everytime u want to show the gui... so either add once and re-show everytime (like the script below) or destroy and then add again (bad idea).

; USE RIGHT MOUSE BUTTON TO SEND SELECTED NODE ARTICLE TO EMAIL 
MyRadio = 
Gui, add, radio, vMyRadio, Email as plain text 
Gui, add, radio,, Email as rtf text 
Gui, add, radio,, Email as text attachment 
Gui, add, radio,, Email as rtf attachment 
Gui, add, button, default xm, OK  ; xm puts it at the bottom left corner. 

^RButton:: 
Gui, show 
return 

ButtonOK: 
GuiClose: 
GuiEscape: 
Gui, submit 
MsgBox You entered:`n%MyRadio% 
gosub, %MyRadio% 
return 

; SEND SELECTED NODE ARTICLE TO EMAIL AS PLAIN TEXT 
1: 
Send,^a+^c 
Run, mailto: 
WinWaitActive, New Message 
Send,{Tab 3}^v 
WinMaximize, New Message 
Send,^a!oy{enter}^{Home} 
return 


; SEND SELECTED NODE ARTICLE TO EMAIL AS RTF 
2: 
Send,^a^c 
Run, mailto: 
WinWaitActive, New Message 
Send,{Tab 3}^v 
WinMaximize, New Message 
Send,^a!oy{enter}^{Home} 
return 

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004
Rajat,
I have tried your suggested code, but the radio button window does not show and the script goes to the message box and then exits the script as I have not selected anything.

This script is part of a larger script and I wonder if something else is interfering with the gui show, though this is the only time I have used this in the script (which I have attached below)

; for use with TreePad
; Revised 20:50 Sun 21 November 2004
; ===================================
; CONFINE TO TREEPAD WINDOW
; In the auto-execute section (top part) of the script:
SetTimer, WatchWindow, 500
return

WatchWindow:
IfWinActive, TreePad    ; Checks if TreePad active
     Suspend, Off       ; Does NOT suspend script
else
     Suspend, On        ; Suspends script
return
; ===================================

; SPACEBAR FOR FORWARD NAVIGATION
/* This section commented out for the moment
~space::
IfNotInString, A_PriorHotkey, space
{

   KeyWait, space
   return
}
if A_TimeSincePriorHotkey > 400 ; Too much time between presses, so this isn't a double-press.
{
   Send, {space}
   KeyWait, space
   return
}
; Otherwise, it's a double-press:
Send, ^!{Down}
return
*/
; ====================================
; SOME SHORT CUT KEYS
^+U::Send !ocu		;; Change text  to Upper case
^+L::Send !oco		; Change text  to lower case
^+K::Send !oci		; Change text  to mixed Title case
^!v::Send, ^c{F11}^v{F12}		; Copy  text from node title and paste into article

; ====================================
; TEXT EXPANSIONS
::mon::Martin O'Neill
::cw::Carlow
::ke::Kildare
::wx::Wexford
::snh::Special Needs Home
::tn::Tintean
::vat::VAT
; ====================================
; USE F4 TO TURN TREE ON AND OFF
~F4::
IfNotInString, A_PriorHotkey, F4
{
   Send, ^{F12}
   KeyWait, F4
   return
}
if A_TimeSincePriorHotkey > 400 ; Too much time between presses, so this isn't a double-press.
{
   Send, ^{F12}
   KeyWait, space
   return
}
; Otherwise, it's a double-press:
Send, ^{F10}
return

; ====================================

; USE RIGHT MOUSE BUTTON TO SEND SELECTED NODE ARTICLE TO EMAIL
;MyRadio =
Gui, add, radio, vMyRadio, Email as plain text
Gui, add, radio,, Email as rtf text
Gui, add, radio,, Email as text attachment
Gui, add, radio,, Email as rtf attachment
Gui, add, button, default xm, OK  ; xm puts it at the bottom left corner.

^RButton::
Gui, show
; return
ButtonOK:
GuiClose:
GuiEscape:
Gui, submit
MsgBox You entered:`n%MyRadio%
gosub, %MyRadio%
return

; SEND SELECTED NODE ARTICLE TO EMAIL AS PLAIN TEXT
1:
Send,^a+^c
Run, mailto:
WinWaitActive, New Message
Send,{Tab 3}^v
WinMaximize, New Message
Send,^a!oy{enter}^{Home}
return


; SEND SELECTED NODE ARTICLE TO EMAIL AS RTF
2:
Send,^a^c
Run, mailto:
WinWaitActive, New Message
Send,{Tab 3}^v
WinMaximize, New Message
Send,^a!oy{enter}^{Home}
return

Many thanks for your help
Martin

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
the gui is not created at all in your script. it needs to be created before showing, and the creation (gui, add) has to be before the first 'return' or 'exit' command.

here's another approach by which u don't have to keep the 'gui, add' statements at the top:

#a::
	IfNotEqual, FirstTimeA, No
	{
		Gui, add, button,, just a test button
		FirstTimeA = No
	}
	
	Gui, Show,, About..
Return

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004
[quote name="Rajat"]

here's another approach by which u don't have to keep the 'gui, add' statements at the top:

Rajat, I didn't understand your code last weekend and so had to spend some time thinking about it and reading the relevant parts of the help file. I think I understand how it works now. Many thanks.

Martin

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i'm glad u understood it. actually i've this habit of giving broad guidelines/directions to the solution instead of giving the solution script directly. maybe its laziness on my part, but i believe that in the long run it helps, as the other person while doing the research reqd for following the directions, learns stuff besides what he's after ...and so improves his skills.

i rarely give complete solution scripts (though i made an exception above) but definitely appreciate ppl who take time to do so, like chris and beardboy.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat