Help with a Visual Counter

Get help with using AutoHotkey and its commands and hotkeys
jjestr
Posts: 2
Joined: 16 Jan 2020, 10:20

Help with a Visual Counter

16 Jan 2020, 10:29

Hey guys,

I am trying to get a ticket counter to work on a program. Basically, I need a visual number counter to display each time a 'Reset' button is pressed. I've tried numerous things and I'm not getting anywhere. Here's the closest I've gotten:

Code: Select all

;+---------------------------------------+
IfExist, %A_Temp%\TicketCount%A_YDay%.txt                        ;  A_YDay - built in variable for day of the year - Feb 1 = 32
            FileRead, TicketCount, %A_Temp%\TicketCount%A_YDay%.txt
else
            {
                        TicketCount := 0
            }
;+---------------------------------------+
	Gui, Add, Button, x325 y7 h20   vReset, Reset ;--> Reset button

	Gui, Add, Button, x7 y7 h20 gClipToEdit, P ;--> Ticket button
	Gui, Add, Edit, x30 y7 h21 w91  hwndTick vTick limit11, ;--> Ticket input
;Gui,2: Add, Edit, x335 y63 w210 hwndTick vXp0rt5, %Xp0rt5%
	SetEditCueBanner(Tick, "Ticket")
if (TicketCount)
           Gui, Add, Edit, x7 y230 ReadOnly vTicketCountDisplay, %TicketCount%
else
           Gui, Add, Edit, x7 y230 ReadOnly vTicketCountDisplay, None
;+---------------------------------------+
ResetMe:
            ++TicketCount
            FileDelete, %A_Temp%\TicketCount%A_YDay%.txt
            FileAppend, %TicketCount%, %A_Temp%\TicketCount%A_YDay%.txt
            Reload
return
[Mod Edit: [code][/code] tags added]

Lemme know if you guys need more information. I appreciate any/all help with this. Thanks!
User avatar
TLM
Posts: 1545
Joined: 01 Oct 2013, 07:52
GitHub: TLMcode
Contact:

Re: Help with a Visual Counter

16 Jan 2020, 12:28

Assuming you're trying to point the Reset button to the ResetMe label:

Code: Select all

;+---------------------------------------+
IfExist, %A_Temp%\TicketCount%A_YDay%.txt                        ;  A_YDay - built in variable for day of the year - Feb 1 = 32
            FileRead, TicketCount, %A_Temp%\TicketCount%A_YDay%.txt
else
            {
                        TicketCount := 0
            }
;+---------------------------------------+
	Gui, Add, Button, x325 y7 h20   gResetMe vReset, Reset ;--> Reset button

	; Gui, Add, Button, x7 y7 h20 gClipToEdit, P ;--> Ticket button
	Gui, Add, Edit, x30 y7 h21 w91  hwndTick vTick limit11, ;--> Ticket input
Gui,2: Add, Edit, x335 y63 w210 hwndTick vXp0rt5, %Xp0rt5%
	SetEditCueBanner(Tick, "Ticket")
           Gui, Add, Edit, x7 y230 ReadOnly vTicketCountDisplay, % TicketCount ? TicketCount : "None"

;+---------------------------------------+
ResetMe:
            ++TicketCount
            GuiControl,, TicketCountDisplay, %TicketCount%
            FileDelete, %A_Temp%\TicketCount%A_YDay%.txt
            FileAppend, %TicketCount%, % File
return
jjestr
Posts: 2
Joined: 16 Jan 2020, 10:20

Re: Help with a Visual Counter

16 Jan 2020, 15:07

Hey, I appreciate the response. Unfortunately, that removes some of the other ticket info in the gui and places a blank box. I'll attach the entire code of the gui without the ticket counter coding. The ultimate goal is to have a ticket counter box next to the PPV button that counts up each time the 'Reset' button is clicked.

Code: Select all

