How to extract top results from multiple counters? [Solved]

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TheLastAnon
Posts: 2
Joined: 21 Apr 2014, 03:45

How to extract top results from multiple counters? [Solved]

21 Apr 2014, 04:25

Hello, I would greatly appreciate some help with my AutoHotkey issue, I'm dead stuck and my knowledge level is low but I have a sample script for review.

What I need to do is transfer calls and keep track of how many times I've transferred calls to specific department. I created a gui with buttons for each extension. The ideal functionality would allow me to click on a button for the corresponding extension and count the transfers. When asked for the data I could press the "Totals" button and a message box would display the top three most used extensions and reset the totals after the messagebox is closed. In the event two of the top three have been used the same amount it doesn't matter which one is reported.

I'm not sure I am solving this problem in a good way but I have some issues.

1. I cannot figure out how to get my counters to start at zero, they always start at one.
2. I just don't have any idea whatsoever how I can find the top three most used extensions =/

Help is appreciated.

Code: Select all

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

;http://ahkscript.org/boards/viewtopic.php?f=5&t=3317

Var_Count_111 := 0

Gui, Add, Button, gcount111 x12 y9 w100 h30, 111
Gui, Add, Button, gcount112 x12 y59 w100 h30, 112
Gui, Add, Button, gcount119 x12 y109 w100 h30, 119
Gui, Add, Button, gcount205 x12 y159 w100 h30, 205
Gui, Add, Button, gcount239 x12 y209 w100 h30, 239
Gui, Add, Button, gcount251 x12 y259 w100 h30, 251
Gui, Add, Button, gcount255 x12 y309 w100 h30, 255
Gui, Add, Button, gcount257 x12 y359 w100 h30, 257
Gui, Add, Button, gcount259 x12 y409 w100 h30, 259
Gui, Add, Button, gcount260 x12 y459 w100 h30, 260
Gui, Add, Button, gcount300 x142 y9 w100 h30, 300
Gui, Add, Button, gcount302 x142 y59 w100 h30, 302
Gui, Add, Button, gcount311 x142 y109 w100 h30, 311
Gui, Add, Button, gcount312 x142 y159 w100 h30, 312
Gui, Add, Button, gcount317 x142 y209 w100 h30, 317
Gui, Add, Button, gcount350 x142 y259 w100 h30, 350
Gui, Add, Button, gcount359 x142 y309 w100 h30, 359
Gui, Add, Button, gcount360 x142 y359 w100 h30, 360
Gui, Add, Button, gcount362 x142 y409 w100 h30, 362
Gui, Add, Button, gcount409 x142 y459 w100 h30, 409
Gui, Add, Button, gcount414 x272 y9 w100 h30, 414
Gui, Add, Button, gcount422 x272 y59 w100 h30, 422
Gui, Add, Button, gcount423 x272 y109 w100 h30, 423
Gui, Add, Button, gcount500 x272 y159 w100 h30, 500
Gui, Add, Button, gcount501 x272 y209 w100 h30, 501
Gui, Add, Button, gcount515 x272 y259 w100 h30, 515
Gui, Add, Button, gcount518 x272 y309 w100 h30, 518
Gui, Add, Button, gcount545 x272 y359 w100 h30, 545
Gui, Add, Button, gcount550 x272 y409 w100 h30, 550
Gui, Add, Button, gcount573 x272 y459 w100 h30, 573
Gui, Add, Button, gcount583 x402 y9 w100 h30, 583
Gui, Add, Button, gcount586 x402 y59 w100 h30, 586
Gui, Add, Button, gcount724 x402 y109 w100 h30, 724
Gui, Add, Button, gcount782 x402 y159 w100 h30, 782
Gui, Add, Button, gcount783 x402 y209 w100 h30, 783
Gui, Add, Button, gcount787 x402 y259 w100 h30, 787
Gui, Add, Button, gcount815 x402 y309 w100 h30, 815
Gui, Add, Button, gcount822 x402 y359 w100 h30, 822
Gui, Add, Button, gcount829 x402 y409 w100 h30, 829
Gui, Add, Button, gcount874 x402 y459 w100 h30, 874
Gui, Add, Button, gcount882 x532 y9 w100 h30, 882
Gui, Add, Button, gcount883 x532 y59 w100 h30, 883
Gui, Add, Button, gcount895 x532 y109 w100 h30, 895
Gui, Add, Button, gTotals x532 y159 w100 h30, Totals

