AutoHotkey Community

It is currently May 27th, 2012, 4:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Duplicate variable error
PostPosted: March 9th, 2010, 11:04 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Hey everyone. I am getting an annoying duplicate variable error when there is not a duplicate variable. Can anyone help me out with this?

Code:
SetTimer, CBN, 50
MsgBox, 4131, New Request, Which request would you like to fill out?
CBN:
IfWinNotExist, New Request
   Return
ControlSetText, Button1, &VOICE
ControlSetText, Button2, &PLS
 IfMsgBox, Yes ; VOICE
   REQUEST = VOICE
 IfMsgBox, No ; PLS
   REQUEST = PLS
Gui, Font, w700
Gui, Add, GroupBox, x11 y4 w280 h180 , Customer
Gui, Font, w400
Gui, Add, Text, x21 y24 w40 h20 , Name
Gui, Add, Edit, x21 y44 w260 h20 vCNAME,
Gui, Add, Text, x21 y74 w110 h20 , Account Number
Gui, Add, Edit, x21 y94 w260 h20 vCNUM, 2
Gui, Add, Text, x21 y124 w80 h20 , Product Line
Gui, Add, DropDownList, x21 y144 w150 h10 vPRODLN, 3
Gui, Add, Text, x181 y124 w50 h20 , Version
Gui, Add, DropDownList, x181 y144 w100 h20 vVERS, 4
Gui, Font, w700
Gui, Add, GroupBox, x11 y194 w280 h180 , Partner
Gui, Font, w400
Gui, Add, Text, x21 y214 w40 h20 , Name
Gui, Add, Edit, x21 y234 w260 h20 vPNAME, 5
Gui, Add, Text, x21 y264 w110 h20 , Account Number
Gui, Add, Edit, x21 y284 w260 h20 vPNUM, 6
Gui, Add, Text, x21 y314 w60 h20 , Location
Gui, Add, Edit, x21 y334 w260 h20 vLOC, 7
Gui, Font, w700
Gui, Add, GroupBox, x301 y4 w280 h180 , VSA
Gui, Font, w400
Gui, Add, Text, x311 y24 w160 h20 , Service Request Number
Gui, Add, Edit, x311 y44 w260 h20 vSRNUM, 8
Gui, Add, Text, x311 y74 w100 h20 , Order Number
Gui, Add, Edit, x311 y94 w260 h20 vORDNUM, 9
Gui, Add, Text, x311 y124 w80 h20 , Order Total
Gui, Add, Edit, x311 y144 w260 h20 vORDTOT, 10
Gui, Font, w700
Gui, Add, GroupBox, x301 y194 w280 h180 , Steps
Gui, Font, w400
Gui, Add, Text, x311 y214 w260 h20 , Steps taken to research the inquiry/order:
Gui, Add, Edit, x311 y234 w260 h50 vSTEPS, 11
Gui, Add, Text, x311 y294 w260 h20 , Detailed description of the issue:
Gui, Add, Edit, x311 y314 w260 h50 vDESC, 12
Gui, Add, Button, x21 y384 w100 h30 , 13
Gui, Add, Button, x171 y384 w100 h30 , 14
Gui, Add, Button, x321 y384 w100 h30 , 15
Gui, Add, Button, x471 y384 w100 h30 , Submit
Gui, Show, w598 h428, VOICE/PLS Request
Return

GuiClose:
ExitApp


The issue seems to be isolated to the timer up top to change the button names. When I take that part out, it works perfect. What's going on here? I have tried to change my variable name (CNAME) to something else, but this does not do it. I have also tried to change the "ControlSetText" line to change buttons "Yes" and "No" instead of "Button1(2)." I am so frustrated with troubleshooting it, I had to post it all up. Sorry for the length, and thank you for any replies.

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 9th, 2010, 11:08 pm 
You are falling into the same "trying to re-create the Gui every time" problem that many users have had...

You need to build the Gui once, then show/hide & use GuiControl to change things about it...

Move all the Gui, Add's above the CBN label & try to make it work that way...this is a common error/mistake, I need to find or create a concrete example of it & how to get past it...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:12 pm 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
Code:
SetTimer, CBN, 50
MsgBox, 4131, New Request, Which request would you like to fill out?

