counter for hotstrings Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Acromotive

counter for hotstrings

04 Apr 2018, 07:40

I am curious if anyone has developed a counter for time saved using hotstrings?

I have a ahk file that I run to save time typing repetitive phrases. Each time I use a hotstring such as "lol" for laugh out loud and it expands I would like the program to add 1.5 seconds to a counter showing how much time I saved using the hotstring.

Any ideas?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: counter for hotstrings

04 Apr 2018, 08:18

I'd guess you're from the States being that much into statistics :shock: :silent:
GeneBene

Re: counter for hotstrings  Topic is solved

04 Apr 2018, 08:46

BoBo wrote:I'd guess you're from the States being that much into statistics :shock: :silent:
reviewing the statistics will eat up all the time he saved
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

04 Apr 2018, 08:58

I have installed this on several computers at my work and would like to know average amounts of time saved/usage of the program per person.

I love the hard time you guys are giving me but would appreciate some real feedback or ideas to go about this using autohotkey.

Thank you
GeneBene

Re: counter for hotstrings

04 Apr 2018, 09:13

arochon wrote:I have installed this on several computers at my work and would like to know average amounts of time saved/usage of the program per person.

I love the hard time you guys are giving me but would appreciate some real feedback or ideas to go about this using autohotkey.

Thank you
try this, you can also send the data to a file this is just so you can demo, remember, when the script restarts the old data is lost unless you saved to file

Code: Select all

::lol::
SendInput, laugh out loud
timesaved += 1.5
msgbox, %timesaved%
return
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

04 Apr 2018, 10:55

GeneBene - thank you for the help this is perfect!

::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return



F8::msgbox, %timesaved%
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

04 Apr 2018, 10:58

Now the next step is to apply an amount to all hotstrings then figure out a way to convert %timesaved% to display to a gui in format of hours, minutes, and seconds
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: counter for hotstrings

04 Apr 2018, 11:00

Here's a way:

Code: Select all

:*:abcj-::
:*:abcm-::
:*:abcz-::
vHotkey := RegExReplace(A_ThisHotkey, "^:.*?:") ;remove first two colons and the text in-between
vHotkey := SubStr(vHotkey, 1, -1)
if !IsObject(oArray)
	oArray := Object("abcj", "abcdefghij"
	, "abcm", "abcdefghijklm"
	, "abcz", "abcdefghijklmnopqrstuvwxyz"
	, "", "")
vText := oArray[vHotkey]
vLen := StrLen(vText) - StrLen(vHotkey) - 1
;SendInput, % "{Raw}" vText
SendInput, % "{Text}" vText
MsgBox, % "you saved " vLen " key presses"
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
GeneBene

Re: counter for hotstrings

04 Apr 2018, 11:11

arochon wrote:Now the next step is to apply an amount to all hotstrings then figure out a way to convert %timesaved% to display to a gui in format of hours, minutes, and seconds
this page has info on turning seconds into what you want https://www.autohotkey.com/docs/commands/FormatTime.htm see last example there
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: counter for hotstrings

04 Apr 2018, 11:23

The Format function can also be useful for displaying times, see: FORMAT FUNCTION EXAMPLES here:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

04 Apr 2018, 12:07

I added this as suggested but I am having issues with %timesaved% not being a whole number of seconds. For instance %timesaved%= 3.500000 which is not a valid input for (number of seconds)

Code: Select all

::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return



; The following function converts the specified number of seconds into the corresponding
; number of hours, minutes, and seconds (hh:mm:ss format).

f8::MsgBox % FormatSeconds(%timesaved%)  ; 7384 = 2 hours + 3 minutes + 4 seconds. It yields: 2:03:04

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss
    /*
    ; Unlike the method used above, this would not support more than 24 hours worth of seconds:
    FormatTime, hmmss, %time%, h:mm:ss
    return hmmss
    */
}
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

05 Apr 2018, 11:38

::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return

timesaved := Round(timesaved)

F8::MsgBox,% FormatSeconds(timesaved)
Last edited by arochon on 16 Apr 2018, 07:35, edited 1 time in total.
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

16 Apr 2018, 07:33

Found 1 issue with this method....

when using

Code: Select all

::rofl::
sendinput, roll on floor laughing
First letter capitalization is not recognized. Typing rofl is the same as If you type Rofl = "roll on floor laughing" or ROfl = "roll on floor laughing". You have to Type ROFL to get = "ROLL ON FLOOR LAUGHING"

Code: Select all

::rofl::roll on floor laughing
If using this format, which I would like to be able to do, you can command the first letter to be capital or not by typing "Rofl" vs "rofl"

Any ideas? Thanks in advance for any help. I would like to accomplish the counter idea without disrupting the capitilization features of the hotstring.
User avatar
BriHecato
Posts: 124
Joined: 18 Jul 2017, 07:17

Re: counter for hotstrings

16 Apr 2018, 08:08

Is this what you looking for (options for hotstrings)?

Code: Select all

:C:rofl::roll on floor laughing
:C:Rofl::Roll On Floor Laughing
:C:ROFL::ROLL ON FLOOR LAUGHING
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: counter for hotstrings

16 Apr 2018, 09:45

Thank you BriHecato.

I tried adding the "C" option earlier... but did not make 3 different entries. The following code worked and accomplished both tasks.

To clarify:

Code: Select all

:C:aat::
sendinput, ambient air temperature{space}
counter += 1
return

:C:Aat::
sendinput, Ambient air temperature{space}
counter += 1
return

:C:AAT::
sendinput, AMBIENT AIR TEMPERATURE{space}
counter += 1
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 283 guests