AutoHotkey Community

It is currently May 27th, 2012, 4:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: November 19th, 2009, 10:35 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
I'm combining several scripts that I've been using for the last year into a GUI that I hope to share with other employees at my desk. The code below was an independent AHK script on my pc that worked perfectly (98% of the time)

The problem I'm having now is that a line of text that is commented out in my code is finding it's way into my clipboard... and then my script is pasting it into my ticketing system... Which will never be accepted as something that other agents could use.

Code:
;BlockInput, on
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
; Jumps to the Home Field "Office Number"
Send, {SHIFTDOWN}{CTRLDOWN}{HOME}{SHIFTUP}{CTRLUP}
Sleep, 100
;Tabs to the Case ID field.
Send, {TAB %case_id%}
;Highlights and copies the Case ID field
Send, {SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
ClipWait ;
;Stores the Case ID field to the variable "fueticket"
fueticket = %ClipBoard%
Clipboard = ;
Sleep, 100
;If,Then,Else statement to Tab to the Email Address field
if (email_address > case_id){
tabnum := email_address - case_id
  Send, {TAB %tabnum%}
  }
else{
tabnum := case_id - email_address
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Sleep, 100
; Highlights and Copies the Email Address field
Send, {CTRLDOWN}{END}{CTRLUP}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
ClipWait ;
; Stores the Email Address to the variable "fueemail"
fueemail = %ClipBoard%

ClipBoard = ;
Sleep, 350
; If,Then,Else to tabe to the Short Description field.
if (short_description > email_address){
tabnum := short_description - email_address
  Send, {TAB %tabnum%}
  }
else{
tabnum := email_address - short_description
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Sleep, 100
; Highlights and Copies the Short Description field.
Send, {SHIFTDOWN}{UP}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
ClipWait ;
fueshortDis = %ClipBoard%
ClipBoard = ;
Sleep, 350
Run mailto:%fueemail%&subject=SERVICE DESK FOLLOW-UP: %fueticket%
WinWait, SERVICE DESK FOLLOW-UP: %fueticket%
IfWinNotActive, SERVICE DESK FOLLOW-UP: %fueticket%, WinActivate, SERVICE DESK FOLLOW-UP: %fueticket%
WinWaitActive, SERVICE DESK FOLLOW-UP: %fueticket%
;Sleep, 1000
ClipBoard = ServiceDesk Ticket-Updates
ClipWait ;
Send, {SHIFTDOWN}{TAB 4}{SHIFTUP}
Send ^v
Sleep, 300
ClipBoard = A Service Desk agent was unable to reach you at phone number provided in the ticket. Please contact the Service Desk at XXX-XXX-XXXX for assistance regarding Ticket Number
ClipWait ;
Send, {TAB 5}{CTRLDOWN}a{CTRLUP}{DEL}
Send ^v
Send ^b
Send, {SPACE}<
Sleep, 300
ClipBoard = %fueticket%
ClipWait ;
Send ^v
Send, >
Send ^b
Send, {SPACE}
Sleep, 300
ClipBoard = The description for this ticket is:
ClipWait ;
Send ^v
Send ^b
Send, {SPACE}<
Sleep, 300
ClipBoard = %fueshortDis%>`r`n`r`n%Agent_Initials%
ClipWait ;
Send ^v
Send ^b
Send, {SPACE}
Sleep, 300
ClipBoard = |`r`nService Desk Support Specialist II`r`n IT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
ClipWait ;
Send ^v
Sleep, 300
Send, {ALTDOWN}f{ALTUP}
Sleep, 150
Send, a
WinWait, Save As,
IfWinNotActive, Save As, , WinActivate, Save As,
WinWaitActive, Save As,
Sleep, 300
ClipBoard = %Stored_Email%
ClipWait ;
Send ^v
Send, {TAB}oo{ENTER}{ENTER}
WinWait, Microsoft Office Outlook,
IfWinNotActive, Microsoft Office Outlook, , WinActivate, Microsoft Office Outlook,
WinWaitActive, Microsoft Office Outlook,
Send, {LEFT}{ENTER}
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Sleep, 350
ClipBoard = <ve %A_MM%/%A_DD% %Agent_Initials%
ClipWait,
Send {HOME}^v{SPACE}
if (status > short_description){
tabnum := status - short_description
  Send, {TAB %tabnum%}
  }
else{
tabnum := short_description - status
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Send, p
if (pending > status){
tabnum := pending - status
  Send, {TAB %tabnum%}
  }
else{
tabnum := status - pending
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Send, r
if (worklog > pending){
tabnum := worklog - pending
  Send, {TAB %tabnum%}
  }
else{
tabnum := pending - worklog
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
ClipBoard = LVE For Follow Up
ClipWait,
Send ^v
if (timespent > worklog){
tabnum := timespent - worklog
  Send, {TAB %tabnum%}
  }
else{
tabnum := worklog - timespent
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
}
Send, {BACKSPACE}5
if (assignee > timespent){
tabnum := assignee - timespent
  Send, {TAB %tabnum%}
  }
else{
tabnum := timespent - assignee
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
}
Send, {SHIFTDOWN}{HOME}{SHIFTUP}
Sleep, 300
ClipBoard = %Remedy_Name%
ClipWait ;
Send ^v
Sleep, 500
ClipBoard = %ClipCurrent%
;BlockInput, Off
Return


The text that keeps getting erroneously added to the clipboard is

Code:
; Highlights and Copies the Short Description field.


If you have time, could you scan my code and see if I have indeed applied this text to the clipboard somewhere... Or am I experiencing some sort of "memory buffer overflow" and this is my garbage output and if so can you recommend someway of avoiding this problem.

Thank you,
Sam


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 11:28 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
This is confusing code. I'm working on cleaning it up, combining some sections, converting the SEND keys to be more readable, or at least their shortcut formats.

Being heavily relied on the clipboard for pasting may be part of the issue. I would suggest 3 step process for it, or you can have SEND send it, unless there's some important reason not to.

Code:
;empty clipboard
clipboard =
clipboard = something
clipwait

send ^v


EDIT: Here's the cleaned up code, although i am still not entirely sure what you are doing, nor can i test it. If the program is slow, then having all the sleeps may be required, otherwise this should do.

Code:
   ;BlockInput, on
   SetTitleMatchMode 2

   WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
;   IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
   WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem

   ClipCurrent := ClipBoardAll

   ; Jumps to the Home Field "Office Number"
   Send, +^{HOME}

   ;Tabs to the Case ID field.
   Send, {TAB %case_id%}

   ;Highlights and copies the Case ID field
   ClipBoard =
   Send, +{HOME}^c
   ClipWait

   ;Stores the Case ID field to the variable "fueticket"
   fueticket = %ClipBoard%

   ;If,Then,Else statement to Tab to the Email Address field
   if (email_address > case_id) {
      tabnum := email_address - case_id
      Send, {TAB %tabnum%}
   } else {
      tabnum := case_id - email_address
      Send, +{TAB %tabnum%}
   }

   ; Highlights and Copies the Email Address field

   Clipboard =
   Send, ^{END}+{HOME}^c
   ClipWait

   ; Stores the Email Address to the variable "fueemail"
   fueemail = %ClipBoard%

   ; If,Then,Else to tabe to the Short Description field.
   if (short_description > email_address) {
      tabnum := short_description - email_address
      Send, {TAB %tabnum%}
   } else {
      tabnum := email_address - short_description
      Send, +{TAB %tabnum%}
   }
   
   ; Highlights and Copies the Short Description field.
   ClipBoard =
   Send, +{UP}+{HOME}^c
   ClipWait

   fueshortDis = %ClipBoard%

   Run mailto:%fueemail%&subject=SERVICE DESK FOLLOW-UP: %fueticket%

   WinWait, SERVICE DESK FOLLOW-UP: %fueticket%
;   IfWinNotActive, SERVICE DESK FOLLOW-UP: %fueticket%
   WinWaitActive, SERVICE DESK FOLLOW-UP: %fueticket%

   Send, +{TAB 4}ServiceDesk Ticket-Updates

   Send, {TAB 5}^a{DEL}

   ;separated for convinence of the message only.
   Send, A Service Desk agent was unable to reach you at phone number provided in the ticket. Please contact the Service Desk at XXX-XXX-XXXX for assistance regarding Ticket Number
   Send, ^b{SPACE}<{Raw}%fueticket%>

   Send ^b The description for this ticket is:^b <{raw}%fueshortDis%>`r`n`r`n%Agent_Initials%
   ;second send due to RAW.
   Send ^v^b{SPACE}
   
   clipboard =
   ClipBoard = |`r`nService Desk Support Specialist II`r`n IT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
   ClipWait
   Send ^v!fa

   WinWait, Save As,
;   IfWinNotActive, Save As, , WinActivate, Save As,
   WinWaitActive, Save As,

   Send {Raw}%Stored_Email%
   Send ^v{TAB}oo{ENTER}{ENTER}
   
   WinWait, Microsoft Office Outlook,
;   IfWinNotActive, Microsoft Office Outlook
   WinWaitActive, Microsoft Office Outlook

   Send, {LEFT}{ENTER}

   WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
;   IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
   WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem

;   ClipBoard =
;   ClipWait
   ;if agent initials never contain {}^! or other control characters, then this is ok.
   Send {HOME}<ve %A_MM%/%A_DD% %Agent_Initials%{SPACE}

   ;compacted separate character sends with the other sends.
   if (status > short_description){
      tabnum := status - short_description
      Send, {TAB %tabnum%}p
   } else {
      tabnum := short_description - status
      Send, +{TAB %tabnum%}p
   }

   if (pending > status) {
      tabnum := pending - status
      Send, {TAB %tabnum%}r
   } else {
      tabnum := status - pending
      Send, +{TAB %tabnum%}r
   }
   
   if (worklog > pending) {
      tabnum := worklog - pending
      Send, {TAB %tabnum%}
   } else {
      tabnum := pending - worklog
      Send, +{TAB %tabnum%}
   }

   Send, LVE For Follow Up

   if (timespent > worklog){
      tabnum := timespent - worklog
      Send, {TAB %tabnum%}
   } else {
      tabnum := worklog - timespent
      Send, +{TAB %tabnum%}
   }

   ;backspace and replace with 5? or backspace 5 times?
   Send, {BACKSPACE}5

   if (assignee > timespent){
      tabnum := assignee - timespent
      Send, {TAB %tabnum%}+{HOME}
   } else {
      tabnum := timespent - assignee
      Send, +{TAB %tabnum%}+{HOME}
   }

   Send, {Raw}%Remedy_Name%
   
   ClipBoard = %ClipCurrent%
   ;BlockInput, Off
Return


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 20th, 2009, 4:59 am 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Sorry I didn't give more info last time... was trying to get to the bank before the closed and wanted to make sure I posted before leaving the office so that I could possibly get an answer before going back to work tomorrow.

I work at a Service Desk as both a Tier I and Tier II. I started working with the Tier II group about a year ago, and quickly became tired of the "routine." The code in this script became the answer. The ticketing system we use has a few quirks though so I had to develop "workarounds." I only have one field that is target-able by hot key, so to access the code in the other fields I have to rely on TABS. I updated the script a couple months ago and started using the clipboard. My reason for using the clipboard is that while the "Send" command in combination with a string of text is faster than myself or anyone else at the Service Desk can type, pasting a big string of text all at once is near instantaneous. When I switched from the Sending the text to pasting the text my script run time dropped by 50% or better. So now that we've gone through some of the estranged reasons for my code, let me give a more detailed commenting in the code, and maybe that will help anyone looking to see exactly what is happening. (I am going to use a copy/paste from my initial code) and will attempt to apply some of the keystroke changes made by rtcvb32, I used the large keystroke commands because my initial code was made by the AHK script recorder.

Code:
; This script gathers information from an existing Service Desk Ticket, Creates an E-Mail to the customer providing the customer with the ticket number, and the short description of the ticket then saves the E-Mail.
; The script then updates the ticket... Short Description is Tagged so that other Tier II agents can tell what tickets have been worked and that last day it was worked, and adds a Work Log entry that the agent
; Left voice mail and email for follow-up.
; (Future script will prompt Tier II agent to provide special instructions to the customer, and attach the saved email to the script)

; Activate the ticket program, Remedy, copy the Ticket Number, customer's e-mail address, and the short description.
; BlockInput, on
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
; I still think this next code is needed (especially if this script is initiated while another program has focus), I can't test it until tomorrow, but if someone
; can give me reason tonight I'm all ears.
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem

ClipCurrent = %ClipBoardAll% ; My understanding is that I need to use the % symbol here to make sure that the contents of the clipboard are stored to "ClipCurrent" and not the word ClipBoardAll
ClipBoard = ; Empty the clipboard to ensure no conflicts with the next clipboard data.

Send, +^{HOME} ; Jumps to the Home Field "Office Number," This is the only field in our Ticketing system that I can target with a "Hot Key"
Sleep, 100 ; I've had some problems with my scripts getting ahead and causing the wrong text to copy, or not copy at all, so I add Sleep commands to try and correct the timing.

Send, {TAB %case_id%} ;The Ticketing system uses "templates" for placement of the fields, and fields can be added and removed by the System Engineers as required, because of this
; my scripts can be messed up whenever a template is updated.  Because of this I use an INI file to store the Tab numbers based off of the Home Field.

;Highlights and copies the Case ID field
Send, +{HOME}^c
ClipWait ;Waite for the clipboard to have content before continueing.

fueticket = %ClipBoard% ;Stores the Case ID field to the variable "fueticket"

Clipboard = ;
Sleep, 100

if (email_address > case_id){ ; These variables are from the INI file.  IF/Else statement so that when the System engineers update the TAB order of the Ticketing system it will still work.
tabnum := email_address - case_id
  Send, {TAB %tabnum%}
  }
else{
tabnum := case_id - email_address
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Sleep, 100

Send, ^{END}+{HOME}^c ; Highlights and Copies the Email Address field
ClipWait ;

fueemail = %ClipBoard% ; Stores the Email Address to the variable "fueemail"
ClipBoard = ;
Sleep, 350

if (short_description > email_address){
tabnum := short_description - email_address
  Send, {TAB %tabnum%}
  }
else{
tabnum := email_address - short_description
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Sleep, 100

Send, +{UP}{HOME}^c ; Highlights and Copies the Short Description field.
ClipWait ;
fueshortDis = %ClipBoard%
ClipBoard = ;
Sleep, 350

; Create new e-mail, address it to the customer, send it from the Service Desk email addres, tell the customer the ticket number, and short description of the ticket we are contating him in reference too.
; Add the service desk agents initials for tracking purposes.  Save the e-mail to a specific location for easy attaching of the email to the customers ticket.
Run mailto:%fueemail%&subject=SERVICE DESK FOLLOW-UP: %fueticket%
WinWait, SERVICE DESK FOLLOW-UP: %fueticket%
IfWinNotActive, SERVICE DESK FOLLOW-UP: %fueticket%, WinActivate, SERVICE DESK FOLLOW-UP: %fueticket%
WinWaitActive, SERVICE DESK FOLLOW-UP: %fueticket%
;Sleep, 1000
ClipBoard = ServiceDesk Ticket-Updates
ClipWait ;
Send, +{TAB 4}
Send ^v
Sleep, 300
ClipBoard = A Service Desk agent was unable to reach you at phone number provided in the ticket. Please contact the Service Desk at XXX-XXX-XXXX for assistance regarding Ticket Number
ClipWait ;
Send, {TAB 5}^a{DEL}
Send ^v
Send ^b
Send, {SPACE}<
Sleep, 300
ClipBoard = %fueticket%
ClipWait ;
Send ^v
Send, >
Send ^b
Send, {SPACE}
Sleep, 300
ClipBoard = The description for this ticket is:
ClipWait ;
Send ^v
Send ^b
Send, {SPACE}<
Sleep, 300
ClipBoard = %fueshortDis%>`r`n`r`n%Agent_Initials%
ClipWait ;
Send ^v
Send ^b
Send, {SPACE}
Sleep, 300
ClipBoard = |`r`nService Desk Support Specialist II`r`n IT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
ClipWait ;
Send ^v
Sleep, 300
Send, !f
Sleep, 150
Send, a

; Waite for the save window, and save.
WinWait, Save As,
IfWinNotActive, Save As, , WinActivate, Save As,
WinWaitActive, Save As,
Sleep, 300
ClipBoard = %Stored_Email%
ClipWait ;
Send ^v
Send, {TAB}oo{ENTER}{ENTER}

; Waite for save window to close and for the notice window that their is already a file with this title.
WinWait, Microsoft Office Outlook,
IfWinNotActive, Microsoft Office Outlook, , WinActivate, Microsoft Office Outlook,
WinWaitActive, Microsoft Office Outlook,
Send, {LEFT}{ENTER} ; Tell the system to overwrite the existing file. (No need for these files to exist on the agents computer beyond working the ticket as they are attached to the ticket before moving on to the next ticket)

; Switch back to Ticket/Remedy to Tag the ticket with the date, and that the agent left a voice mail and/or email.
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Sleep, 350
ClipBoard = <ve %A_MM%/%A_DD% %Agent_Initials%
ClipWait,
Send {HOME}^v{SPACE}
if (status > short_description){
tabnum := status - short_description
  Send, {TAB %tabnum%}
  }
else{
tabnum := short_description - status
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Send, p
if (pending > status){
tabnum := pending - status
  Send, {TAB %tabnum%}
  }
else{
tabnum := status - pending
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
Send, r
if (worklog > pending){
tabnum := worklog - pending
  Send, {TAB %tabnum%}
  }
else{
tabnum := pending - worklog
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
  }
ClipBoard = LVE For Follow Up
ClipWait,
Send ^v
if (timespent > worklog){
tabnum := timespent - worklog
  Send, {TAB %tabnum%}
  }
else{
tabnum := worklog - timespent
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
}
Send, {BACKSPACE}5
if (assignee > timespent){
tabnum := assignee - timespent
  Send, {TAB %tabnum%}
  }
else{
tabnum := timespent - assignee
  Send, {SHIFTDOWN}{TAB %tabnum%}{SHIFTUP}
}
Send, {SHIFTDOWN}{HOME}{SHIFTUP}
Sleep, 300
ClipBoard = %Remedy_Name%
ClipWait ;
Send ^v
Sleep, 500
ClipBoard = %ClipCurrent%
;BlockInput, Off
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 11:06 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Didnt read the whole post.
But I think this:
tabnum := case_id - email_address
cant work, because you have spaces in the name of the var...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 10:47 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
I work a LOT with automating ticketing systems of all sorts.

First thing's first, without a function like this you are practically dead in the water. "Send" is insane to try to time or verify the entry durations, you need to use the clipboard whenever you want to enter text: (something like)

Code:
Paste(x) ;paste text safely
{
   While Clipboard <>
   {
   Clipboard =
   }
   
   While Clipboard <> x
   {
   Clipboard := x
   }
   
   Send, ^v
   
   Sleep, 100
   
Return

}


And when grabbing text from the screen:


Code:
ClipCopy() ;get text from the screen using the clipboard
{
   SavedClip := Clipboard
   Sleep, 50
   Clipboard =
   Sleep, 50
   Send ^c ;copy
   ClipWait
   Copied := Clipboard
   Sleep, 50
   Clipboard := SavedClip
   
Return Copied

}


Try those and see if you are still having problems. Chances are we can get around whatever is causing the problem but you need to be entering and retrieving the text in a sane, verifiable way first. The thing that makes these 'sane' is that your next command is not ever going to fire before the operation has completed.

The trick to automating any system is that every action you take must be verified. Change a window control? Verify it before the next action and use that verification as the script timing. The command won't move on until it can verify that what it did is correct and since you have verified it you know the script can safely proceed. This must be done for EVERY action taken WHEREVER possible if you want reliable automation.

Code:
   VALUEENTRY := 0
   While valueentry <> 1
   {
      ControlSetText, Edit7, %Value%, ClarifyCRM ;set the field text
      Sleep, 100
      ControlGetText, valueentry, Edit7, ClarifyCRM
      
      If valueentry = %value%
      {
         valueentry = 1
      }
      
      If A_index > 100 ;if more than 10 seconds or 100 attempts have passed
      {
         ErrorLog("ClarifyChooseQuery()", "Failed to verify selection of VALUE field")
      }
   }


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 19th, 2010, 8:23 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
:shock: Thank you, Thank you, Thank you!!!!
I've got say Randallf... I'm literally blown away with a mindset for autohotkey programing that I had considered before but couldn't see how to do it. Just this past week I started experimenting with using ControlSetText and ControlGetText within my ticketing program and Outlook. I had been using Copy & Paste commands for some time now (huge performance boost over the send command) but still had to deal with timing issues, and the only way I knew to deal with the timing issues was with the sleep command and the clipwait command which works... until I try and let a coworker use my script. The idea of using a whileloop to set a field to text then get the text back out of the field to a different variable and compare them and continue the while loop until they match is totally awesome... With a script that has reached 1200+ lines and mainly only using sleep and clipwait I know this will be a big undertaking, but I see the huge benefit... I see this as the key to making my script finally start becoming stable enough that my coworkers can benefit from it because to this day I'm the only person using it because I know what the bugs are and how to work around them.

I see where you are using a ErrorLog function as a kill switch for the while loop if it goes over 10 seconds. Can you provide more insight into how you do your error logs like this... I only have one error system right now and it is check and error message created in the same area of my script where the check is done. It looks like you are using a Function and or combination of functions here for your errorlog. I really don't consider myself a program so this is another mindset I just don't have right now. Thank you

Thank you again,
Sam

Any more nuggets of information like this that you can offer would be greatly appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2010, 12:00 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Glad you like it! Here's a function for ensuring that controls are active before sending a paste command,

Code:
ControlFocusVerify(control, wintitle)
{
   control = %control%
   NotFocused := 1
   While NotFocused
   {
      ControlFocus, %control%, %wintitle%
      Sleep, 100
      ControlGetFocus, x, %wintitle%
      If x = %control%
      {
         NotFocused := 0
      }
   }

   If A_index > 100 ;10 seconds in this loop of sleep, 100
   {
      msgbox Error! Control: %control%
      ErrorLog("ControlFocusVerify", "Failed to verify that control: %control% was focused.")
   }
   
}


The error logging function WAS simple, you could potentially add a lot to this, or make it simple again, this is from the function set that I built for ClarifyCRM...

It more or less just write the stuff you send it to a file and issues exitapp. The 'last line' stuff won't work because of course the last lines are always the error logging function! XD



Code:
ErrorLog(function, reason) ;log an error to file and quit
{
   Error := function . " returned failure for case:" . CaseID " because " . reason . " at:" . a_now . "`n" . "AHK FUNCTION: " . A_ThisFunc . "`n" . "AHK LABEL:    " . A_ThisLabel . "`n" . "LAST FILE:    " . A_LineFile . "`n" . "LAST LINE:    " . A_LineNumber . "`n"
   ErrorFile := A_ScriptDir . "\ErrorLog.txt"
   FileAppend, %error%, %ErrorFile%
   msgbox %error%`nError has been logged. Exiting application.
   LaunchFile(ErrorFile, "Notepad")   
   
ExitApp ;calling this function closes the application

}


If you are in 'NKY' i am in 'SWOH', if you want to talk AHK sometime let me know.

Also, if you'd like me to look your code over and make suggestions I'd be glad to... with examples of your own code to learn from you'd probably make some big strides.

One last edit... are you using HP ServiceCenter?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Cool...
PostPosted: April 20th, 2010, 2:18 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
I'm actually in South KY, my parents live in Florence and extended family is in Dayton, so I travel up near there a few times a year.

As for the program we are actually using an in house Remedy Client... I.E. we bought their Server but use our own application for the agents. Which is probably the biggest hurdle of this whole project...

The ControlFocusVerify is very cool but will only work for Outlook email :-( the reason is that our in house program uses something like frames for separating the editable field, because every single editable field on a ticket has the exact same ClassNN name, thus the reason I have to use the TABTO(to,from) function so that I can get data from and manipulate the data in the ticket.

Another issue I have just had come up within the past couple months is that they have made new tickets and existing tickets have a different tab order by removing one of the tab locations from new tickets. So none of my functions work with new tickets right now because I haven't figured out how to alter my tab order properly.

I would love to let you look at my code, I will have to go through it and remove company information first though as they have strict policies in place on that stuff... So maybe later today or tomorrow I can place it on here.

Thanks again,
Sam

Have to get back to work now :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2010, 6:34 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
Here is my Code presently... Wish I had more time to go through and comment everything for you; but things are kind of busy here at the desk and presently I don't get time to dedicate to this project.
Code:
; Program Title
program_title = 3S D Tool Box (Alpha 1.3)

; System Tray Icon
Menu, Tray, Icon, %A_ScriptDir%\images\tray.ico
Menu, Tray, Tip, %program_title%
Menu, tray, add, Settings, 3ST_Settings
Menu, tray, add, Clear ClipBoard, Clear_ClipBoard
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         Samuel D. Harney <sam@samharney.com>
;
; Script Function: The purpose of this script is to simpligy the repetitive
;   routines of the Agents working in the Service Desk. To Streamline tasks
; to allow for a more standardized front, and smoother operations.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Includes GetINIVars.ahk
#Include %A_ScriptDir%\getinivars.ahk ; This script file reads all my stored variables from multiple INI files.

;Main GUI Window, GUI allows for agent to run most scripts with their mouse if they choose (Parts of the GUI do not have any actual scripts added yet, so still have other features the GUI will reveal that I still need to code)
Gui 1: Default
Gui, Add, Picture, x0 y0 w222 h92 , %A_ScriptDir%\3st-logo.gif
Gui, Add, MonthCal, x2 y92 w210 h152 vSelected_Date ,
Gui, Add, Text, x2 y251 w67 h20 , Current Mode:
Gui, Add, Text, x70 y251 w150 h40 vPm , %phonemode%
Gui, Add, Text, x2 y288 w49 h15 , Set Mode
;The following 3 lines of the GUI have no script yet. Partly because it would require a second seperate script that was encoded as a seperate exe file for the final product, and also because Managment stated that they didn't like parts of this feature...
Gui, Add, DropDownList, x73 y286 w120 h21 vSelectedMode r5 AltSubmit, 10 Min. Break|15 Min. Break|Available|Availabe w/ T-Pop|Available No ACD|Logged Off & Log Out|Lunch|Lunch (30 Min.)|Lunch (1 Hour)
Gui, Add, Text, x2 y313 w75 h15 , Return Mode
Gui, Add, DropDownList, x73 y308 w120 h21 vreturn_code r5 AltSubmit, Meeting-Mgr|Meeting-Team|Available|Available w/ T-Pop||Available No ACD|Special Projects|Training-Company|Training-Customer
;Gui, Add, Button, x193 y286 w20 h21 gGetMode, >
AddGraphicButton("interaction_mode_button", A_WorkingDir . "\images\interaction.bmp", "x193 y286 w20 h21 gGetMode", 15, 15)
Gui, Add, Text, x2 y335 w65 h15 , Assign To:
Gui, Add, DropDownList, x73 y330 w120 h21 vDDAssignTo r3 AltSubmit, Tier 1 %Remedy_Name%|Tier 2 %Remedy_Name%|Site Support
AddGraphicButton("remedy_assign_button", A_WorkingDir . "\images\remedy.bmp", "x193 y330 w20 h21 gAssignTo", 15, 15)
Gui, Add, Text, x2 y357 w65 h15 , Email From
Gui, Add, DropDownList, x73 y352 w120 h21 vDDEmail_From r3 AltSubmit, %Email_Name%||ServiceDesk Ticket-Updates
AddGraphicButton("new_email_button", A_WorkingDir . "\images\newemail.bmp", "x193 y352 w20 h21 gEmail_Customer", 12, 15)
Gui, Add, Text, x2 y379 w65 h15 , Tier II:
Gui, Add, DropDownList, x73 y374 w120 h21 vDDTierII r3 AltSubmit, Day 1:Follow-Up|Day 2:COB Notice|Day 4:Close Ticket
AddGraphicButton("tierii_button", A_WorkingDir . "\images\remedy.bmp", "x193 y374 w20 h21 gTierII_Drop_Down", 15, 15)
Gui, Add, Button, x4 y415 w100 h30 gcallers_tickets_HK, Look-up All of`nthe Callers Tickets
Gui, Add, Button, x112 y415 w100 h30 gwip_ticket_button, WIP`r`nTicket
AddGraphicButton("remedy_button", A_WorkingDir . "\images\remedy.bmp", "x4 y462 h30 w30 gActivate_Remedy", 25, 25)
AddGraphicButton("outlook_button", A_WorkingDir . "\images\outlook.bmp", "x35 y462 h30 w30 gActivate_Outlook", 25, 25)
AddGraphicButton("bomgar_button", A_WorkingDir . "\images\bomgar.bmp", "x66 y462 h30 w30 gActivate_Bomgar", 25, 25)
;Gui, Add, Button, x112 y462 w100 h30 gActivate_Outlook, Outlook
;Gui, Tab, Tier II

; Generated using SmartGUI Creator 4.0
  Gui, Show, X%windowX% Y%windowY% h500 w218, %program_Title%
  Gui, Color, FFFFFF
  Gui, +AlwaysOnTop
If %alwaysOnTop% = 0
  {
  Gui, -AlwaysOnTop
  }

;HotKey Global Listeners (The following HotKeys are only de-activated when the Settings window is open. Some HotKeys need to be either locked down to a specific program or scripts updated to make sure and switch to that program before executing.)
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_HK%, Available_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_w_TP_HK%, AvailablewTP_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_no_acd_HK%, available_no_acd_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %callers_tickets_HK%, callers_tickets_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %email_caller_HK%, Email_Customer
Hotkey, IfWinActive, BMC Remedy User - [CITS Service Management ;Using partical Window Title match mode so that both Tier 1 and Tier 2 agents could use this script
Hotkey, %resolve_qc_HK%, AssignToAgent_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %wip_ticket_HK%, wip_ticket_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day1_HK%, t2_day1_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day2_HK%, t2_day2_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day4_HK%, t2_day4_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %activate_remedy_HK%, activate_remedy
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %activate_outlook_HK%, activate_outlook
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_highlighted_HK%, call_highlighted_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_phone_HK%, call_phone_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_cell_HK%, call_cell_HK

Return

;"Subroutines" are used as the main way for controling the flow of the script
;Button Subs
TierII_Drop_Down: ;This Subroutine is for the GUI window, it gets the result for the DDTierII dropdown and then based on the number it sends the script to the proper Subroutine.
GuiControlGet, DDTierII
If DDTierII = 1
  {
  GoSub, t2_day1_HK
  }
Else If DDTierII = 2
  {
  GoSub, t2_day2_HK
  }
Else If DDTierII = 3
  {
  GoSub, t2_day4_HK
  }
Return

Email_Customer: ;This Subroutine is curently broken, due to me attempting to use ControlGetText, and ControlSetText in place of the Copy/Paste commands that I had been using.
GuiControlGet, DDEmail_From
ClipCurrnet = %ClipboardAll%
Clipboard = ;
SetTitleMatchMode 2
WinWait, BMC Remedy User - [CITS Service Management,
IfWinNotActive, BMC Remedy User - [CITS Service Management, , WinActivate, BMC Remedy User - [CITS Service Management,
WinWaitActive, BMC Remedy User - [CITS Service Management,
Send, +^{HOME}{Tab %email_address%} ;Shift+Control+Home is a keyboard command within our Remedy that sends the cursor to the Home field, The Home field is where all my Tab numbering is based off of, and the Tab numbers are stored in an INI file.
Sleep 500
ControlGetText, ticket_email, RichEdit20A1, BMC Remedy User - [CITS Service Management
If DDEmail_From = 1
  {
  Run mailto:%ticket_email%&subject=SERVICE DESK
  }
Else If DDEmail_From = 2
  {
  Run mailto:%ticket_email%&subject=SERVICE DESK
  WinWait, SERVICE DESK
  Sleep, 1000
ControlSetText, RichEdit20WPT1, ServiceDesk Ticket-Updates, SERVICE DESK
Sleep, 100
email_body = %Agent_Initials% |`r`nService Desk Support Specialist II`r`nIT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
;MsgBox, %email_body%
ControlSetText, _WwG1, %email_body%, SERVICE DESK
Sleep, 100   
  Send, ^{HOME}{DEL}{ENTER}{ENTER}^{HOME}
  Clipboard = %ClipCurrent%
  }
Return

AssignTo: ; Assign Ticket DropDown Box
GuiControlGet, DDAssignTo
If DDAssignTo = 3
  {
  GoSub, Assign_To_Site_Support
  }
Else If DDAssignTo != 3
  {
  GoSub, AssignToAgent
  }
Return

AssignToAgent_HK:
DDAssignTo = 1
AssignToAgent:
SetTitleMatchMode 2
WinWait, BMC Remedy User - [CITS Service Management,
IfWinNotActive, BMC Remedy User - [CITS Service Management, , WinActivate, BMC Remedy User - [CITS Service Management,
WinWaitActive, BMC Remedy User - [CITS Service Management,
If DDAssignTo = 2
  {
  Send, +^{HOME}
  Sleep, 100
  Send, {Tab %group%}
  Send, +{HOME}%t2_queue%
  TabTo(assignee, group)
  Send, +{HOME}%Remedy_Name%
  }
Else If DDAssignTo = 1
  {
  Send, +^{HOME}
  Sleep, 100
  Send, {Tab %group%}
  Send, +{HOME}Service Desk
  TabTo(assignee, group)
  Send, +{HOME}%Remedy_Name%
  }
Return

 
Assign_To_Site_Support:
Clipcurrent = %ClipBoardAll%
Clipboard = ;
SetTitleMatchMode 2
WinWait, BMC Remedy User - [CITS Service Management,
IfWinNotActive, BMC Remedy User - [CITS Service Management, , WinActivate, BMC Remedy User - [CITS Service Management,
WinWaitActive, BMC Remedy User - [CITS Service Management,
Send, +^{HOME}
Sleep, 100
Send, {TAB %locationdetails%}{ENTER}
SetTitleMatchMode 2
WinWait, BMC Remedy User - [CITS Location Information (Modify)],
Sleep, 500
Send, {F6}
Sleep, 300
Send +{END}
Sleep, 100
Send, ^c
Clipwait,
Sleep, 100
Send, ^{F4}
WinWait, Remedy User - [CITS Service Management,
Sleep, 100
Tabto(group, locationdetails)
Send +{HOME}^v
Sleep, 500
Tabto(assignee, group)
Send +{HOME}{Backspace}
Clipboard = %Clipcurrent%
Return

Activate_Remedy:
WinGet, wList, List, ahk_class ArFrame
if !wList { ; if wList is empty/zero (no Remedy windows exist)
  Run, C:\Program Files\AR System\User\aruser.exe
  return
}
if (wList >= 1) {
  WinActivate, % "ahk_id " wList1
  return
}
Return

Activate_Outlook:
Run, outlook.exe /recycle
Return


Activate_Bomgar:
WinGet, wList, List, ahk_class QWidget
if !wList { ; if wList is empty/zero (no Outlook windows exist)
  Clipcurrent = %ClipBoardAll%
  Clipboard = ;
  SetTitleMatchMode, 2
  WinActivate, Remedy User
  WinWaitActive, Remedy User
  Send, +^{HOME}
  Sleep 100
  Send {TAB %email_address%}+{HOME}^c
  Clipwait,
  bomgar_email_address = %Clipboard%
  Run, C:\Program Files\Bomgar\Representative\remote-its.naismc.com\bomgar-rep.exe
  WinWaitActive, Bomgar - Representative Login
  Send, {ENTER}
  WinWaitActive, Bomgar Representative Console
  Send !s{DOWN}{ENTER}
  WinWaitActive, Session Key Generated
  Clipboard = ;
  Sleep, 100
  Send, {TAB 4}^c
  Clipwait,
  Sleep, 100
  bomgar_session_key = %Clipboard%
  Sleep, 100
  StringReplace, bomgar_session_key, bomgar_session_key, ?, `%3F, All
  Send, {ESC}
  Sleep, 100
; Run mailto:%bomgar_email_address%&subject=Service Desk Remote Support Invitation from %agent_first_name%
bomgar_email_body=
(
%agent_first_name% would like to start a support session with you. To do so, please click on the link below and follow the online instructions.`%0A`%0A%bomgar_session_key%`%0A`%0ABomgar enables a support representative to view your screen in order to assist you. Session traffic is fully encrypted to protect your system's data. Once a session has begun, you will be able to end it at any time.`%0A`%0A%Agent_Initials% | `%0A%Agent_Title%`%0AIT Services`%0APhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`%0A%Service_Desk_homepage%
)
  Run mailto:%bomgar_email_address%&subject=Service Desk Remote Support Invitation from %agent_first_name%&Body=%bomgar_email_body%
 WinWait, Service Desk Remote Support Invitation from %agent_first_name%
 Sleep, 100
 ControlSetText, RichEdit20WPT1, ServiceDesk Ticket-Updates, Service Desk Remote Support Invitation from %agent_first_name%
 ;Send, +{TAB 4}ServiceDesk Ticket-Updates
 Sleep, 300
; Send, {TAB 5}^a{DEL}%agent_first_name% would like to start a support session with you. To do so, please click on the link below and follow the online instructions.{ENTER}{ENTER}%bomgar_session_key%{ENTER}{ENTER}Bomgar enables a support representative to view your screen in order to assist you. Session traffic is fully encrypted to protect your system's data. Once a session has begun, you will be able to end it at any time.^b{Enter}{Enter}%Agent_Initials%^b{SPACE}| {ENTER}%Agent_Title%{ENTER}IT Services{ENTER}Phone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%{ENTER}%Service_Desk_homepage%
 Sleep, 100
 Clipboard = Clipcurrent
 Clipwait
 return
}
if (wList >= 1) {
  Clipcurrent = %ClipBoardAll%
  Clipboard = ;
  SetTitleMatchMode, 2
  WinActivate, Remedy User
  WinWaitActive, Remedy User
  Send, +^{HOME}
  Sleep 100
  Send {TAB %email_address%}+{HOME}^c
  Clipwait,
  bomgar_email_address = %Clipboard%
  WinActivate, % "ahk_id " wList1
  WinWaitActive, Bomgar Representative Console
  Send !s{DOWN}{ENTER}
  WinWaitActive, Session Key Generated
  Clipboard = ;
  Sleep, 100
  Send, {TAB 4}^c
  Clipwait,
  Sleep, 100
  bomgar_session_key = %Clipboard%
  Sleep, 100
  StringReplace, bomgar_session_key, bomgar_session_key, ?, `%3F, All
  Send, {ESC}
  Sleep, 100
  bomgar_email_body=
(
%agent_first_name% would like to start a support session with you. To do so, please click on the link below and follow the online instructions.`%0A`%0A%bomgar_session_key%`%0A`%0ABomgar enables a support representative to view your screen in order to assist you. Session traffic is fully encrypted to protect your system's data. Once a session has begun, you will be able to end it at any time.`%0A`%0A%Agent_Initials% | `%0A%Agent_Title%`%0AIT Services`%0APhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`%0A%Service_Desk_homepage%
)
  Run mailto:%bomgar_email_address%&subject=Service Desk Remote Support Invitation from %agent_first_name%&Body=%bomgar_email_body%
;  Run mailto:%bomgar_email_address%&subject=Service Desk Remote Support Invitation from %agent_first_name%
  WinWait, Service Desk Remote Support Invitation from %agent_first_name%
  Sleep, 100
  Send, +{TAB 4}ServiceDesk Ticket-Updates
  Sleep, 300
;  Send, {TAB 5}^a{DEL}%agent_first_name% would like to start a support session with you. To do so, please click on the link below and follow the online instructions.{ENTER}{ENTER}%bomgar_session_key%{ENTER}{ENTER}Bomgar enables a support representative to view your screen in order to assist you. Session traffic is fully encrypted to protect your system's data. Once a session has begun, you will be able to end it at any time.^b{Enter}{Enter}%Agent_Initials%^b{SPACE}| {ENTER}%Agent_Title%{ENTER}IT Services{ENTER}Phone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%{ENTER}%Service_Desk_homepage%
  Sleep, 100
  Clipboard = Clipcurrent
  Clipwait
  return
}
Return

; HotKey Subs
Available_HK:
SelectedMode=3
GoSub ChangeMode
Return

AvailablewTP_HK:
SelectedMode = 4
GoSub ChangeMode
Return

available_no_acd_HK:
SelectedMode = 5
GoSub ChangeMode
Return

callers_tickets_HK:
SetTitleMatchMode 2
WinActivate, Remedy User - [CITS Service Management
Send, +^{HOME}
Sleep, 100
Send, {TAB %employee_id%}
Sleep, 100
Send +{HOME}^c^o!a{HOME}cits incident/problem management{ENTER}
WinWait, Remedy User - [CITS Service Management
IfWinNotActive, Remedy User - [CITS Service Management, WinActivate, Remedy User - [CITS Service Management
WinWaitActive, Remedy User - [CITS Service Management
Sleep, 100
Send +^{HOME}
Send, {TAB %employee_id%}^v^{ENTER}
Return

;Tier II HotKey Subs
wip_ticket_button:
WinWait, BMC Remedy User - [CITS Service Management,
IfWinNotActive, BMC Remedy User - [CITS Service Management, , WinActivate, BMC Remedy User - [CITS Service Management,
WinWaitActive, BMC Remedy User - [CITS Service Management,
wip_ticket_HK:
BlockInput, on
Send, +^{HOME}
Send, {TAB %status%}w
TabTo(worklog, status)
Sleep, 500
Send, %Wip_Work_Log_Entry%
Sleep, 100
Tabto(timespent, worklog)
Send, {Backspace}1
Tabto(assignee, timespent)
Send, +{HOME}
Send, %Remedy_Name%
;Send, {CTRLDOWN}{ENTER}{CTRLUP}
;WinWait, AR System User - Note,
;IfWinNotActive, AR System User - Note, , WinActivate, AR System User - Note,
;WinWaitActive, AR System User - Note,
;Send, {Enter}
BlockInput, off
Return

t2_day1_HK:
SetTitleMatchMode 2
WinWait, BMC Remedy User - [CITS Service Management (Modify)],
IfWinNotActive, BMC Remedy User - [CITS Service Management (Modify)], , WinActivate, BMC Remedy User - [CITS Service Management (Modify)],
WinWaitActive, BMC Remedy User - [CITS Service Management (Modify)],
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
Sleep, 350
Send, +^{HOME}
Sleep, 100
Send, {TAB %case_id%}
Send, +{HOME}^c
ClipWait ;
fueticket = %ClipBoard%
Clipboard = ;
Sleep, 350
TabTo(email_address, case_id)
Sleep, 100
Send, ^{END}+{HOME}^c
ClipWait ;
fueemail = %ClipBoard%
ClipBoard = ;
Sleep, 350
TabTo(short_description, email_address)
Sleep, 100
Send, +{UP}+{HOME}^c
ClipWait ;
fueshortDis = %ClipBoard%
ClipBoard = ;
t2_day1_email_body=
(
A Service Desk agent was unable to reach you at phone number provided in the ticket. Please contact the Service Desk at ___-___-____ for assistance regarding Ticket Number <%fueticket%> The description for this ticket is: <%fueshortDis%>`%0A`%0A%Agent_Initials% | `%0A%Agent_Title%`%0AIT Services`%0APhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`%0A%Service_Desk_homepage% 
)
Sleep, 350
Run mailto:%fueemail%&subject=SERVICE DESK FOLLOW-UP: %fueticket%&Body=%t2_day1_email_body%
WinWait, SERVICE DESK FOLLOW-UP: %fueticket%
Sleep, 1000
ClipBoard = ServiceDesk Ticket-Updates
ClipWait ;
Send, +{TAB 4}
Send ^v
Sleep, 300
Send, !f
Sleep, 100
Send, a
WinWait, Save As,
WinWaitActive, Save As,
Sleep, 300
ClipBoard = %Stored_Email%SERVICE DESK FOLLOW-UP
ClipWait ;
Send ^v
Send, {TAB}oo{ENTER}{ENTER}
WinWait, Microsoft Office Outlook,
IfWinNotActive, Microsoft Office Outlook, , WinActivate, Microsoft Office Outlook,
WinWaitActive, Microsoft Office Outlook,
Send, {LEFT}{ENTER}
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Sleep, 350
ClipBoard = <ve %A_MM%/%A_DD% %Agent_Initials%
Send {HOME}^v{SPACE}
TabTo(status, short_description)
Send, {home}p
TabTo(pending, status)
Send, {home}
Tabto(attachment, pending)
attachment_file = 0
GoSub, Attach_Email_To_Ticket
WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
If attachment_file > 1
  {
  Send, {DOWN %attachment_file%}
  }
If attachment_file < 5
  {
  Send, {UP}
  }
Send {APPSKEY}a
Sleep, 300
Send, %Stored_Email%SERVICE DESK FOLLOW-UP.msg{ENTER}
TabTo(worklog, attachment)
Send, %day1_work_log_entry%
TabTo(timespent, worklog)
Send, {BACKSPACE}5
TabTo(assignee, timespent)
Send, +{HOME}
Send, %Remedy_Name%
Sleep, 500
ClipBoard = %ClipCurrent%
Return

t2_day2_HK:
GoSub, COB_Parse
If A_DD = %cob_day%
  {
  MsgBox,0,Error: COB Date,ERROR: COB Date = Todays Date`r`nPlease Select a COB Date with a future date.
  Return
  }
If (A_DD > %cob_day%) and (A_MM = %cob_month%)
  {
  MsgBox,0,Error: COB Date,ERROR: COB Date is PRIOR to Todays Date`r`nPlease Select a COB Date with a future date.
  Return
  }
;If (A_DD = 1) and (%cob_day% > 26)
;  {
;  MsgBox,0,Error: COB Date,ERROR: COB Date is PRIOR to Todays Date`r`nPlease Select a COB Date with a future date.
;  Return
;  }
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
Sleep, 350
Send, +^{HOME}
Sleep, 100
Send, {TAB %case_id%}
Send, +{HOME}^c
ClipWait ;
cobticket = %ClipBoard%
Clipboard = ;
Sleep, 350
TabTo(email_address, case_id)
Sleep, 100
Send, ^{END}+{HOME}^c
ClipWait ;
cobemail = %ClipBoard%
ClipBoard = ;
Sleep, 350
TabTo(short_description, email_address)
Sleep, 100
Send, +{UP}+{HOME}^c
ClipWait ;
cobshortDis = %ClipBoard%
ClipBoard = ;
Sleep, 350
Run mailto:%cobemail%&subject=Ticket due to close: %cobticket%
WinWait, Ticket due to close: %cobticket%
Sleep, 1000
ClipBoard = ServiceDesk Ticket-Updates
ClipWait ;
Send, +{TAB 4}^v
Sleep, 300
ClipBoard = A Service Desk agent was unable to reach you at phone number provided in the ticket. This is the second attempt to contact you regarding ticket number
ClipWait ;
Send, {TAB 5}^a{DEL}
Send ^v^b{SPACE}<
Sleep, 300
ClipBoard = %cobticket%>
ClipWait ;
Send ^v^b{SPACE}
Sleep, 300
ClipBoard = The description for this ticket is:
ClipWait ;
Send ^v^b{SPACE}<
Sleep, 300
Clipboard = ;
GoSub, Format_Short_Description
ClipWait ;
WinActivate, Ticket due to close: %cobticket%
Send %COB_Short_Description%>{ENTER}{ENTER}
ClipBoard = Your ticket will be CLOSED if there is no response by close of business tomorrow <%cob_month%/%cob_day%>
ClipWait,
Send, ^v^b{SPACE}
Sleep, 300
Clipboard = ;
Clipboard = If you are still experiencing a problem or have any questions, please contact the Service Desk immediately at ___-___-____. We look forward to assisting you.
ClipWait ;
Send ^v^b{ENTER}{ENTER}%Agent_Initials%^b{SPACE}
Sleep, 300
ClipBoard = | `r`nService Desk Support Specialist II`r`nIT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
ClipWait ;
Send ^v
Sleep, 300
Send, !f
Sleep, 100
Send, a
WinWait, Save As,
;IfWinNotActive, Save As, , WinActivate, Save As,
WinWaitActive, Save As,
Sleep, 300
ClipBoard = %Stored_Email%Ticket due to close
ClipWait ;
Send ^v{TAB}oo{ENTER}{ENTER}
WinWait, Microsoft Office Outlook,
IfWinNotActive, Microsoft Office Outlook, , WinActivate, Microsoft Office Outlook,
WinWaitActive, Microsoft Office Outlook,
Send, {LEFT}{ENTER}
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Sleep, 350
ClipBoard = <ve %A_MM%/%A_DD% *COB %cob_month%/%cob_day%* %Agent_Initials% %COB_Short_Description%
Send {DEL}^v
TabTo(attachment, short_description)
attachment_file = 0
GoSub, Attach_Email_To_Ticket
WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
If attachment_file > 1
  {
  Send, {DOWN %attachment_file%}
  }
If attachment_file < 5
  {
  Send, {UP}
  }
Send {APPSKEY}a
Sleep, 300
Send, %Stored_Email%Ticket due to close.msg{ENTER}
TabTo(worklog, attachment)
Send, %day2_work_log_entry%
TabTo(timespent, worklog)
Send, {BACKSPACE}5
TabTo(assignee, timespent)
Send, +{HOME}
Send, %Remedy_Name%
Sleep, 500
ClipBoard = %ClipCurrent%
COB_ticket_finished = 1
Return

t2_day4_HK:
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
IfWinNotActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Sleep, 200
Send, +^{HOME}{TAB %worklog%}!+{F7}
WinWaitActive, CITS Service Managem
Send, {TAB 2}^{END}
MsgBox,4,Please Veriy updated status...,Has this ticket been updated since the user was notified that it was going to close?
IfMsgBox, Yes
  Return
Send, {Esc}
WinWaitActive, Remedy User - [CITS Service Management (Modify)], CITS Service Managem
Send +^{HOME}
Send, {TAB %case_id%}+{HOME}^c
ClipWait,
TicketID = %ClipBoard%
Sleep, 500
Tabto(resolution_code, case_id)
Send, User - Unable to Reach/No Response
Sleep, 500
ClipBoard = ;
ClipBoard = The Service Desk has made two previous attempts to contact you regarding this ticket and received no response. We believe that your problem may be resolved so we will be closing ticket number %TicketID% . If you are still experiencing a problem or need additional assistance, please contact the Service Desk at ___-___-____ and we will open a new request for you. Thank you for your time.`r`n`r`n%Agent_Initials% | `r`n%Agent_Title%`r`nIT Services`r`nPhone: %Service_Desk_Phonenum% Fax: %Service_Desk_faxnum%`r`n%Service_Desk_homepage%
Clipwait
Tabto(status, resolution_code)
Send, r
Tabto(worklog, status)
Send ^v
Tabto(timespent, worklog)
Send, {BACKSPACE}5
Tabto(resolution, timespent)
Send ^v
;^{ENTER}
;WinWait, AR System User - Note, OK
;IfWinNotActive, AR System User - Note, OK, WinActivate, AR System User - Note, OK
;WinWaitActive, AR System User - Note, OK
;Send, {Enter}
;Sleep, 100
;WinWait, BMC Remedy User - [CITS Service Management (Modify)], CITS Service Managem
;IfWinNotActive, BMC Remedy User - [CITS Service Management (Modify)], CITS Service Managem, WinActivate, BMC Remedy User - [CITS Service Management (Modify)], CITS Service Managem
;WinWaitActive, BMC Remedy User - [CITS Service Management (Modify)], CITS Service Managem
;Send, {CTRLDOWN}{F4}{CTRLUP}
Return

call_highlighted_HK:
BlockInput, on
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
Send, ^c
Dial()
ClipBoard = %ClipBoardAll%
BlockInput, off
Return

call_phone_HK:
BlockInput, on
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management
IfWinNotActive, Remedy User - [CITS Service Management, WinActivate, Remedy User - [CITS Service Management
WinWaitActive, Remedy User - [CITS Service Management
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
Sleep, 350
Send, +^{HOME}
Sleep, 100
Send, {TAB %phone%}
Sleep, 500
Send, +{HOME}^c
Clipwait
Sleep, 1000
Dial()
ClipBoard = %ClipCurrent%
BlockInput, off
Return

call_cell_HK:
BlockInput, on
ClipCurrent = %ClipBoardAll%
ClipBoard = ;
SetTitleMatchMode 2
WinWait, Remedy User - [CITS Service Management
IfWinNotActive, Remedy User - [CITS Service Management, WinActivate, Remedy User - [CITS Service Management
WinWaitActive, Remedy User - [CITS Service Management
Send, +^{HOME}
Sleep, 100
Send, {TAB %cell%}
Sleep, 500
Send, +{HOME}^c
Clipwait
Sleep, 1000
Dial()
ClipBoard = %ClipCurrent%
BlockInput, off
Return

GetMode: ;Called by the ">" button next to the Set Mode Drop Down List.
GuiControlGet, SelectedMode
ChangeMode: ;Allows Hotkeys to by pass the GuiControlGet command above.
GuiControlGet, return_code
If (return_code = 1){
return_mode = Meeting-Mgr
}
Else If (return_code = 2){
return_mode = Meeting-Team
}
Else If (return_code = 3){
return_mode = Available
}
Else If (return_code = 4){
return_mode = Available w/ T-Pop
}
Else If (return_code = 5){
return_mode = Available No ACD
}
Else If (return_code = 6){
return_mode = Special Projects
}
Else If (return_code = 7){
return_mode = Training-Company
}
Else If (return_code = 8){
return_mode = Training-Customer
}
If (SelectedMode = 1){
  GuiControl, Text, Pm, Aux - Break 10 Min.`r`nAuto %return_mode%
  IniWrite, 10, %preferencesini%, Timer, minutes
  IniWrite, 0, %preferencesini%, Timer, seconds
  IniWrite, 10 Min. Break, %preferencesini%, Timer, mode_title
  IniWrite, aux_break, %preferencesini%, Timer, mode_code
  ChangeMode(aux_break)
  Run %A_ScriptDir%\timer.ahk
}
Else If (SelectedMode = 2){
  GuiControl, Text, Pm, Aux - Break 15 Min.`r`nAuto %return_mode%
  IniWrite, 14, %preferencesini%, Timer, minutes
  IniWrite, 45, %preferencesini%, Timer, seconds
  IniWrite, 15 Min. Break, %preferencesini%, Timer, mode_title
  IniWrite, aux_break, %preferencesini%, Timer, mode_code
  ChangeMode(aux_break)
  Run %A_ScriptDir%\timer.ahk
}
Else If (SelectedMode = 3){
  GuiControl, Text, Pm, Available`r`nNo T-Pop
  ChangeMode(available)
}
Else If (SelectedMode = 4){
  GuiControl, Text, Pm, Available`r`nWith T-Pop
  IniWrite, available, %preferencesini%, Timer, mode_code
  ChangeMode(available)
  Run %A_ScriptDir%\ticketpop.ahk
}
Else If (SelectedMode = 5){
  GuiControl, Text, Pm, Available No ACD
  ChangeMode(available_no_acd)
}
Else If(SelectedMode = 6){
  GuiControl, Text, Pm, Logged Off &`r`nLogged Out
  ChangeMode(logged_off)
  WinWaitActive, Interaction Client: .NET Edition,
  Send, !fo
}
return

GuiClose:
WinGetPos, 3sX, 3sY, , , A  ; "A" to get the active window's pos.
IniWrite, %3sX%, %preferencesini%, GUI, windowx
IniWrite, %3sY%, %preferencesini%, GUI, windowy

ExitApp

;Tier II Comands

COB_Parse:
GuiControlGet, Selected_Date
Loop, parse, Selected_Date
{
date%A_index% = %A_LoopField%
}
cob_month = %date5%%date6%
cob_day = %date7%%date8%
return

; *******************************************************************
; AddGraphicButton.ahk
; *******************************************************************
; Version: 2.2 Updated: May 20, 2007
; by corrupt
; *******************************************************************
; VariableName = variable name for the button
; ImgPath = Path to the image to be displayed
; Options = AutoHotkey button options (g label, button size, etc...)
; bHeight = Image height (default = 32)
; bWidth = Image width (default = 32)
; *******************************************************************
; note:
; - calling the function again with the same variable name will
; modify the image on the button
; *******************************************************************
AddGraphicButton(VariableName, ImgPath, Options="", bHeight=32, bWidth=32){
Global
Local ImgType, ImgType1, ImgPath0, ImgPath1, ImgPath2, hwndmode
; BS_BITMAP := 128, IMAGE_BITMAP := 0, BS_ICON := 64, IMAGE_ICON := 1
Static LR_LOADFROMFILE := 16
Static BM_SETIMAGE := 247
Static NULL
SplitPath, ImgPath,,, ImgType1
If ImgPath is float
{
  ImgType1 := (SubStr(ImgPath, 1, 1)  = "0") ? "bmp" : "ico"
  StringSplit, ImgPath, ImgPath,`.
  %VariableName%_img := ImgPath2
  hwndmode := true
}
ImgTYpe := (ImgType1 = "bmp") ? 128 : 64
If (%VariableName%_img != "") AND !(hwndmode)
  DllCall("DeleteObject", "UInt", %VariableName%_img)
If (%VariableName%_hwnd = "")
  Gui, Add, Button,  v%VariableName% hwnd%VariableName%_hwnd +%ImgTYpe% %Options%
ImgType := (ImgType1 = "bmp") ? 0 : 1
If !(hwndmode)
  %VariableName%_img := DllCall("LoadImage", "UInt", NULL, "Str", ImgPath, "UInt", ImgType, "Int", bWidth, "Int", bHeight, "UInt", LR_LOADFROMFILE, "UInt")
DllCall("SendMessage", "UInt", %VariableName%_hwnd, "UInt", BM_SETIMAGE, "UInt", ImgType,  "UInt", %VariableName%_img)
Return %VariableName%_img ; Return the handle to the image
}

Format_Short_Description:
Gui 3:Default
Gui, Add, Text, x10 y10 w200 h30, Please Remove All Tier II Tags
Gui, Add, Edit, x10 y40 w200 h30 vCOB_Short_Description, %cobshortDis%
Gui, Add, Button, x220 y40 w50 h30 gSave_COB_Short_Description, OK
Gui, Show, h80 w280, %program_title% Settings
Gui, +AlwaysOnTop -SysMenu +Owner
Gui, +LastFound   ; set the Last Found Window
WinWaitActive     ; "wait" until Gui5 is active
WinWaitClose
Return

Save_COB_Short_Description:
GuiControlGet, COB_Short_Description
Sleep, 500
Clipboard = 1
ClipWait,
Gui, Destroy
Return

Attach_Email_To_Ticket:
Gui 5:Default
Gui, Add, Text, x10 y10 w200 h30, Please Type the number for the File Attachment (1-5)
Gui, Add, DropDownList, x10 y40 w65 h45 r5 vattachment_file, 1|2|3|4|5
Gui, Add, Button, x220 y40 w50 h30, OK
Gui, Show, h80 w280, %program_title% Attachment File #:
Gui, +AlwaysOnTop -SysMenu +Owner
Gui, +LastFound   ; set the Last Found Window
WinWaitActive     ; "wait" until Gui5 is active
WinWaitClose      ; wait until Gui5 is closed (destroyed)
Return

5ButtonOK:
GuiControlGet, attachment_file
Sleep, 500
Clipboard = 1
ClipWait,
Gui, Destroy
Return

Clear_ClipBoard:
ClipBoard = ""
Return

3ST_Settings:
GoSub, 3ST_Settings_Gui
GuiControl,, vDDEmail_From, |%Email_Name%||ServiceDesk Ticket-Updates
Return

3ST_Settings_Gui:

; Parse Emails for display in the Program Settings
ST2_Day1_Email = %T2_Day1_Email%
StringReplace, ST2_Day1_Email, ST2_Day1_Email, <n>, `n, All
StringReplace, ST2_Day1_Email, ST2_Day1_Email, <r>, `r, All
ST2_Day2_Email = %T2_Day2_Email%
StringReplace, ST2_Day2_Email, ST2_Day2_Email, <n>, `n, All
StringReplace, ST2_Day2_Email, ST2_Day2_Email, <r>, `r, All
ST2_Email_Signature = %T2_Email_Signature%
StringReplace, ST2_Email_Signature, ST2_Email_Signature, <n>, `n, All
StringReplace, ST2_Email_Signature, ST2_Email_Signature, <r>, `r, All

Gui 2:Default
Gui, Add, Button, x510 y340 w100 h30 gGui2Cancel , Cancel
Gui, Add, Button, x406 y340 w100 h30 gGui2OK, OK
Gui, Add, Button, x302 y340 w100 h30 gGui2Apply, Apply
Gui, Add, Tab, x-4 y0 w620 h340 , Preferences|Hotkeys|T2 Day 1|T2 Day 2|T2 Email Signature
Gui, Tab, Preference
Gui, Add, CheckBox, x6 y30 w100 h20 vSalwaysOnTop Checked%alwaysOnTop%, Always On Top
Gui, Add, GroupBox, x6 y90 w600 h240 , Personal Information
Gui, Add, Text, x16 y110 w80 h20 , Remedy Name
Gui, Add, Edit, x96 y110 w140 h20 vSRemedy_Name, %Remedy_Name%
Gui, Add, Text, x16 y140 w80 h20 , Email Name
Gui, Add, Edit, x96 y140 w140 h20 vSEmail_Name, %Email_Name%
Gui, Add, Text, x16 y170 w80 h20 , Initials
Gui, Add, Edit, x96 y170 w140 h20 vSAgent_Initials, %Agent_Initials%
Gui, Add, Text, x16 y200 w80 h20 , First Name
Gui, Add, Edit, x96 y200 w140 h20 vSagent_first_name, %agent_first_name%
Gui, Add, Text, x16 y230 w80 h20 , Tier II Queue
Gui, Add, DropDownList, x96 y230 w140 h20 r6 vST2_queue, %T2_queue%||Service Desk|Service Desk (DW-CRM-RM)|Service Desk (Email)|Service Desk (Follow-Up)|Service Desk (RmAcc/WIFI)|Service Desk (T&E/Procur)
Gui, Add, Text, x16 y260 w80 h20 , QC-Signature
Gui, Add, Edit, x96 y260 w140 h20 vSqc_signature, %qc_signature%
Gui, Add, Text, x256 y140 w100 h20 , Job Position
Gui, Add, Edit, x366 y140 w230 h20 vSAgent_Title , %Agent_Title%
Gui, Add, Text, x256 y170 w100 h20 , Work In Progress
Gui, Add, Edit, x366 y170 w230 h20 vSwip_work_log_entry , %wip_work_log_entry%
Gui, Add, Text, x256 y200 w100 h20 , Saved Email Path
Gui, Add, Edit, x366 y200 w230 h20 vSStored_Email , %Stored_Email%
Gui, Tab, Hotkeys
Gui, Add, Text, x6 y30 w130 h20 , Available
Gui, Add, Hotkey, x186 y30 w120 h20 vSavailable_HK, %available_HK%
Gui, Add, Text, x6 y60 w130 h20 , Available with Ticket Pop
Gui, Add, Hotkey, x186 y60 w120 h20 vSavailable_w_TP_HK, %available_w_TP_HK%
Gui, Add, Text, x6 y90 w130 h20 , Available No ACD
Gui, Add, Hotkey, x186 y90 w120 h20 vSavailable_no_acd_HK,%available_no_acd_HK%
Gui, Add, Text, x6 y120 w130 h20 , Look-up Callers Tickets
Gui, Add, Hotkey, x186 y120 w120 h20 vScallers_tickets_HK, %callers_tickets_HK% 
Gui, Add, Text, x6 y150 w130 h20 , Email Caller
Gui, Add, Hotkey, x186 y150 w120 h20 vSemail_caller_HK, %email_caller_HK%
Gui, Add, Text, x6 y180 w130 h20 , Resolve Quick Call
Gui, Add, Hotkey, x186 y180 w120 h20 vSresolve_qc_HK, %resolve_qc_HK%
Gui, Add, Text, x6 y210 w130 h20 , Activate Outlook
Gui, Add, Hotkey, x186 y210 w120 h20 vSactivate_outlook_HK, %activate_outlook_HK%
Gui, Add, Text, x6 y240 w130 h20 , Activate Remedy
Gui, Add, Hotkey, x186 y240 w120 h20 vSactivate_remedy_HK, %activate_remedy_HK%
;Tier 2
Gui, Add, GroupBox, x326 y30 w280 h300 , Tier II Only
Gui, Add, Text, x336 y60 w110 h20 , WIP Ticket
Gui, Add, Hotkey, x466 y60 w130 h20 vSwip_ticket_HK, %wip_ticket_HK%
Gui, Add, Text, x336 y90 w110 h20 , Day 1 Follow-up
Gui, Add, Hotkey, x466 y90 w130 h20 vSt2_day1_HK, %t2_day1_HK%
Gui, Add, Text, x336 y120 w110 h20 , Day 2 Follow-up/COB
Gui, Add, Hotkey, x466 y120 w130 h20 vSt2_day2_HK, %t2_day2_HK%
Gui, Add, Text, x336 y150 w110 h20 , Day 4 Close COB
Gui, Add, Hotkey, x466 y150 w130 h20 vSt2_day4_HK, %t2_day4_HK%
Gui, Add, Text, x336 y180 w110 h20 , Dial Highlighted
Gui, Add, Hotkey, x466 y180 w130 h20 vScall_highlighted_HK, %call_highlighted_HK%
Gui, Add, Text, x336 y210 w110 h20 , Dial Customer Phone
Gui, Add, Hotkey, x466 y210 w130 h20 vScall_phone_HK, %call_phone_HK%
Gui, Add, Text, x336 y240 w110 h20 , Dial Customer Cell
Gui, Add, Hotkey, x466 y240 w130 h20 vScall_cell_HK, %call_cell_HK%
Gui, Tab, T2 Day 1
Gui, Add, Text, x6 y30 w450 h60, The Email variables will be used for placement of the data from the ticket.`nMake sure to include the brackets "[]" and this is case sesitive. (i.e. [tsd] will not work)
Gui, Add, GroupBox, x455 y30 w155 h62, Email Variables
Gui, Add, Text, x460 y45 w145 h40, [T#] - Ticket Number`n[TSD] - Short Description`n[FIX] - Fix Guide
Gui, Add, Text, x6 y80 w200 h20, Day 1 Email Subject
Gui, Add, Edit, x6 y100 w450 h20 vST2_Day1_subject, %T2_Day1_subject%
Gui, Add, Text, x6 y125 w145 h20, Day 1 Email Template.
Gui, Add, Edit, x6 y150 w600 h180 vST2_Day1_Email , %ST2_Day1_Email%
Gui, Tab, T2 Day 2
Gui, Add, Text, x6 y30 w450 h60, The Email variables will be used for placement of the data from the ticket.`nMake sure to include the brackets "[]" and this is case sesitive. (i.e. [tsd] will not work)
Gui, Add, GroupBox, x455 y30 w155 h62, Email Variables
Gui, Add, Text, x460 y45 w145 h40, [T#] - Ticket Number`n[TSD] - Short Description`n[COB] - COB Date
Gui, Add, Text, x6 y80 w200 h20, Day 2 Email Subject
Gui, Add, Edit, x6 y100 w450 h20 vST2_Day2_subject, %T2_Day2_subject%
Gui, Add, Text, x6 y125 w145 h20, Day 2 Email Template.
Gui, Add, Edit, x6 y150 w600 h180 vST2_Day2_Email , %ST2_Day2_Email%
Gui, TAB, T2 Email Signature
Gui, Add, Text, x6 y30 w450 h60, The Signature Variables will be used for placement of the data from the `nPreferences tab into the signature of the emails sent to the customer.`nMake sure to include the brackets "[]" and this is case sesitive. (i.e. [tsd] will not work)
Gui, Add, GroupBox, x455 y30 w155 h62, Signature Variables
Gui, Add, Text, x460 y45 w145 h40, [INI] - Agent Initials`n[AT] - Agent Title`n[S#] - Service Desk #`n[SF#]
Gui, Add, Text, x6 y125 w145 h20,  Signature Template.
Gui, Add, Edit, x6 y150 w600 h180 vST2_Email_Signature , %ST2_Email_Signature%


; Generated using SmartGUI Creator 4.0
Gui, Show, x346 y204 h377 w615, %program_title% Settings
Gui, +AlwaysOnTop -SysMenu +Owner
Gui, +LastFound   ; set the Last Found Window
WinWaitActive     ; "wait" until Gui5 is active
WinWaitClose 
Return

Gui2Cancel:
Gui, Destroy
Return


Gui2OK:
IniWrite, 0, %preferencesini%, GUI, Save_Finished
Sleep, 100
GoSub, Gui2Apply
Gui2OKRepeat:
IniRead, Save_Finished, %preferencesini%, GUI, Save_Finished
If (%Save_Finished% = 1)
  {
  Sleep, 100
  GoSub, Gui2OKRepeat
  }
Gui, Destroy
Return

Gui2Apply:
GuiControlGet, SalwaysOnTop
alwaysontop = %SalwaysOnTop%
IniWrite, %SalwaysOnTop%, %preferencesini%, Gui, alwaysontop
GuiControlGet, SRemedy_Name
Remedy_Name = %SRemedy_Name%
IniWrite, %Remedy_Name%, %preferencesini%, Agent, remedy_name
GuiControlGet, SEmail_Name
Email_Name = %SEmail_Name%
IniWrite, %Email_Name%, %preferencesini%, Agent, email_name
GuiControlGet, SAgent_Initials
Agent_Initials = %SAgent_Initials%
IniWrite, %Agent_Initials%, %preferencesini%, Agent, initials
GuiControlGet, Sagent_first_name
agent_first_name = %Sagent_first_name%
IniWrite, %agent_first_name%, %preferencesini%, Agent, first_name
GuiControlGet, ST2_queue
T2_queue = %ST2_queue%
IniWrite, %T2_queue%, %preferencesini%, Agent, t2_queue
GuiControlGet, SAgent_Title
Agent_Title = %SAgent_Title%
IniWrite, %Agent_Title%, %preferencesini%, Agent, agent_title
GuiControlGet, Swip_work_log_entry
wip_work_log_entry = %Swip_work_log_entry%
IniWrite, %Swip_work_log_entry%, %preferencesini%, Agent, wip_work_log_entry
GuiControlGet, Sqc_signature
qc_signature = %Sqc_signature%
IniWrite, %qc_signature%, %preferencesini%, Agent, qc_signature
GuiControlGet, SStored_Email
Stored_Email = %SStored_Email%
IniWrite, %SStored_Email%, %preferencesini%, Agent, Stored_Email
GuiControlGet, Savailable_HK
available_HK = %Savailable_HK%
IniWrite, %Savailable_HK%, %preferencesini%, Hotkeys, available
GuiControlGet, Savailable_w_TP_HK
available_w_TP_HK = %Savailable_w_TP_HK%
IniWrite, %Savailable_w_TP_HK%, %preferencesini%, Hotkeys, available_w_TP
GuiControlGet, Savailable_no_acd_HK
available_no_acd_HK = %Savailable_no_acd_HK%
IniWrite, %Savailable_no_acd_HK%, %preferencesini%, Hotkeys, available_no_acd
GuiControlGet, Scallers_tickets_HK
callers_tickets_HK = %Scallers_tickets_HK%
IniWrite, %Scallers_tickets_HK%, %preferencesini%, Hotkeys, callers_tickets
GuiControlGet, Semail_caller_HK
email_caller_HK = %Semail_caller_HK%
IniWrite, %Semail_caller_HK%, %preferencesini%, Hotkeys, email_caller
GuiControlGet, Sresolve_qc_HK
resolve_qc_HK = %Sresolve_qc_HK%
IniWrite, %resolve_qc_HK%, %preferencesini%, Hotkeys, resolve_qc
GuiControlGet, Swip_ticket_HK
wip_ticket_HK = %Swip_ticket_HK%
IniWrite, %wip_ticket_HK%, %preferencesini%, Hotkeys, wip_ticket
GuiControlGet, St2_day1_HK
t2_day1_HK = %St2_day1_HK%
IniWrite, %t2_day1_HK%, %preferencesini%, Hotkeys, t2_day1
GuiControlGet,  St2_day2_HK
t2_day2_HK = %St2_day2_HK%
IniWrite, %t2_day2_HK%, %preferencesini%, Hotkeys, t2_day2
GuiControlGet, St2_day4_HK
t2_day4_HK = %St2_day4_HK%
IniWrite, %t2_day4_HK%, %preferencesini%, Hotkeys, t2_day4
GuiControlGet, Sactivate_outlook_HK
activate_outlook_HK = %Sactivate_outlook_HK%
IniWrite, %Sactivate_outlook_HK%, %preferencesini%, Hotkeys, activate_outlook
GuiControlGet, Sactivate_remedy_HK
activate_remedy_HK = %Sactivate_remedy_HK%
IniWrite, %Sactivate_remedy_HK%, %preferencesini%, Hotkeys, activate_remedy
GuiControlGet, Scall_highlighted_HK
call_highlighted_HK = %Scall_highlighted_HK%
IniWrite, %call_highlighted_HK%, %preferencesini%, Hotkeys, call_highlighted
GuiControlGet, Scall_phone_HK
call_phone_HK = %Scall_phone_HK%
IniWrite, %call_phone_HK%, %preferencesini%, Hotkeys, call_phone
GuiControlGet, Scall_cell_HK
call_cell_HK = %Scall_cell_HK%
IniWrite, %call_cell_HK%, %preferencesini%, Hotkeys, call_cell
GuiControlGet, ST2_Day1_subject
T2_Day1_subject = %ST2_Day1_subject%
IniWrite, %T2_Day1_subject%, %preferencesini%, TierIIEmails, T2_Day1_subject
GuiControlGet, ST2_Day1_Email
StringReplace, ST2_Day1_Email, ST2_Day1_Email, `n, <n>, All
StringReplace, ST2_Day1_Email, ST2_Day1_Email, `r, <r>, All
T2_Day1_Email = %ST2_Day1_Email%
IniWrite, %T2_Day1_Email%, %preferencesini%, TierIIEmails, T2_Day1_Email
GuiControlGet, ST2_Day2_subject
T2_Day2_subject = %ST2_Day2_subject%
IniWrite, %T2_Day2_subject%, %preferencesini%, TierIIEmails, T2_Day2_subject
GuiControlGet, ST2_Day2_Email
StringReplace, ST2_Day2_Email, ST2_Day2_Email, `n, <n>, All
StringReplace, ST2_Day2_Email, ST2_Day2_Email, `r, <r>, All
T2_Day2_Email = %ST2_Day2_Email%
IniWrite, %T2_Day2_Email%, %preferencesini%, TierIIEmails, T2_Day2_Email
GuiControlGet, ST2_Email_Signature
StringReplace, ST2_Email_Signature, ST2_Email_Signature, `n, <n>, All
StringReplace, ST2_Email_Signature, ST2_Email_Signature, `r, <r>, All
T2_Email_Signature = %ST2_Email_Signature%
IniWrite, %T2_Email_Signature%, %preferencesini%, TierIIEmails, T2_Email_Signature





;Save_Finished is to help ensure that the Gui does not get destroyed until the Program has finished saving the settings.
IniWrite, 1, %preferencesini%, GUI, Save_Finished

;HotKey Global Listeners
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_HK%, Available_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_w_TP_HK%, AvailablewTP_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %available_no_acd_HK%, available_no_acd_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %callers_tickets_HK%, callers_tickets_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %email_caller_HK%, Email_Customer
Hotkey, IfWinActive, BMC Remedy User - [CITS Service Management
Hotkey, %resolve_qc_HK%, AssignToAgent_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %wip_ticket_HK%, wip_ticket_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day1_HK%, t2_day1_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day2_HK%, t2_day2_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %t2_day4_HK%, t2_day4_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %activate_remedy_HK%, activate_remedy
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %activate_outlook_HK%, activate_outlook
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_highlighted_HK%, call_highlighted_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_phone_HK%, call_phone_HK
Hotkey, IfWinNotActive, %program_title% Settings
Hotkey, %call_cell_HK%, call_cell_HK

Gui 1: +AlwaysOnTop
If %alwaysOnTop% = 0
  {
  Gui 1: -AlwaysOnTop
  }

Return


; Functions
;Ticket Tab Function
TabTo(going_to, comeing_from)
{
if (going_to > comeing_from){
tabnum := going_to - comeing_from
  Send, {TAB %tabnum%}
  }
else{
tabnum := comeing_from - going_to
  Send, +{TAB %tabnum%}
  }
}

; Change Interaction Client Mode
ChangeMode(changeto)
{
Send #c
WinWait, Interaction Client: .NET Edition,
IfWinNotActive, Interaction Client: .NET Edition, , WinActivate, Interaction Client: .NET Edition,
WinWaitActive, Interaction Client: .NET Edition,
Send !s {TAB}{ENTER}
WinWait,  ahk_class WindowsForms10.Window.8.app.0.33c0d9d,
IfWinNotActive,  ahk_class WindowsForms10.Window.8.app.0.33c0d9d, , WinActivate,  ahk_class WindowsForms10.Window.8.app.0.33c0d9d,
WinWaitActive,  ahk_class WindowsForms10.Window.8.app.0.33c0d9d,
Send,{TAB %status_drop_down%}{HOME}{DOWN %changeto%}{TAB 2}{ENTER}
}

;Dial Number
Dial()
{
Sleep, 450
Send, #c
Sleep, 100
Send, !n
Sleep, 100
Send, ^v
Sleep, 450
Send, {ENTER}
}


If you need me to explain anything just let me know... You should know that I don't consider myself a programmer, I tend to just patch things together, so I fully anticipate red marks all over my work :)

Thanks,
Sam


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2010, 8:58 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
I will definitely look further than this for you, but first thing is first (and please forgive as I don't mean to be picky)... you can use OTB if you want, but your bracing is inconsistent. The rule here AFAIK is to use whatever styling works best but you do need to have a consistent styling... it makes it much easier for you (or others!) to read, example:

Code:
; Functions
;Ticket Tab Function
TabTo(going_to, comeing_from)
{
if (going_to > comeing_from){
tabnum := going_to - comeing_from
  Send, {TAB %tabnum%}
  }
else{
tabnum := comeing_from - going_to
  Send, +{TAB %tabnum%}
  }
}

Rewritten as: (spelling fixed ;) )

Code:
Tabto(going_to, coming_from)
{
   If going_to > coming_from
   {
      TabNum := going_to - coming_from
      Send (TAB %tabnum%}
   }
   Else
   {
      Tabnum := coming_from - going_to
      Send +{Tab %tabnum%}
   }
}


If you aren't using SCITE4AUTOHOTKEY I highly recommend it.

Next, you have a TON of INIread, INIwrite, etc, which when I got into INI files last week started driving me crazy. So I wrote these functions to let me work easier with INI files, and sure these don't differ a lot from the actual commands but as I use a console now to log program action to these are much easier. They also allow you to easily take any particular action (such as backing up the INI, if you wanted) each time the file is written to.

I am also including my console GUI bit and the Cadd() function. My current project is the first time that I've used a console like this but it makes it VERY easy to determine what is going on inside your program. I am also including INIrefresh() which is how I go through my INI to find all of the keys to populate them to a list. These also allow you to assign keys to variable pretty easily,

Code:
MyVariable := INIget(mysection, mykey)


Will post more... let me know what you think. You don't HAVE to use any of this stuff by any stretch but the console has made my development of what I'm currently working on MUCH easier/faster.


Code follows:

Code:
;CONSOLE CONTROLS
Cadd(text)
{
   global
   FormatTime, NowStamp, %A_now%, HH:mm:ss
   text := NowStamp . " " . text
   Ctext := text . "`n" . Ctext ;newest lines on top of course
   GuiControl,1:, Ctext, %Ctext%   
}

Cclear()
{
   global
   Ctext := ""
   GuiControl,, Ctext, %Ctext%
}

Cexport(filename = 0)
{
   Global Ctext
   If !filename
   {    
      filename := a_scriptdir . "\ConsoleExport" . A_now . ".txt"
   }
   
   FileAppend, %Ctext%, %filename%
   Run, Notepad.exe %filename%
   
   Return
}





;LOG CONSOLE GUI
Gui, Add, Edit, x220 y50 w400 h200 vCtext hScroll
Gui, Add, Button, gCexport y+5 x+-200, EXPORT





;functions for working with ini files
INIget(section, key)
{
   global inipath
   INIread, value, %inipath%, %section%, %key%
   ;INIread has no error level, instead it sets the output to the word 'error'
   If Value = ERROR
   {
      s := "INIget() failed. Section: " . section . " Key: " . key
      Cadd(s)
      Return 0
   }

   s := "INIget() success. Section: " . section . " Key: " . key . " Value: " . value
   Cadd(s)

   Return value
   
}

INIdelete(section, key = 0)
{
   global INIpath
   If Key
   {
      IniDelete, %INIpath%, %Section%, %key%
      If Errorlevel
      {
         s := "INIdelete() FAILURE. Section: " . section . " Key: " . key . " ErrorLevel: " . ErrorLevel
         Cadd(s)
         Return 0
      }   
      Else
      {
         s := "INIdelete() success. Section: " . section . " Key: " . key . " ErrorLevel: " . ErrorLevel
         Cadd(s)
         Return 1
      }
   }
   Else
   {
      IniDelete, %inipath%, %section%
      If Errorlevel
      {
         s := "INIdelete() FAILURE. Section: " . section . " Key: " . key . " ErrorLevel: " . ErrorLevel
         Cadd(s)
         Return 0
      }   
      Else
      {
         s := "INIdelete() success. Section: " . section . " Key: " . key . " ErrorLevel: " . ErrorLevel
         Cadd(s)
         Return 1
      }
   }
}

INIsave(section, key, value)
{
   global inipath
   INIwrite, %value%, %inipath%, %section%, %key%
   If ErrorLevel
   {
      s := "INIsave() FAILED. Section: " . section . " Key: " . key . " Value: " . value
      Cadd(s)
      Return 0
   }
   
   s := "INIsave() Section: " . section . " Key: " . key . " Value: " . value
   Cadd(s)
   Return 1
   
}

INIrefresh()
{
   global
   section := ""
   ReportList := ""
   FileRead, INIdata, %INIpath%
   If ErrorLevel
   {
      Cadd("INIrefresh() FAILED on file read!")
      Return 0
   }
   
   Loop, Parse, INIdata, `n ;working
   {
      ;msgbox %A_loopfield%
      If A_LoopField contains [
      {
         StringTrimRight, Section, A_LoopField, 2
         ;Section := Section ;autotrim?
         StringTrimLeft, Section, Section, 1
         ;here goes the code to construct an `n delimited string of the saved report names
         ReportList := ReportList . Section . "|" ;gui listbox is pipe delimited
      }
   }
   
   GuiControl,1:, ReportNames, |
   GuiControl,1:, ReportNames, %ReportList%
   Cadd("INI REFRESHED")
Return

}


Last edited by randallf on April 21st, 2010, 10:12 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2010, 9:37 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
I had written a big long reply that the forum code stole from me upon trying to copy what I had written :( I will go through again but no time ATM...

My end question, however, is what problems are you having when you try to move to another users system? It would help a lot to know what the problem labels or functions seem to be.

As to your first post, don't use comments in this way:

Code:
Clipboard = ;

;Try

Clipboard := ""

;to zero the clipboard


I have got weird comments or other code appearing in my scripts before, my other initial advice on that is to go through and fix all of your bracing/formatting so that it looks clean and you can tell if you missed anything. A context-specific editor might help a lot too, not sure what you are currently using but again SCITE4AUTOHOTKEY is the best I've found so far. Work is being done on an AHK IDE however.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Scite4AutoHotKey v2?
PostPosted: April 22nd, 2010, 7:59 pm 
Offline

Joined: September 29th, 2009, 1:02 pm
Posts: 75
I had been using PSPAD with the AutoHotKey plugin. I downloaded and installed Scite4AutoHotkey v2 (Does this one have the same "formatting assistance" you were referring to?) I do like the included AutoHotkey editors that were included with it to help with doing GUIs and MSG boxes and such. Also do you know if it should auto correct my file for syntax related issues?

I have had to work Tier2 all day today so have not had any free time to try and use anything else you have provided yet.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 3:03 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
I have worked with a few system via Citrix that allow only text entry, I found that one way to verify entry on a field was to use pixel detection after typing a certain character. If this is not possible I would try to determine the maximum possible delay and adjust speed appropriately. One thing that made that easier on me was to time it with Sleep %LongDelay%, Sleep %ShortDelay% etc and then adjust those variables as necessary.

SciTE does have syntax highlighting. Unfortunately I haven't found a feature rich editor that has AHK-specific syntax highlighting. (that is good)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group