;----------------NOTES
;----------------**Buttons**
;--------Reset: Self-Explanatory
;--------Ownership: Ownership note for CSG
;--------Note: Creates your resolution text
;----------------**Hotkeys**
;--------CTRL+`: Similar to CTRL+Space from BA Tools, it will copy and automatically paste highlighted text into the "Notepad" tab
;--------CTRL+SHIFT+V: This is the same as the above function, but it will strip all characters and paste only numerical characters to the "TNs" tab

#SingleInstance, force ;--> always add
#NoEnv ; --> always add

;+---------------------------------------+
;---> Global Var
var=
var += 10,min
FormatTime, var, %var%, MM/dd/yy HH:mm
VarField1 := test
;+---------------------------------------+
; [^ = Ctrl] [+ = Shift] [! = Alt] [# = Win]
;GRAPHICAL UI LAYOUT
;+---------------------------------------+
CustomColor = c0b797 ;--> Set Color https www.w3schools.com /colors/colors_picker.asp  Broken Link for safety
Gui, +AlwaysOnTop
Gui, Color, %CustomColor% ;-->Custom Color Global Set
Gui, Show, w400 h500 , Tier 2 Note ;--> Gui Parm, APP Width Height, Title

Gui, -AlwaysOnTop ;--> +AlwaysOnTop will change to set gui always to permanent front focus
Gui, Add, CheckBox, x380 y10 gA0nt0p vAt0p,


;GET --> WIN Position
;WinSet, Transparent, 227, ahk_class AutoHotkeyGUI ;--> Transparency 0-250
WinSet, TransColor, %CustomColor% 150 ;-->Transparency continue winSet
WinGetPos X, Y, Width, Height, A ;--> Declare PoS
MaxX := A_ScreenWidth - Width - -404 ;-->This will put the Gui to the right 20= width padding
MaxY := A_ScreenHeight - Height - -2 ;-->Put Gui Above Taskbar, 50= height padding
WinMove A, ,%MaxX%, %MaxY%
;END --> WIN Position

Gui, font, s8, Verdana
;Gui, -Border ;-->Remove Gui Border
;Gui, +Resize
;Gui, -MaximizeBox
;Gui, font, Bold
;Gui, Add, Text, x400 y6, T2 Tools ;--> Text top of window

;Gui, font 
;Gui, font, s8, Verdana

	Gui, Add, Button, x325 y7 h20   vReset, Reset ;--> Reset button

	Gui, Add, Button, x7 y7 h20 gClipToEdit, P ;--> Ticket button
	Gui, Add, Edit, x30 y7 h21 w91  hwndTick vTick limit11, ;--> Ticket input
;Gui,2: Add, Edit, x335 y63 w210 hwndTick vXp0rt5, %Xp0rt5%
	SetEditCueBanner(Tick, "Ticket")



	Gui, Add, Button, x125 y7 h20 gBTN_Yes , Add'l Ticket ;--> Add'l Ticket YES
	Gui, Add, Edit, x208 y7 h21 w108  vYtick, No Add'l


	Gui, Add, Button, x7 y32 h20  gIssue1, P  ;--> Issue button
	Gui, Add, Edit, x30 y32  h21 w285 hwndIssue1 vIssue1, ;--> Issue input
	SetEditCueBanner(Issue1, "Issue")

	Gui, Add, Button, x323 y32 h20  gBTN_Istamp, Ownership ;--> Initial Stamp button

	Gui, Add, Button, x7 y57 h20  gKlipper, P ;--> Contact button
	Gui, Add, Edit, x30 y57 h21 w320  hwndName vName limit25, ;--> Name input
	SetEditCueBanner(Name, "Name")

	Gui, Add, Button, x355 y57 h20  w40  gBTN_Fstamp, Note ;--> Final Stamp button


	Gui, Add, Button, x7 y82  h20 gCtoE, P  ;--> Contact Method button
	Gui, Add, Edit, x30 y82 h21 w365 hwndMethod vMethod limit25, ;--> Contact Method input
	SetEditCueBanner(Method, "Phone/Email")


	Gui, Add, Button, x7 y107 h20 gBTN_one , P ;--> Attempt button One
	Gui, Add, Edit, x30 y107 h21 w365  hwndAtt1 vAtt1
	SetEditCueBanner(Att1, "1st Attempt")

	Gui, Add, Button, x7 y132 h20 gBTN_two, P ;--> Attempt button Two
	Gui, Add, Edit, x30 y132 h21 w365 hwndAtt2 vAtt2
	SetEditCueBanner(Att2, "2nd Attempt")

	Gui, Add, Button, x7 y157 h20  gBTN_three, P  ;--> Attempt button Three
	Gui, Add, Edit, x30 y157 h21 w365 hwndAtt3 vAtt3
	SetEditCueBanner(Att3, "3rd Attempt")

	
	Gui, Add, Edit, x30 y182 h21 w365 hwndAcct vAcct
	SetEditCueBanner(Acct, "Account")

	Gui, Add, Tab2, x7 y205 w390 h500 buttons, Resolution|Notepad|TNs|PPV



Gui, Tab, 3 ;---------------------- TN TAB

	Gui, Add, Edit, x7 y230 w385 h265 vTNEdit, ;--> Account input




Gui, Tab, 2 ;--------------NOTEPAD TAB

	Gui, Add, Edit, x7 y230  w385 h265 vTempNote, ;--> Notepad



Gui, Tab, 1  ;-------------RESOLUTION TAB

	Gui, Add, Edit, x7 y230  w385 h265 vKnote, ;--> Preview of note build

Gui, Tab, 4 ;-------------PPV TAB

	Gui, Add, Button, x7 y230   vPPV, PPV ;--> PPV button




;+---------------------------------------+
;FUNCTIONS AND clickTO actions
;+---------------------------------------+



Kopy: ;Copy button Func
    Gui, Submit, NoHide
    clipboard = % Knote
    ToolTip Ok, 350, 105
Sleep 1000
ToolTip ; Turn off the tip.
return
;---------------------------------------------




FKopy: ;Copy button Func
    Gui, Submit, NoHide
    clipboard = % FinalNote
    ToolTip Ok, 350, 105
Sleep 1000
ToolTip ; Turn off the tip.

clipwait
	if (strlen(clipboard) > 300)
	{
		Msgbox,64, ALERT!!, Too Many Characters for CSG
		;0ne := +rd, 1, 300)  ;Sets amount of characters copied to clipboard
		;clipboard := 0ne
	}
return
;------------------------------------------------
              

;Copy to Floating Clipboard
^Space:: ;Ctrl+Space
Copy:
  GuiControlGet, Tick        ;Get CR Ticket contents into Tick
  Gui, Hide                      ;Focus will now be on window underneath
  Sleep 300
  SendInput ^c                      ;Copy highlighted text to Windows clipboard
  ClipWait                          ;Wait for Win clipboard to contain data
 Gui, Show, NA                  ;Redisplay floating clipboard but don't activate it
  GuiVisible := "1"
  If (StrLen(Tick) = 0)      ;If Tick is empty
    Tick .= Clipboard ;Append contents of Win clipboard
  Else
    Tick .= "" . Clipboard := "" ;Append CR/LF + Win clipboard
  GuiControl,, Tick, %Tick%  ;Update Edit view

Return

;---------------------Copy and strip TN 




 ;Copy Stipped TNs
^+V:: ;Ctrl+Shift+V
CopyTN:
  GuiControlGet, TNEdit        ;Get Edit contents into TempN
  Gui, Hide                      ;Focus will now be on window underneath
  Sleep 300   
  SendInput ^c                      ;Copy highlighted text to Windows clipboard
  ClipWait                          ;Wait for Win clipboard to contain data
  TempN:= Clipboard       ;Get Edit contents into TNEdit
  Clipboard:= RegExReplace(TempN, "x)[^0-9]")
  ClipWait
Gui, Show, NA                  ;Redisplay floating clipboard but don't activate it
  GuiVisible := "1"
  If (StrLen(TNEdit) = 0)      ;If floating clipboard is empty
    TNEdit .= Clipboard ;Append contents of Win clipboard
  Else
    TNEdit .= "`r`n" . Clipboard ;Append CR/LF + Win clipboard
  GuiControl,, TNEdit, %Clipboard%  ;Update Edit view
  GuiControl, Choose, Systabcontrol322, 2 ;Update Tab view
Return
  


;-----------------PPV WINDOW-------------

ButtonPPV: ;PPV button Func
Gui,2: 





Gui,2: Color, %CustomColor%

Gui,2: -Border 
;Gui,2: Show, %gui_position% show w500 h250
Gui,2: Show, %gui_position% w550 h250, PPV Tools

;Gui, Add, Button, x440 y5 h20   gResetPPV, Reset ;--> Reset button

Gui,2: Add, Button, x489 y5  h20  gMinPPV, Min ;--> Minimize button

Gui,2: Add, Button, x525 y5  h20  gExtB, X ;--> Close button

 

Gui,2:Font,  bold
Gui,2: Add, Text, x350 y10,Hotline: (888)509-8646 ;--> Text for...
Gui,2:Font,
Gui, font, s8, Verdana

;Gui,2:Add,Groupbox,x7 y28 w160 h30, ;--> tech field divider
;Gui,2:Add,Groupbox,x6 y61 w160 h140, ;--> Event field divider
;Gui,2:Add,Groupbox,x7 y62 w155 h31, ;--> box border Promoter
;Gui,2:Add,Groupbox,x7 y97 w155 h31, ;--> box border Event
;Gui,2:Add,Groupbox,x7 y132 w155 h31, ;--> box border DESCRIPTION
;Gui,2:Add,Groupbox,x7 y167 w155 h31, ;--> box border DateTime
;Gui,2: Add, Edit, x10 y35 w155 hwndh0ldtek vTek border, ;--> Tech Name
;Gui,2: Add, Edit, x10 y35 w155 vTek border, ;--> Tech Name
;SetEditCueBanner(h0ldtek, "T2-Agent")


Gui,2: Add, button, x5 y5 gYankk1, INS ;--> Yank-Paste Info
Gui,2: Add, ComboBox, x37 y5 vpr0m0ter, [Promoter]||Joe Hand|GG Events|JJ Sports
Gui,2: Add, button, x160 y5 gYankk2, INS ;--> Yank-Paste Info
Gui,2: Add, ComboBox, x192 y5  vSp0rt,[Event]||UFC|BOXING|WWE|
Gui,2: Add, button, x160 y35 gYankk3, Get ;--> Yank-Paste Info
Gui,2: Add, Edit, x190 y35 w120 hwndh0ldmatch vt1tle border,
SetEditCueBanner(h0ldmatch, "DESCRIPTION")

Gui,2: Add, button, x5 y35, Get ;--> Yank-Paste Info

Gui,2: Add, DateTime, x37 y35 w120 vt1me,ddd MMM dd yyyy


Gui,2: Add, ListView, x5 y128 w540 h115 Grid HwndPPV_AddList border, Account         |Business          |Address     |Name-Tn|Fee|Agent|TV|Boxes|Contact ;-->Listview
;Gui,2:Add,Groupbox,x172 y27 w323 h120, ;->listview box
Gui,2: Add, Button, x5 y110 w40 h15 gadd0, Insert
Gui,2: Add, Button, x48 y110 w40 h15 grem0ve, Delete
Gui,2: Add, Button, x91 y110 w40 h15 grem0veA11, Clear
;Gui,2:Add,Groupbox, x5 y175 w45 h26, ;--> box export
Gui,2: Add, Button, x134 y110 w40 h15 gxp0rt, Export


Gui,2: Add, Edit, x60 y85 w200  hwndXce12 vXp0rt2 limit25, %Xp0rt2%
SetEditCueBanner(Xce12, "Contact Info")
;Gui,2: Add, Edit, x269 y197 w75 hwndXce11 vXp0rt1 number limit10, %Xp0rt1%
;SetEditCueBanner(Xce11, "TN")
Gui,2: Add, Edit, x5 y63 w125 hwndXce13 vXp0rt3 number limit16, %Xp0rt3%
SetEditCueBanner(Xce13, "Account Number")
Gui,2: Add, Edit, x133 y63 w200 hwndXce14 vXp0rt4, %Xp0rt4%
SetEditCueBanner(Xce14, "Business")
Gui,2: Add, Edit, x335 y63 w210 hwndXce15 vXp0rt5, %Xp0rt5%
SetEditCueBanner(Xce15, "Address")

Gui,2: Add, Combobox, x305 y85 w50 vXp0rt6,[Chnl]||454|504|847|870|902
Gui,2: Add, Edit, x263 y85 w40 hwndXce17 vXp0rt7 number limit2, %Xp0rt7%
SetEditCueBanner(Xce17, "#DTA")
Gui,2: Add, Combobox, x358 y85 w125 vXp0rt8,[Response]||Spoke To Customer|Left VM|Unable To Reach
;Gui,2:Add,Groupbox, x172 y165 w400 h80, ;--> box border PPV Excel Fields

;Gui,2:Add,Groupbox, x245 y139 w150 h26, ;--> box border listbox actions

;Gui,2:Add,Groupbox,x69 y213 w62 h26, ;->CSG Note Stamp
;Gui,2:Add,Text, x10 y85, Sppvtran ;->Code Fee
;Gui,2:Font,  bold
Gui,2: Add, CheckBox, x5 y90 ga0r vAorR,Y
Gui,2: Add, CheckBox, x30 y90 ga0r1 vAorR1,N
;Gui,2: Add, Button, x90 y221 w40 h18 gl0g, CSG
Gui,2:Font,


;Gui,2:Add,Groupbox,x3 y25 w495 h220 border, ;global border
;Gui,2: font,bold ;--> Font Type BOLD for Copy and Reset buttons only
Gui,2: Add, Button, x490 y30 w55 h22 gK1ear vK1earr, RESET ;--> Reset button
;Gui,2: Add, Button, x450 y250 w50 h22 gXit, EXIT ;--> Exit button
Gui,2: font  ;--> Begin new font parm
Gui,2: Add, Button, x370 y30 w55 h22 gResp0nse, Accepted
Gui,2: Add, Button, x430 y30 w55 h22 gResp0nse0, Rejected
;+---------------------END PPV window-----------------------+




ButtonRESET: ;Reset button Func
    
	Gui Submit, NoHide 
	GuiControl,, Knote,
	GuiControl,, TNEdit
	GuiControl,, TempNote
	GuiControl,, MacADD1
	GuiControl,, MNGip
	GuiControl,, GroupID
	GuiControl,, AcctEdit
        GuiControl,, Att1
	GuiControl,, Att2
	GuiControl,, Att3
	GuiControl,, Acct
	GuiControl,, Tick
	GuiControl,, Name
    GuiControl,, Method
	GuiControl,, Issue1
	GuiControl,, Ytick, No Add'l
	ToolTip Ok, 350, 150
Sleep 1000
ToolTip ; Turn off the tip.
return

K1ear: ;-->Reset button Func
    GuiControl,, Xp0rt1
	GuiControl,, Xp0rt2
	GuiControl,, Xp0rt3
	GuiControl,, Xp0rt4
	GuiControl,, Xp0rt5
	GuiControl,, Xp0rt6
	GuiControl,, Xp0rt7
	GuiControl,, Xp0rt8
	ToolTip Cleared, 460, -20 ;--> Turn on the tip.
Sleep 1000
ToolTip ;--> Turn off the tip.
return

ButtonMin:
	WinMinimize
return

ExtB:
	gui, 2:destroy
return

MinPPV:
	WinMinimize
return

ExtA:
	ExitApp 
return

	
IpADD:
GuiControl,, MNGip, %Clipboard%
return

ClipToEdit: ;Ticket edit box paste Func
GuiControl,, Tick, %Clipboard% ;Paste Clip Controller
return

AcctNum: ;Account button edit box paste Func
GuiControl,, AcctEdit, %Clipboard% ;Paste Clip Controller
return

Mac1:
GuiControl,, MacADD1,%Clipboard%
return

GrpID:
GuiControl,, GroupID, %Clipboard%
return

Klipper: ;Name edit box paste Func
GuiControl,, Name, %Clipboard%
return

CtoE: ;Method edit box paste Func
GuiControl,, Method, %Clipboard%
return

Issue1: ;Issue edit box paste Func
GuiControl,, Issue1, %Clipboard%
return

A0nt0p:
    Gui, Submit, NoHide
	
    If At0p = 1
    {
        Gui, +AlwaysOnTop
		ToolTip +Always On Top, 415, -20 ;--> Turn on the tip.
Sleep 1000
ToolTip ;--> Turn off the tip.
    }
    else
    {
        Gui, -AlwaysOnTop
		ToolTip -Always On Top, 415, -20 ;--> Turn on the tip.
Sleep 1000
ToolTip ;--> Turn off the tip.
    }
Return

ch0p1:  ;--> if the editbox[Knote] greater than 300 copy only 1st char to 300th char to clipboard
	if (strlen(clipboard) > 300)
		{

			0ne := substr(Knote, 1, 300)
			clipboard := 0ne
				ToolTip Split 1 Complete, 415, -20 ;--> Turn on the tip.
				Sleep 1000
				ToolTip ; Turn off the tip.
		}
return


ch0p2:  ;--> if the editbox[Knote] greater than 300 copy only 300th char to 600th char to clipboard
	if (strlen(clipboard) > 300)
		{

			tw0 := substr(Knote, 300, 600)
			clipboard := tw0
				ToolTip Split 2 Complete, 415, -20 ;--> Turn on the tip.
				Sleep 1000
				ToolTip ; Turn off the tip.
		}
return

xp0rt:
	clipboard = %PPV_AddList%
;	Excel.CreateByXp0rt("PPV_AddList.xlsx", PPV_AddList)
;	ToolTip Saved In Current Directory, 460, -20 ;--> Turn on the tip.
;		Sleep 1000
		ToolTip ;--> Turn off the tip.
return


;clipboard = PPV_AddList




a0r1:
Gui, Submit, NoHide
    If AorR1 = 1
    {
	
		Time = 20080623143412 ; set this variable to the time string

		FormatTime, Time2, %t1me%, ddd MMM dd yyyy
	
	clipboard = $0.00 TRANSPORT FEE ADDED FOR %t1tle% %Time2%.
		ToolTip Fee (NO) Copied, 415, -20 ;--> Turn on the tip.
Sleep 1000
ToolTip ;--> Turn off the tip.
    }
    else
    {
		clipboard =   ; Empty the clipboard
		ToolTip Clipboard Cleared, 415, -20 ;--> Turn on the tip.
    }
Return

a0r:
Gui, Submit, NoHide
    If AorR = 1
    {
		Time = 20080623143412 ; set this variable to the time string

		FormatTime, Time2, %t1me%, ddd MMM dd yyyy
	clipboard = $125.00 TRANSPORT FEE ADDED FOR %t1tle% %Time2%.
		ToolTip Fee (YES) Copied, 415, -20 ;--> Turn on the tip.
Sleep 1000
ToolTip ;--> Turn off the tip.
    }
    else
    {
		clipboard =   ; Empty the clipboard
		ToolTip Clipboard Cleared, 415, -20 ;--> Turn on the tip.
		Sleep 1000
ToolTip ;--> Turn off the tip.
    }
Return


add0:
	Gui, Submit, NoHide
	NewRow := LV_Add("", Xp0rt3, Xp0rt4, Xp0rt5,Xp0rt2 "-" Xp0rt1, "Y", A_UserName, Xp0rt6, Xp0rt7, Xp0rt8)
return

rem0ve:
	LV_Delete(1)
return

rem0veA11:
	LV_Delete()
return


l0g:
	Gui, Submit, NoHide
	Time = 20080623143412 ; set this variable to the time string

	FormatTime, Time2, %t1me%, ddd MMM dd yyyy
	clipboard = The following establishment has been licensed by %pr0m0ter% as a closed circuit exhibition location for the upcoming %t1tle% - closed circuit event scheduled for %Time2%.`n**%A_Username%-T2-JOLIET**
	
	ToolTip CSG Note Copied, 460, -20 ;--> Turn on the tip.
		Sleep 1000
		ToolTip ;--> Turn off the tip.
