Last active
February 7, 2020 19:31
-
-
Save Saibot942/9128fc588d34af4aee66ce889edd2627 to your computer and use it in GitHub Desktop.
Ticket handling tools for Kronos Cloud teams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Note: This EXE was compiled from an AutoHotkey script | |
; http://www.autohotkey.com/docs/Tutorial.htm | |
; # is windows key | |
; ^ is control | |
; ! is alt | |
; + is Shift | |
; & An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. | |
; ---------- META SCRIPTS ---------- META SCRIPTS ---------- META SCRIPTS ---------- | |
; These few scripts are specifically related to this overall program. | |
;##################################################### | |
;## Ctrl + Alt + Shift + l # List the functionality ## | |
;##################################################### | |
^!+l:: | |
MsgBox, | |
( | |
Ticket handling tools for Kronos Cloud teams`nVersion: 2020.02.06`nAuthor: Toby Garcia | |
https://gist.github.com/Saibot942/9128fc588d34af4aee66ce889edd2627 | |
`n============================================== | |
`nProgram Controls: | |
`n <ctrl + alt + shift + s>`n Show this list | |
`n <ctrl + alt + shift + x>`n eXit this program | |
`n----------------------------------------------------------------------- | |
`nTicket Handling: | |
`n <win+w>`n Open highlighted INC, RITM, TASK, CHG, or SID in ServiceNow | |
`n <win+f>`n Search for highlighted Case, SID, or KB in SalesForce | |
`n----------------------------------------------------------------------- | |
`nClipboard Tools: | |
`n <win+v>`n Show Clipboard contents in a popup message box | |
`n <ctrl+shift+v>`n Paste formatted text from clipboard in plaintext | |
`n <ctrl+shift+x>`n Empty the Windows clibboard | |
`n <ctrl+alt+win+v>`n CyberArk Paster | |
`n----------------------------------------------------------------------- | |
) | |
return | |
; ---------- | |
;############################################ | |
;## Ctrl + Alt + Shift + x to exit program ## | |
;############################################ | |
^!+x:: | |
SplashTextOn,250,50,BYE!,Peace out rainbow trout! | |
Sleep, 1111 | |
SplashTextOff | |
ExitApp | |
return | |
; ---------- FUNCTIONS ---------- FUNCTIONS ---------- FUNCTIONS ---------- | |
;function that returns the previous contents of the clipboard, and sets the sytem clipboard to whatever is currently hilighted | |
f_returnOrigClipboardAndCtrlC() { | |
;Msgbox,, f_returnOrigClipboardAndCtrlC, f_returnOrigClipboardAndCtrlC called! | |
sleep 100 ;Doesn't work without this pause!!! | |
origClipboard := Clipboard ;Save the system clipboard to our new variable origClipboard | |
Clipboard := "" ;Clear Clipboard so we can use ClipWait later... | |
SendInput ^c ;Copy whatever is hilighted | |
ClipWait, 1 ;Wait up to 1 second for Clipboard to contain text | |
if ErrorLevel | |
{ | |
MsgBox,,f_returnOrigClipboardAndCtrlC, The attempt to copy text onto the clipboard failed. Did you highlight anything? | |
Exit, 1 | |
} | |
;Msgbox,, f_returnOrigClipboardAndCtrlC, returning origClipboard:`n'%origClipboard%'`nto caller... | |
return, (origClipboard) ;Return [, Expression] (Variable names in an expression are not enclosed in percent signs, literal strings shoud be in "" quotes) | |
} | |
; ---------- | |
;function that takes arguement and sets it to the system clipboard, then exits. | |
f_restoreSystemClipboardAndExit(origClipboard) { | |
;MsgBox,, f_restoreSystemClipboardAndExit, origClipboard contents:`n`n%origClipboard%, 2 | |
Sleep 100 ;Doesn't work without this pause!!! | |
if ( strLen(origClipboard) > 0 ) { | |
Clipboard := "" ;Clear system clipboard so we can use ClipWait | |
Clipboard := origClipboard ;Restore origianal clipboard contents | |
ClipWait, 1 ;Wait up to 1 second for Clipboard to contain text | |
if ErrorLevel | |
{ | |
MsgBox,,f_restoreSystemClipboardAndExit, The attempt to copy text onto the clipboard failed. | |
Exit, 1 | |
} | |
origClipboard := "" ;free memory | |
Exit, 0 ;Exit | |
} else { | |
Exit, 0 | |
} | |
} | |
; ---------- | |
;Function to perform regex verification on clipboard contents and return it as an object with a type and a val | |
;val will have spaces and `r`n's removed | |
;Currently called from win+G and win+F | |
f_identifyClipboard() { | |
;Msgbox,, f_identifyClipboard, !!! | |
ahkInput := Clipboard ;Set hilighted text to ahkInput | |
StringReplace, ahkInput, ahkInput, `r`n, , All ;Remove all carrige returns and line feeds | |
StringReplace, ahkInput, ahkInput, %A_SPACE%, , All ;Remove all spaces | |
StringLen, ahkInputLen, ahkInput ;Set ahkInputLen to length of ahkInput | |
BugID := RegExMatch(ahkInput, "i)^ID") ;Set BugID to 1 if clipboard starts with id, not case sensitive | |
sfCase := RegExMatch(ahkInput, "[0,1][0-9]{7}") ;Set sfCase to 1 if clipboard is an 8 digit number, starting with 0 | |
sfSID := RegExMatch(ahkInput, "6[0-9]{6}") ;Set sfSID to 1 if clipboard is a 7 digit number starting with 6 | |
sfKB := RegExMatch(ahkInput, "i)^KB") ;Set sfSID to 1 if clipboard is a 7 digit number starting with 6 | |
snowINC := RegExMatch(ahkInput, "i)^INC") ;Set snowINC to 1 if clipboard starts with INC, not case sensitive | |
snowCHG := RegExMatch(ahkInput, "i)^CHG") ;Set snowCHG to 1 if clipboard starts with CHG, not case sensitive | |
snowPRB := RegExMatch(ahkInput, "i)^PRB") ;Set snowPRB to 1 if clipboard starts with PRB, not case sensitive | |
snowPRJ := RegExMatch(ahkInput, "i)^PRJ") ;Set snowPRJ to 1 if clipboard starts with PRJ, not case sensitive | |
snowREQ := RegExMatch(ahkInput, "i)^REQ") ;Set snowREQ to 1 if clipboard starts with CHG, not case sensitive | |
snowRITM := RegExMatch(ahkInput, "i)^RITM") ;Set snowRITM to 1 if clipboard starts with RITM, not case sensitive | |
snowTASK := RegExMatch(ahkInput, "i)^SCTASK") ;Set snowTASK to 1 if clipboard starts with RITM, not case sensitive | |
;Msgbox,, f_identifyClipboard, ahkInput: '%ahkInput%' ;(DISABLED) Enable for debug messagging | |
;Msgbox,, f_identifyClipboard, ahkInputLen: '%ahkInputLen%' ;(DISABLED) Enable for debug messagging | |
if (ahkInputLen > 15) { | |
waffles := {type: "tooLong", val: ahkInputLen} | |
} else if (BugID) { | |
waffles := {type: "bugID", val: ahkInput} | |
} else if (sfCase) { | |
waffles := {type: "sfCase", val: ahkInput} | |
} else if (sfSID) { | |
waffles := {type: "sfSID", val: ahkInput} | |
} else if (sfKB) { | |
waffles := {type: "sfKB", val: ahkInput} | |
} else if (snowINC) { | |
waffles := {type: "snowINC", val: ahkInput} | |
} else if (snowCHG) { | |
waffles := {type: "snowCHG", val: ahkInput} | |
} else if (snowPRB) { | |
waffles := {type: "snowPRB", val: ahkInput} | |
} else if (snowPRJ) { | |
waffles := {type: "snowPRJ", val: ahkInput} | |
} else if (snowREQ) { | |
waffles := {type: "snowREQ", val: ahkInput} | |
} else if (snowRITM) { | |
waffles := {type: "snowRITM", val: ahkInput} | |
} else if (snowTASK) { | |
waffles := {type: "snowTASK", val: ahkInput} | |
} else { | |
waffles := {type: "noMatch", val: ahkInput} | |
} | |
return (waffles) | |
} | |
; ---------- | |
;SF_Case function | |
f_winF(winF, typeF) { ; determines the correct URL to use for each type of search | |
if (typeF = "sfCase") { | |
winFURL = "https://kronos.my.salesforce.com/_ui/search/ui/UnifiedSearchResults?searchType=2&str=%winF%#!/fen=500&initialViewMode=detail" | |
} else if (typeF = "sfSID") { | |
winFURL = "https://kronos.my.salesforce.com/_ui/search/ui/UnifiedSearchResults?searchType=2&str=%winF%#!/fen=001&initialViewMode=detail" | |
} else if (typeF = "sfKB") { ; currently executed search within SF for the KB article. Uncomment the next line to go to chatter article instead. | |
winFURL = "https://kronos.my.salesforce.com/_ui/search/ui/UnifiedSearchResults?str=%winF%&searchType=2&sen=a4r#!/fen=ka&initialViewMode=detail&str=%winF%" | |
;winFURL = "https://community.kronos.com/s/article/%winF%" | |
} | |
SplashTextOn,1000,50,Opening %typeF%,%winFURL% ; splash message indicating URL action | |
Run, %winFURL% ; actually opening the website | |
Sleep, 2000 | |
SplashTextOff | |
return | |
} | |
; ---------- | |
;SNOW function | |
f_winW(winW, typeW) { ; determines the correct URL | |
if (typeW = "sfCase") { | |
winWURL = "https://kronoscloud.service-now.com/nav_to.do?uri=/incident_list.do?sysparm_query=123TEXTQUERY321=%winW%" | |
} else if (typeW = "snowINC") { | |
winWURL = "https://kronoscloud.service-now.com/incident.do?sys_id=%winW%" | |
} else if (typeW = "snowCHG") { | |
winWURL = "https://kronoscloud.service-now.com/change_request.do?sys_id=%winW%" | |
} else if (typeW = "snowPRB") { | |
winWURL = "https://kronoscloud.service-now.com/problem_list.do?sys_id=%winW%" | |
} else if (typeW = "snowREQ") { | |
winWURL = "https://kronoscloud.service-now.com/sc_request.do?sys_id=%winW%" | |
} else if (typeW = "snowRITM") { | |
winWURL = "https://kronoscloud.service-now.com/sc_req_item.do?sys_id=%winW%" | |
} else if (typeW = "snowTASK") { | |
winWURL = "https://kronoscloud.service-now.com/sc_task.do?sys_id=%winW%" | |
} | |
SplashTextOn,1000,50,Opening %typeW%,%winWURL% ; splash message indicating URL action | |
Run, %winWURL% ; actually opening the website | |
Sleep, 2000 | |
SplashTextOff | |
return | |
} | |
; ---------- SCRIPTS w/FUNCTIONS ---------- SCRIPTS w/FUNCTIONS ---------- SCRIPTS w/FUNCTIONS ---------- | |
;####################################### | |
;## 'win+w' # goto selected in SNOW ## | |
;####################################### | |
#w:: | |
origClipboard := f_returnOrigClipboardAndCtrlC() | |
pancakes := f_identifyClipboard() | |
;Msgbox % "Clipboard: "Clipboard "`nType: "pancakes.type "`nVal: "pancakes.val "`norigClipboard: "origClipboard | |
if (pancakes.type = "sfCase" or pancakes.type = "snowINC" or pancakes.type = "snowCHG" or pancakes.type = "snowPRJ" or pancakes.type = "snowPRB" or pancakes.type = "snowREQ" or pancakes.type = "snowRITM" or pancakes.type = "snowTASK") { | |
f_winW(pancakes.val, pancakes.type) | |
} else { | |
Msgbox,,% "Selection: "pancakes.type ,% "("pancakes.type ") is not valid for ServiceNow, try again.", 2 | |
} | |
f_restoreSystemClipboardAndExit(origClipboard) | |
; ---------- | |
;###################################### | |
;## 'win+f' # goto SalesForce case ## | |
;###################################### | |
#f:: | |
origClipboard := f_returnOrigClipboardAndCtrlC() | |
pancakes := f_identifyClipboard() | |
;Msgbox % "Clipboard: "Clipboard "`nType: "pancakes.type "`nVal: "pancakes.val "`norigClipboard: "origClipboard | |
if (pancakes.type = "sfCase" or pancakes.type = "sfSID" or pancakes.type = "sfKB") { | |
f_winF(pancakes.val, pancakes.type) | |
} else { | |
Msgbox,,% "Selection: "pancakes.type ,% "("pancakes.type ") is not valid for SalesForce try again.", 2 | |
} | |
f_restoreSystemClipboardAndExit(origClipboard) | |
; ---------- UTILITIES ---------- UTILITIES ---------- UTILITIES ---------- | |
;######################################## | |
;## 'ctrl+shift+v' # paste plaintext ## | |
;######################################## | |
^+v:: | |
clipboard = %clipboard% ; will remove formatting from windows clipboard | |
SendInput ^v ; ctrl + v (paste windows clipboard) | |
return ; To execute multiple commands, put the first line beneath the hotkey definition and make the last line a return | |
; ---------- | |
;################################ | |
;## 'win+v' # show clipboard ## | |
;################################ | |
; Show Clipboard contents in a popup message box | |
#v:: | |
MsgBox,,Clipboard contents:, %Clipboard%, 25 | |
return | |
; ---------- | |
;###################################### | |
;## 'ctrl+shift+x' # clear clipboard ## | |
;###################################### | |
; Empty the Windows clibboard | |
^+x:: | |
if ( StrLen(Clipboard) > 0 ) { | |
Msgbox, 4, Crtl + Alt + x, Clear Clipboard? | |
IfMsgBox, Yes | |
{ | |
Clipboard := "" | |
Msgbox,, Hey`, Listen!, Clipboard Cleared!, 1 | |
return | |
} | |
return | |
} else { | |
Msgbox,, Hey`, Listen!, Clipboard already empty!, 1 | |
return | |
} | |
; ---------- | |
;############################################### | |
;## 'ctrl+shift+c' # Copy Append (non-binary) ## | |
;############################################### | |
; Append a selected text to the end of existing clipboard using expressional assignment. | |
^+c:: | |
origClipboard := f_returnOrigClipboardAndCtrlC() | |
if ( StrLen(origClipboard) > 0 ) { | |
newClipboard := "`r`n`r`n" . Clipboard ;whatever was highlighted is now in our new variable newClipboard (appending two return line feeds) | |
Clipboard := "" ;orig and new clipboards saved, clear system clipboard | |
Clipboard := origClipboard . newClipboard ;Set system clipboard with the newClipboard appended to the origClipboard | |
ClipWait, 1 | |
if ErrorLevel | |
{ | |
MsgBox,,Ctrl+Shift+c (Copy Append), The attempt to copy text onto the clipboard failed. | |
Exit, 1 | |
} | |
newClipboard := "" ;free memory | |
origClipboard := "" ;free memory | |
return | |
} else { | |
return | |
} | |
; ---------- | |
;########################################## | |
;## 'ctrl+win+alt+v' # CyberArk Paster ## | |
;########################################## | |
^#!v:: | |
SendInput ^c ;Copy selected text | |
ClipWait, 1 ;Wait up to 1 second for Clipboard to contain text | |
if ErrorLevel | |
{ | |
MsgBox,,, The attempt to copy text onto the clipboard failed. Did you highlight anything? | |
Exit, 1 | |
} | |
;MsgBox, 4097, , Activate the window into which you wish to paste text and click OK.`n`nText block to be pasted:`n`n%Clipboard% | |
MsgBox, 4097, , Activate the window into which you wish to paste text and click OK. | |
IfMsgBox, Cancel ;CANCEL handler | |
{ | |
SplashTextOn,,, Canceled | |
Sleep 750 | |
SplashTextOff | |
Return | |
} | |
Sleep, 250 | |
SendRaw, %Clipboard% ;sends raw keystrokes to type windows clipboard contents | |
return | |
; ---------- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
KCH_Tools
Ticket handling tools for Kronos Cloud teams
Author: Toby Garcia
==============================================
Program Controls:
<ctrl + alt + shift + l> Show this list
<ctrl + alt + shift + x> eXit this program
Ticket Handling:
<win+w> Open highlighted INC, RITM, TASK, etc. in ServiceNow
<win+f> Open highlighted case or SID in SalesForce
Clipboard Tools:
<win+v> Show Clipboard contents in a popup message box
<ctrl+shift+v> Paste formatted text from clipboard in plaintext
<ctrl+shift+x> Empty the Windows clibboard
<ctrl+alt+win+v> CyberArk Paster