Set Date to Checkbox and uncheck it again Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Totoro
Posts: 3
Joined: 26 May 2018, 03:56

Set Date to Checkbox and uncheck it again

26 May 2018, 04:25

Hi everybody! This is my first post, I am a real newbie...

I was able to build a GUI that works fine but I want to improve its usability. In this GUI I have more than 100 "DateTime-Checkboxes" which look like this for example:

Gui Add, DateTime, vU01_CheckIn x155 y50 w100 ChooseNone, dd.MM.yyyy

The Users have to modify a lot of dates in the boxes and my problem is that the selected date in the calendar always stays with the actual date. So if they work on a project with dates in the future they have to click through the calender a pretty long time to select the correct date.

It would be a great help if I could tell those Checkboxes to start with a different day than today. As this differs from project to project I thought of a variable I call #startdate# and I tried to change all checkboxes to this startdate and then uncheck them again (otherwise they would have to uncheck all unnecessary checkboxes manually). This seemed like a simple task that I put into a subroutine like this:

if (U01_CheckIn = "") ; if checkbox is unchecked
{
GuiControl, , U01_CheckIn, %startdate% ; change the date to startdate (this works)
GuiControl, , U01_CheckIn, 0 ; uncheck the checkbox (this does not work)
}

Why is the checkbox still checked? What am I doing wrong?

Thanks in advance for any help!
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Set Date to Checkbox and uncheck it again

26 May 2018, 05:17

That checkbox does not behave like a regular checkbox, for example, I do not think you can load your GUI and have that checkbox pre checked like you would a regular checkbox using the checked option.

In fact, this line of code:

if (U01_CheckIn = "") ; if checkbox is unchecked

Its not checking if the checkbox is checked or not, it checks the data itself and when unchecked it returns a 0 but not because it looked at the checkbox itself.

If you want to test what it sees just run

msgbox, % U01_CheckIn

You will see when checked it gives you the date

Please read the calendar info https://autohotkey.com/docs/commands/GuiControls.htm

From what I understand, even if you use ChooseYYYYMMDD and choose 2 for checkbox, later in the program this cannot be changed

"2: Specify the number 2 in Options to provide a checkbox inside the control that the user may uncheck to indicate that no date/time is selected. Once the control is created, this option cannot be changed."

Why do you need the checkboxes? What do they do for your program?

Hopefully someone can provide you a workaround
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Set Date to Checkbox and uncheck it again  Topic is solved

26 May 2018, 05:35

GuiControl wrote: Sub-commands

(Blank):

DateTime/MonthCal: Specify for Param3 a date-time stamp in YYYYMMDDHH24MISS format. Specify %A_Now% to use the current date and time (today). For DateTime controls, Param3 may be omitted to cause the control to have no date/time selected (if it was created with that ability).
It will also uncheck the checkbox.
Totoro
Posts: 3
Joined: 26 May 2018, 03:56

Re: Set Date to Checkbox and uncheck it again

26 May 2018, 06:10

Thank you both for your quick answers!!!

@just me:
It took me a couple of minutes to realize that you posted the solution to my problem. Instead of the 0 I just have to leave the Param3 blank and it works exactly like I want it to work :-)

if (U01_CheckIn = "")
{
GuiControl, , U01_CheckIn, %startdate%
GuiControl, , U01_CheckIn,
}

Thank you so much! Das war mir eine riesengroße Hilfe!!!
Totoro
Posts: 3
Joined: 26 May 2018, 03:56

Re: Set Date to Checkbox and uncheck it again

26 May 2018, 06:17

Thank you both for your answers and time to help me!!!

@justme: Thats the simple solution :-)

This way it works exactly as I want it:

if (U01_CheckIn = "")
{
GuiControl, , U01_CheckIn, %startdate%
GuiControl, , U01_CheckIn,
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LepG, mcd, NullRefEx and 124 guests