return


Resp0nse:
	Gui, Submit, NoHide
	clipboard = Hello,`n`n This event has been activated. The customer has been contacted.`n`n -%Tek%`nTier 2 Advanced Technical Support - Repair`nComcast Communications - SMB - West Division
	
		ToolTip Copied, 460, -20 ;--> Turn on the tip.
		Sleep 1000
		ToolTip ;--> Turn off the tip.
return

Resp0nse0:
	Gui, Submit, NoHide
	clipboard = Hello,`n`n This activation request was not approved. I have contacted our customer regarding this issue. If our customer resolved the issue and the event is approved, you will receive a follow up notification via email.`n`n -%Tek%`nTier 2 Advanced Technical Support - Repair`nComcast Communications - SMB - West Division
		ToolTip Copied, 460, -20 ;--> Turn on the tip.
		Sleep 1000
		ToolTip ;--> Turn off the tip.
return

;+--------------END FUNCTIONS AND ACTIONS----------------+




;------------------Final Note Pop Up----------------------------
BTN_Fstamp: ;-->final stamp func
guiControlGet Con1,,Att1
guiControlGet Con2,,Att2
guiControlGet Con3,,Att3
guiControlGet Tk1,,Tick
guiControlGet FNT,,Knote
guiControlGet FIssue,,Issue1
guiControlGet Atick,,Ytick
Gui, new, +AlwaysOnTop  ;--> Final Note
Gui, Show,w350 h205,
Gui, font, s8, Times New Roman
WinGetPos X, Y, Width, Height, A ;--> Declare PoS
MaxX := A_ScreenWidth - Width - 20 ;-->This will put the Gui to the right 20= width padding
MaxY := A_ScreenHeight - Height - 300 ;-->Put Gui Above Taskbar, 50= height padding
WinMove A, ,%MaxX%, %MaxY%
Gui,Add, Edit, x5 y5 w340 h180 vFinalNote , ;--> Final Note Box
Gui, Add, Button, x5 y185 w55 h20 gFKopy vFCopy, COPY ;--> copy button
var=
var += 10,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
guiControl,,FinalNote, **T2 %A_UserName% %Tk1% **`nADDT'L TKTS: %Atick% `nISSUE:%Fissue% `nSTEPS TAKEN: %FNT%`n%Con1%`n**%A_MMM% %A_DD% %A_YYYY% %A_Hour%:%A_min% MST **
return




;--------------------Ownership----------------------------------------------
BTN_Istamp: ;-->initial stamp func
var=
var += 10,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
;guiControl,,Knote, Working`t**JOL_T2 %A_UserName% %Tick% WORKING** %A_MMM% %A_DD% %A_YYYY% | %A_Hour%:%A_min% MST`nFollow up: %var%
;clipboard = Working`t**JOL_T2 %A_UserName% %Tick%**`nOWNER: Opened Tkt ->%A_MMM% %A_DD% %A_YYYY% | %A_Hour%:%A_min% MST`nFollow up: %var%
;clipboard = **JOL_T2 %A_UserName% %Tick% WORKING** %A_MMM% %A_DD% %A_YYYY% | %A_Hour%:%A_min% MST   Follow up approx 30-45 minutes
clipboard = **T2 %A_UserName% **OWNERSHIP** WORKING TICKET %A_MMM% %A_DD% %A_YYYY% @%A_Hour%:%A_min% MST//Follow up approximately 45 min //%Tick%
return
;-------------------------------------------------------------------