Gui, Show, x127 y87 h514 w646, Transfer Totals

count111:
Var_Count_111++
return

count112:
Var_Count_112++
return


count119:
Var_Count_119++
return


count205:
Var_Count_205++
return


count239:
Var_Count_239++
return


count251:
Var_Count_251++
return


count255:
Var_Count_255++
return


count257:
Var_Count_257++
return


count259:
Var_Count_259++
return


count260:
Var_Count_260++
return


count300:
Var_Count_300++
return


count302:
Var_Count_302++
return


count311:
Var_Count_311++
return


count312:
Var_Count_312++
return


count317:
Var_Count_317++
return


count350:
Var_Count_350++
return


count359:
Var_Count_359++
return


count360:
Var_Count_360++
return


count362:
Var_Count_362++
return


count409:
Var_Count_409++
return


count414:
Var_Count_414++
return


count422:
Var_Count_422++
return


count423:
Var_Count_423++
return


count500:
Var_Count_500++
return


count501:
Var_Count_501++
return


count515:
Var_Count_515++
return


count518:
Var_Count_518++
return


count545:
Var_Count_545++
return


count550:
Var_Count_550++
return


count573:
Var_Count_573++
return


count583:
Var_Count_583++
return


count586:
Var_Count_586++
return


count724:
Var_Count_724++
return


count782:
Var_Count_782++
return


count783:
Var_Count_783++
return


count787:
Var_Count_787++
return


count815:
Var_Count_815++
return


count822:
Var_Count_822++
return


count829:
Var_Count_829++
return


count874:
Var_Count_874++
return


count882:
Var_Count_882++
return


count883:
Var_Count_883++
return


count895:
Var_Count_895++
return


Totals:
msgbox %Var_Count_111% transfers to extension 111
reload
Last edited by TheLastAnon on 21 Apr 2014, 13:40, edited 1 time in total.
Guest

Re: How do I extract the top 3 results from multiple counter

21 Apr 2014, 04:57

Try this - I've shortened the code, you can now add an extension quite fast and also the top three is copied to the clipboard after it shows the msgbox.

#NoEnv
#SingleInstance, force
SendMode Input
SetWorkingDir %A_ScriptDir%
;http://ahkscript.org/boards/viewtopic.php?f=5&t=3317

Ext:="111,112,119,205,239,251,255,257,259,260,300,302,311,312,317,350,359,360,362,409,414,422,423,500,501,515,518,545,550,573,83,586,724,782,783,787,815,822,829,874,882,883,895"
x:=10
y:=10

Loop, parse, ext, CSV
{
Gui, Add, Button, gCount x%x% y%y% w100 h30, %A_LoopField%
y+=50
If (Mod(A_Index,10) = 0)
y:=10, x+=120
}
Gui, Add, Button, gTotals x%x% yp+50 w100 h30, Totals
Gui, Show, ,Transfer Totals
Return ; <- this Return was missing

Count:
Var_Count_%A_GuiControl%++
return

Totals:
allCalls:=""
Loop, parse, ext, CSV
allCalls .= Var_Count_%A_LoopField% " transfers to extension " A_LoopField "|"
Sort, allCalls, N RD|
TopThree:=SubStr(allCalls,1,InStr(allCalls, "|" , false, 1, 3)) ; change 3 to 5 to get the top 5
StringReplace, TopThree, TopThree, |, `n, All
Clipboard:=TopThree
MsgBox % TopThree
Reload
TheLastAnon
Posts: 2
Joined: 21 Apr 2014, 03:45

Re: How do I extract the top 3 results from multiple counter

21 Apr 2014, 13:38

Wow thank you so much! That is tons better. There is no way I would have been able to figure this out >< I wasn't even close -.- Your solution far exceeds my expectations.
Ahh I forgot the return...well, at least I know why the counter wasn't working :D

Everything works perfectly! Thanks again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: joefiesta, mikeyww and 279 guests