Page 1 of 1

checkbox issue

Posted: 01 Apr 2017, 03:24
by duzymichal
Hi, I'm a complete beginner at AHK. The script below was born out of smartgui, guide reading, trial and error. Until the day before yesterday this script ran flawlessly. And yesterday, just when I wanted to distribute it among my colleagues, I noticed that that the output either reflects or doesn't the state of checkboxes at random. Any help with this will be greatly appreciated.

Code: Select all

; SU Quickpaste

Gui,+AlwaysOnTop
gui, font, s10, Verdana
Gui, Add, Tab2, x42 y20 w390 h310 , SC created | Chasing | PO created
Gui, Add, Edit, vPR x232 y100 w160 h30
Gui, Add, Edit, vSC x232 y170 w160 h30
Gui, Add, Text, x92 y100 w110 h30 , Purchase Request
Gui, Add, Text, x92 y170 w110 h30 , Shopping Cart
Gui, Add, CheckBox, Checked x262 y230 w130 h40 vnotification, PO notification
Gui, Add, Button, default gOk x182 y280 w90 h30 , OK

Gui, Tab, 2
Gui, Add, Text, x142 y150 w90 h30 , Shopping Cart
Gui, Add, Edit, vSC2 x252 y150 w120 h30 
Gui, Add, CheckBox, x302 y240 w100 h30 vUrgent, Urgent
Gui, Add, Button, default gOk2 x182 y280 w90 h30 , OK

Gui, Tab, 3
Gui, Add, Text, x92 y100 w100 h30 , Purchase Request
Gui, Add, Text, x92 y170 w100 h30 , Purchase Order
Gui, Add, Edit, vPR2 x232 y100 w150 h30
Gui, Add, Edit, vPO x232 y170 w150 h30
Gui, Add, CheckBox, Checked x272 y240 w100 h30 vGRN, GRN notification
Gui, Add, Button, default gOk3 x182 y280 w90 h30 , OK


Gui, Show, x226 y116 h383 w483, SU Quickpaste
Return

ok:

{
Gui, submit, 

	clipboard = text (%PR%) text %SC% 
        

if notification = 1
	clipboard = 
	clipboard = some other text (%PR%) some other text %SC%.some other text.

GuiControl,,PR,
GuiControl,,SC,
Gui Minimize

		
}
return



ok2:

{
Gui, submit, 
	clipboard = text %SC2% text.


if Urgent = 1
	clipboard = 
	clipboard = some other text %SC2% some other text.			

GuiControl,,SC2,
Gui Minimize
	
} 
return


ok3:

{
Gui, submit, 

	clipboard = text (%PR2%) text %PO%. 


if GRN = 1
	clipboard = 
	clipboard = some other text (%PR2%) some other text.		

GuiControl,,PR2,
GuiControl,,PO,
Gui Minimize

} 
return


GuiClose:
ExitApp
GuiEscape:
ExitApp



Re: checkbox issue

Posted: 01 Apr 2017, 11:12
by Xtra
Add a glabel to each checkbox line and create a check: label that submits the change.
Also added a Gui,Submit,NoHide after showing the gui because you set one of the checkboxes to be checked by default.

See below:

Code: Select all

; SU Quickpaste

Gui,+AlwaysOnTop
gui, font, s10, Verdana
Gui, Add, Tab2, x42 y20 w390 h310 , SC created | Chasing | PO created
Gui, Add, Edit, vPR x232 y100 w160 h30
Gui, Add, Edit, vSC x232 y170 w160 h30
Gui, Add, Text, x92 y100 w110 h30 , Purchase Request
Gui, Add, Text, x92 y170 w110 h30 , Shopping Cart
Gui, Add, CheckBox, Checked x262 y230 w130 h40 vnotification gCheck, PO notification
Gui, Add, Button, default gOk x182 y280 w90 h30 , OK

Gui, Tab, 2
Gui, Add, Text, x142 y150 w90 h30 , Shopping Cart
Gui, Add, Edit, vSC2 x252 y150 w120 h30 
Gui, Add, CheckBox, x302 y240 w100 h30 vUrgent gCheck, Urgent
Gui, Add, Button, default gOk2 x182 y280 w90 h30 , OK

Gui, Tab, 3
Gui, Add, Text, x92 y100 w100 h30 , Purchase Request
Gui, Add, Text, x92 y170 w100 h30 , Purchase Order
Gui, Add, Edit, vPR2 x232 y100 w150 h30
Gui, Add, Edit, vPO x232 y170 w150 h30
Gui, Add, CheckBox, Checked x272 y240 w100 h30 vGRN gCheck, GRN notification
Gui, Add, Button, default gOk3 x182 y280 w90 h30 , OK