Gui, Font, w700
Gui, Add, GroupBox, x11 y4 w280 h180 , Customer
Gui, Font, w400
Gui, Add, Text, x21 y24 w40 h20 , Name
Gui, Add, Edit, x21 y44 w260 h20 vCNAME,
Gui, Add, Text, x21 y74 w110 h20 , Account Number
Gui, Add, Edit, x21 y94 w260 h20 vCNUM, 2
Gui, Add, Text, x21 y124 w80 h20 , Product Line
Gui, Add, DropDownList, x21 y144 w150 h10 vPRODLN, 3
Gui, Add, Text, x181 y124 w50 h20 , Version
Gui, Add, DropDownList, x181 y144 w100 h20 vVERS, 4
Gui, Font, w700
Gui, Add, GroupBox, x11 y194 w280 h180 , Partner
Gui, Font, w400
Gui, Add, Text, x21 y214 w40 h20 , Name
Gui, Add, Edit, x21 y234 w260 h20 vPNAME, 5
Gui, Add, Text, x21 y264 w110 h20 , Account Number
Gui, Add, Edit, x21 y284 w260 h20 vPNUM, 6
Gui, Add, Text, x21 y314 w60 h20 , Location
Gui, Add, Edit, x21 y334 w260 h20 vLOC, 7
Gui, Font, w700
Gui, Add, GroupBox, x301 y4 w280 h180 , VSA
Gui, Font, w400
Gui, Add, Text, x311 y24 w160 h20 , Service Request Number
Gui, Add, Edit, x311 y44 w260 h20 vSRNUM, 8
Gui, Add, Text, x311 y74 w100 h20 , Order Number
Gui, Add, Edit, x311 y94 w260 h20 vORDNUM, 9
Gui, Add, Text, x311 y124 w80 h20 , Order Total
Gui, Add, Edit, x311 y144 w260 h20 vORDTOT, 10
Gui, Font, w700
Gui, Add, GroupBox, x301 y194 w280 h180 , Steps
Gui, Font, w400
Gui, Add, Text, x311 y214 w260 h20 , Steps taken to research the inquiry/order:
Gui, Add, Edit, x311 y234 w260 h50 vSTEPS, 11
Gui, Add, Text, x311 y294 w260 h20 , Detailed description of the issue:
Gui, Add, Edit, x311 y314 w260 h50 vDESC, 12
Gui, Add, Button, x21 y384 w100 h30 , 13
Gui, Add, Button, x171 y384 w100 h30 , 14
Gui, Add, Button, x321 y384 w100 h30 , 15
Gui, Add, Button, x471 y384 w100 h30 , Submit
Gui, Show, w598 h428, VOICE/PLS Request

CBN:
IfWinNotExist, New Request
   Return
ControlSetText, Button1, &VOICE
ControlSetText, Button2, &PLS
 IfMsgBox, Yes ; VOICE
   REQUEST = VOICE
 IfMsgBox, No ; PLS
   REQUEST = PLS
Return

GuiClose:
ExitApp

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 9th, 2010, 11:15 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Anonymous wrote:
You are falling into the same "trying to re-create the Gui every time" problem that many users have had...

You need to build the Gui once, then show/hide & use GuiControl to change things about it...

Move all the Gui, Add's above the CBN label & try to make it work that way...this is a common error/mistake, I need to find or create a concrete example of it & how to get past it...


-Guest
Firstly, thank you for your reply. I'm not sure I understand why this is happening. Aren't I just building the gui once the way it was?

-Eedis
Thank you.

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 9th, 2010, 11:19 pm 
Jeremiah wrote:
Aren't I just building the gui once the way it was?

...no, the CBN timer was hitting all the Gui, Add's before...

Wait...the CBN timer is only to change the msgbox?...change that to "SetTimer, CBN, -50"...negative means to run only once...currently it's constantly changing the msgbox's button names to what they already are...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:24 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
That worked great! Both methods worked great. I don't really have much experience with the Timers, I just copied and pasted the example that was in the documentation. I'm still confused about how a timer works for this, but hey... it works. Thanks guys!

_________________
-Jeremiah


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], rbrtryn, Yahoo [Bot] and 68 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