;-----------------------Contact Buttons--------------------------

BTN_Yes:  ;-->button 1 func
var=
var += 120,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
guiControl,,Ytick, %Clipboard%
return					

BTN_one:  ;-->button 1 func
guiControlGet Nm1,, Name
guiControlGet Cnt1,, Method
var=
var += 120,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
guiControl,,Att1, CONTACT: %Nm1% - %Cnt1% %A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_min% MST
return


BTN_two: ;-->button 2 func
guiControlGet Nm1,, Name
guiControlGet Cnt1,, Method
var=
var += 120,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
guiControl,,Att2, ** 2nd contact  %Nm1% %Cnt1% %A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_min% MST**
return

BTN_three: ;-->button 3 func
guiControlGet Nm1,, Name
guiControlGet Cnt1,, Method
var=
var += 120,min
FormatTime, var, %var%, MM/dd/yy HH:mm
Gui, Submit, NoHide
guiControl,,Att3, ** 3rd contact  %Nm1% %Cnt1% %A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_min% MST**
return

Yankk1: ;-->Ticket edit box paste Func
GuiControl,, pr0m0ter, %Clipboard% ;Paste Clip Controller
return

Yankk2: ;-->Name edit box paste Func
GuiControl,, Sp0rt, %Clipboard%
return