Gui, Show, x226 y116 h383 w483, SU Quickpaste
Gui, Submit, NoHide
Return

check:
    Gui, Submit, NoHide
return



ok:

{
Gui, submit, 

	clipboard = text (%PR%) text %SC% 
        

if notification = 1
	clipboard = 
	clipboard = some other text (%PR%) some other text %SC%.some other text.

GuiControl,,PR,
GuiControl,,SC,
Gui Minimize

		
}
return



ok2:

{
Gui, submit, 
	clipboard = text %SC2% text.


if Urgent = 1
	clipboard = 
	clipboard = some other text %SC2% some other text.			

GuiControl,,SC2,
Gui Minimize
	
} 
return


ok3:

{
Gui, submit, 

	clipboard = text (%PR2%) text %PO%. 


if GRN = 1
	clipboard = 
	clipboard = some other text (%PR2%) some other text.		

GuiControl,,PR2,
GuiControl,,PO,
Gui Minimize

} 
return


GuiClose:
ExitApp
GuiEscape:
ExitApp

HTH

Re: checkbox issue

Posted: 01 Apr 2017, 12:55
by duzymichal
Thank you for taking a look at the script. I'm afraid it still doesn't work. Whether I check or uncheck the boxes the output is always checked... It's possible that I didn't get your instructions, but it's my understanding that everything was included in the amended version?

Re: checkbox issue

Posted: 01 Apr 2017, 13:00
by wolf_II

Re: checkbox issue  Topic is solved

Posted: 01 Apr 2017, 13:04
by tomoe_uehara
Hello, the checkbox works fine, I guess your problem lies within your IF statement:

Code: Select all

; SU Quickpaste

Gui,+AlwaysOnTop
gui, font, s10, Verdana
Gui, Add, Tab2, x42 y20 w390 h310 , SC created | Chasing | PO created
Gui, Add, Edit, vPR x232 y100 w160 h30
Gui, Add, Edit, vSC x232 y170 w160 h30
Gui, Add, Text, x92 y100 w110 h30 , Purchase Request
Gui, Add, Text, x92 y170 w110 h30 , Shopping Cart
Gui, Add, CheckBox, Checked x262 y230 w130 h40 vnotification gCheck, PO notification
Gui, Add, Button, default gOk x182 y280 w90 h30 , OK

Gui, Tab, 2
Gui, Add, Text, x142 y150 w90 h30 , Shopping Cart
Gui, Add, Edit, vSC2 x252 y150 w120 h30 
Gui, Add, CheckBox, x302 y240 w100 h30 vUrgent gCheck, Urgent
Gui, Add, Button, default gOk2 x182 y280 w90 h30 , OK

Gui, Tab, 3
Gui, Add, Text, x92 y100 w100 h30 , Purchase Request
Gui, Add, Text, x92 y170 w100 h30 , Purchase Order
Gui, Add, Edit, vPR2 x232 y100 w150 h30
Gui, Add, Edit, vPO x232 y170 w150 h30
Gui, Add, CheckBox, Checked x272 y240 w100 h30 vGRN gCheck, GRN notification
Gui, Add, Button, default gOk3 x182 y280 w90 h30 , OK

Gui, Show, x226 y116 h383 w483, SU Quickpaste
Gui, Submit, NoHide
Return

check:
    Gui, Submit, NoHide
	msgbox 1: %notification%`n2: %urgent%`n3: %GRN%
return



ok:
Gui, submit, 
	clipboard = text (%PR%) text %SC%    

if (notification = 1)
{
	clipboard = 
	clipboard = some other text (%PR%) some other text %SC%.some other text.
}
GuiControl,,PR,
GuiControl,,SC,
Gui Minimize
return



ok2:
Gui, submit, 
	clipboard = text %SC2% text.

if (Urgent = 1)
{
	clipboard = 
	clipboard = some other text %SC2% some other text.			
}
GuiControl,,SC2,
Gui Minimize
return


ok3:
Gui, submit,
	clipboard = text (%PR2%) text %PO%. 

if (GRN = 1)
{
	clipboard = 
	clipboard = some other text (%PR2%) some other text.		
}
GuiControl,,PR2,
GuiControl,,PO,
Gui Minimize
return

GuiClose:
GuiEscape:
ExitApp

Re: checkbox issue

Posted: 01 Apr 2017, 13:45
by duzymichal
Thank you tomoe_uehara. Works perfectly now :D .