Yankk3: ;-->Method edit box paste Func
GuiControl,, t1tle, %Clipboard%
return
;+---------------------------------------+
;===========================================================================


;+---------------------------------------+
WM_LBUTTONDOWN() ;Set mouse parm
{
PostMessage, 0xA1, 2
}
return

;************Pointer to Open IE Window******************
WBGet(WinTitle="ahk_class IEFrame", Svr#=1) {               ;// based on ComObjQuery docs
   static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
        , IID := "{0002DF05-0000-0000-C000-000000000046}"   ;// IID_IWebBrowserApp
;//     , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}"   ;// IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%

   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
}


;+-------------------Banner SET-----------------------+
SetEditCueBanner(HWND, Cue) {  ; requires AHL_L

   Static EM_SETCUEBANNER := (0x1500 + 1)

   Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)

}

;+----------end all and force close program------------------+


;+----------------------Library Stack------------------------+

Class Excel {

	CreateByArray(outputFile, arr, colCount="") {
		this.Array_To_SafeArray(arr, SafeArray, colCount)
		this.SafeArray_To_Excel(SafeArray, outputFile)
	}

	CreateByXp0rt(outputFile, HLV, Obj_LV_Colors := "", IncludeLvHeader := false) {
		ControlGet, lvData, List,,, ahk_id %HLV%
		ControlGet, rowCount, List, Count,, ahk_id %HLV%
		ControlGet, colCount, List, Count Col,, ahk_id %HLV%

		SafeArray := ComObjArray(VT_VARIANT:=12, rowCount, colCount)
		Loop, Parse, lvData, `n, `r
		{
			row := A_Index - 1
			Loop, Parse, A_LoopField, %A_Tab%
				SafeArray[row, A_Index-1] := A_LoopField
		}
		this.HLV := HLV
		this.SafeArray_To_Excel(SafeArray, outputFile, Obj_LV_Colors, IncludeLvHeader)
	}

	Class ApplyColors
	{
		DoIt(SafeArray, oExcel, Obj_LV_Colors) {
			if !IsObject(Obj_LV_Colors)
				return
			
			sheet := oExcel.ActiveSheet
			this.rowCount := SafeArray.MaxIndex(1) + 1
			this.colCount := SafeArray.MaxIndex(2) + 1

			this.Handle_AlternateRows(Obj_LV_Colors, sheet)
			this.Handle_Rows(Obj_LV_Colors, sheet)
			this.Handle_AlternateCols(Obj_LV_Colors, sheet)
			this.Handle_Cells(Obj_LV_Colors, sheet)
		}

		Handle_AlternateRows(Obj_LV_Colors, sheet) {
			if !Obj_LV_Colors.AltRows || (this.rowCount < 2)
				return

			Loop, % this.rowCount {
				if !Mod(A_Index, 2) && !Obj_LV_Colors.Rows.HasKey(A_Index) {
					cell1 := sheet.Cells(A_Index, 1)
					cell2 := sheet.Cells(A_Index, this.colCount)
					if Obj_LV_Colors.HasKey("ARB")
						try sheet.Range(cell1, cell2).Interior.Color := Obj_LV_Colors.ARB
					if Obj_LV_Colors.HasKey("ART")
						try sheet.Range(cell1, cell2).Font.Color := Obj_LV_Colors.ART
				}
			}
		}

		Handle_AlternateCols(Obj_LV_Colors, sheet) {
			if !Obj_LV_Colors.AltCols || (this.colCount < 2)
				return

			Loop, % this.colCount {
				if !Mod(A_Index, 2) {
					cell1 := sheet.Cells(1, A_Index)
					cell2 := sheet.Cells(this.rowCount, A_Index)
					if Obj_LV_Colors.HasKey("ACB")
						try sheet.Range(cell1, cell2).Interior.Color := Obj_LV_Colors.ACB
					if Obj_LV_Colors.HasKey("ACT")
						try sheet.Range(cell1, cell2).Font.Color := Obj_LV_Colors.ACT
				}
			}
		}

		Handle_Rows(Obj_LV_Colors, sheet) {
			For nRow, oColor in Obj_LV_Colors.Rows {
				if Obj_LV_Colors.IsStatic {
					nRow := this.MapIDToIndex(nRow, Obj_LV_Colors.HWND)
				}

				cell1 := sheet.Cells(nRow, 1)
				cell2 := sheet.Cells(nRow, this.colCount)
				if oColor.HasKey("B")
					try sheet.Range(cell1, cell2).Interior.Color := oColor.B
				if oColor.HasKey("T")
					try sheet.Range(cell1, cell2).Font.Color := oColor.T
			}
		}

		Handle_Cells(Obj_LV_Colors, sheet) {
			For nRow, oCols in Obj_LV_Colors.Cells {
				if Obj_LV_Colors.IsStatic {
					nRow := this.MapIDToIndex(nRow, Obj_LV_Colors.HWND)
				}

				For nCol, oColor in oCols {
					if oColor.HasKey("B")
						try sheet.Cells(nRow, nCol).Interior.Color := oColor.B
					if oColor.HasKey("T")
						try sheet.Cells(nRow, nCol).Font.Color := oColor.T
				}
			}
		}

		MapIDToIndex(ID, HWND) {
			SendMessage, 0x10B5, % ID, 0, , % "ahk_id " . HWND ; LVM_MAPIDTOINDEX
			Return ErrorLevel + 1
		}
	}

	Array_To_SafeArray(arr, ByRef SafeArray, colCount="") {
		rowCount := arr.MaxIndex()
		If !colCount
			colCount := IsObject(arr.1) ? arr.1.MaxIndex() : 1
		SafeArray := ComObjArray(VT_VARIANT:=12, rowCount, colCount)

		Loop, % arr.MaxIndex()
		{
			row := A_Index - 1
			If IsObject( subArr := arr[A_Index] )
				Loop, % subArr.MaxIndex()
					SafeArray[row, A_Index-1] := subArr[A_Index]
			Else
				SafeArray[row, 0] := arr[A_Index]
		}
	}

	SafeArray_To_Excel(SafeArray, ExcelFile, Obj_LV_Colors="", IncludeLvHeader=false) {
		If !InStr(ExcelFile, ":") ; Ensure is fullpath
			ExcelFile := A_ScriptDir "\" ExcelFile

		xl := ComObjCreate("Excel.Application")
		xl.DisplayAlerts := False
		xl.Workbooks.Add

		rowCount := SafeArray.MaxIndex(1) + 1
		colCount := SafeArray.MaxIndex(2) + 1

		sheet := xl.activeSheet

		cell1 := sheet.cells(1, 1)
		cell2 := sheet.cells(rowCount, colCount)
		sheet.Range(cell1, cell2).NumberFormatLocal := "@" ; Set format to Text
		sheet.Range(cell1, cell2).value := SafeArray

		col_start := sheet.Columns(1)
		col_end := sheet.Columns(colCount)
		sheet.Range(col_start, col_end).EntireColumn.AutoFit

		if Obj_LV_Colors {
			this.ApplyColors.DoIt(SafeArray, xl, Obj_LV_Colors)
		}
		if IncludeLvHeader {
			sheet.Rows("1:1").Insert(xlDown:=-4121)
			cell1 := sheet.cells(1, 1)
			cell2 := sheet.cells(1, colCount)
			sheet.Range(cell1, cell2).value := this.Build_LvHdr_SafeArr(colCount)
			sheet.Range(cell1, cell2).Font.Bold := true
		}

		if (ExcelFile ~= "i)\.xls$")
			XlFileFormat := 56 ; xlExcel8
		else
			XlFileFormat := 51 ; xlWorkbookDefault
		sheet.SaveAs(ExcelFile, XlFileFormat)
		xl.Quit
	}

	Build_LvHdr_SafeArr(colCount) {
		SafeArray_Hdr := ComObjArray(VT_VARIANT:=12, 1, colCount)
		Loop %colCount% {
			SafeArray_Hdr[0, A_Index-1] := this.LV_GetHeaderText(this.HLV, A_Index)
		}
		return SafeArray_Hdr
	}

	LV_GetHeaderText(hwndLV, ColumnNumber) {
		static LVM_GETHEADER := 0x101F
		     , HDM_GETITEM := A_IsUnicode ? 0x120B : 0x1203 ; HDM_GETITEMW : HDM_GETITEMA
		     , HDI_TEXT := 0x0002

		SendMessage, LVM_GETHEADER, 0, 0,, ahk_id %hwndLV%
		if !(hWndHeader := ErrorLevel)
			return

		VarSetCapacity(hdi, 48, 0)
		VarSetCapacity(HDITEMTEXT, 1024 * (A_IsUnicode ? 2 : 1), 0)
		NumPut(HDI_TEXT, hdi, 0, "UInt")
		NumPut(&HDITEMTEXT, hdi, 8, "Ptr")
		NumPut(1024, hdi, 8 + (A_PtrSize * 2), "Int")

		SendMessage, HDM_GETITEM, ColumnNumber-1, &hdi,, ahk_id %hWndHeader%
		return StrGet( NumGet(hdi, 8) )
	}
}

LV_DeleteSelectedRows() { ; Deletes selected rows and returns number of deleted rows. by Learning one
SelectedRowsCount := 0
;=== Get SelectedRows ===
RowNumber := 0
Loop
{
RowNumber := LV_GetNext(RowNumber)
if !RowNumber
break
SelectedRows .= RowNumber "|"
SelectedRowsCount ++
}
StringTrimRight, SelectedRows, SelectedRows, 1

TotalRows := LV_GetCount() ; LV_GetCount() returns the total number of rows in the control

If (SelectedRowsCount = TotalRows) { ; all selected
LV_Delete() ; If the parameter is omitted, all rows in the ListView are deleted
return SelectedRowsCount
}
else if (SelectedRowsCount = 0) ; nothing selected
return 0
else {
Loop, parse, SelectedRows, |
{
if (A_index = 1)
LV_Delete(A_LoopField)
else
LV_Delete(A_LoopField-A_Index+1)
}
return SelectedRowsCount
}
}

;+------------------END Library Stack-------------------+

;+---------------------------------------+
;AHKeys --> ahk db and script bin
;:*:qq:: --> Ind Contact Stamp
;FormatTime, Time,, MM/dd/yy hh:mm:ss tt 
;SendInput <nAME>@{SPACE}%A_Hour%:%A_min%{SPACE}<TN/Email> --{SPACE} 
;return
;+---------------------------------------+
#x::ExitApp ;--> always inclue was to force exit (WINKEY+x)

Return to “Ask For Help”

Who is online

Users browsing this forum: anadir, Bing [Bot], BoomBastic, daywalker, Odlanir, Xeo786 and 196 guests