AutoHotkey Community

It is currently May 26th, 2012, 10:56 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: October 31st, 2009, 1:06 am 
Offline

Joined: February 23rd, 2008, 6:52 pm
Posts: 30
I'm sure there is a better way to do this. I have a script that helps me to automatically record phone calls using the ShoreTel Advanced Call Manager Software.

The keyboard shortcut in ShoreTel is Ctrl-Shift-r. The shortcut is only active when there is an active phone call.

So, I have a loop script that just sends the shortcut every 4 seconds.

However, during the moment that the script is active sending the shortcut, I get sporadic change of state of the control key and Caps Lock. I know that these side effects are mentioned in the help file, but I am not sure how to avoid them. SendInput didn't work either. . .

Code:
Menu, Tray, Icon, record.ico

Loop
{
Sleep, 4000
ControlSend, ,{CTRLDOWN}{SHIFTDOWN}r{SHIFTUP}{CTRLUP}, ShoreTel Advanced Call Manager,

ifwinexist, Escalation Notification Settings
{
Winclose, Escalation Notification Settings
}
}
Return


Last edited by drmartell on November 5th, 2009, 3:31 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2009, 1:26 am 
sending keystrokes to a client for every 4 second doesnt seem like a correct method
how about:
1. does the client window title change name or pop up some notice box when there is a call? (so u can use WinWait, IfWinExist)
2. if u are familiar with the ReadMemory address method, maybe u can find a static address that changes value when there is a phone call, and if the phone number is within the memory, in this case, u wont even need to send the hotkey, but store the value of the static address


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2009, 8:26 pm 
Offline

Joined: February 23rd, 2008, 6:52 pm
Posts: 30
Thanks for the reply,

I started playing with cheat engine to see if there was a memory address I could identify to easily determine whether a call is in progress. No success with that so far.

I now have new issue. We received an upgrade of the ShoreTel Call Manager software last night and now the script I have won't work at all.

Previously to turn recording on the shortcut was Ctrl-r and to turn it of the shortcut was Shift-Ctrl-r. In the latest version of the software, they have changed both shortcuts to Ctrl-r and they are not user configurable.

Now my existing script, which worked OK, just toggles recording on and off every 4 seconds! :(

Any suggested solutions for this?

I have been playing with MenuSpy trying to think of a way to read or send the recording command to the menu item, but it doesn't seem to return information for this particular program (it does for others).

There are no windows that pop up during a call and I also haven't been able to find anything that changes during a call that is detectable with WindowSpy.

Hmmmmmmm . . .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2009, 9:35 pm 
use Cheatening to search string text "There are no active calls at this time" address
see if its static
if it is, u can make a loop to check if that address has changed to another text, if yes, press the hotkey


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2009, 11:26 pm 
Offline

Joined: February 23rd, 2008, 6:52 pm
Posts: 30
Anonymous wrote:
use Cheatening to search string text "There are no active calls at this time" address
see if its static
if it is, u can make a loop to check if that address has changed to another text, if yes, press the hotkey


Good idea, I was not able to find that text, I was able to search my name and find a location that seems to reliably change from my name to another value during incoming and outgoing calls. I'm just not clear how to access it. Cheat Engine shows the value as: 08BB6B6B

Since this is the first I have really dealt with memory addresses, I don't understand the syntax.

For instance I can't yet read that address:

Code:
; Automatically closes handle when a new (or null) program is indicated
; Otherwise, keeps the process handle open between calls that specify the
; same program. When finished reading memory, call this function with no
; parameters to close the process handle i.e: "Closed := ReadMemory()"
ReadMemory(MADDRESS=0,PROGRAM="")
{
   Static OLDPROC, ProcessHandle
   VarSetCapacity(MVALUE,4,0)
   If PROGRAM != %OLDPROC%
   {
      WinGet, pid, pid, % OLDPROC := PROGRAM
      ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
      ,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
      ,"Int",16,"Int",0,"UInt",pid) : 0)
   }
   If (ProcessHandle) && DllCall("ReadProcessMemory","UInt"
   ,ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
   return *(&MVALUE+3)<<24 | *(&MVALUE+2)<<16 | *(&MVALUE+1)<<8 | *(&MVALUE)
   return !ProcessHandle ? "Handle Closed: " closed : "Fail"
}


value:=ReadMemory(08BB6B6B,"PCM.exe")
msgbox %value%


The above returns "Handle Closed:"

Another basic question, once I get this solved on my machine, will the memory location be the same on other machines?

UPDATE: the script calls for the Window Name, not the process name. changing "PCM.exe" to "ShoreTel Personal Call Manager" worked.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 3:32 am 
Offline

Joined: February 23rd, 2008, 6:52 pm
Posts: 30
thanks to IRC channel, here is full working script:

Code:
SetTitleMatchMode, 2
Menu, Tray, Icon, record.ico

; Automatically closes handle when a new (or null) program is indicated
; Otherwise, keeps the process handle open between calls that specify the
; same program. When finished reading memory, call this function with no
; parameters to close the process handle i.e: "Closed := ReadMemory()"
ReadMemory(MADDRESS=0,PROGRAM="")
{
   Static OLDPROC, ProcessHandle
   VarSetCapacity(MVALUE,4,0)
   If PROGRAM != %OLDPROC%
   {
      WinGet, pid, pid, % OLDPROC := PROGRAM
      ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
      ,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
      ,"Int",16,"Int",0,"UInt",pid) : 0)
   }
   If (ProcessHandle) && DllCall("ReadProcessMemory","UInt"
   ,ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
   return *(&MVALUE+3)<<24 | *(&MVALUE+2)<<16 | *(&MVALUE+1)<<8 | *(&MVALUE)
   return !ProcessHandle ? "Handle Closed: " closed : "Fail"
}

Loop
{
Sleep, 4000

value:=ReadMemory(0x08BB6B6B,"5949 - ShoreTel Call Manager")
if (value = 0)
{
WinWait, ShoreTel Call Manager,
IfWinNotActive, ShoreTel Call Manager, , WinActivate, ShoreTel Call Manager,
WinWaitActive, ShoreTel Call Manager,
SendInput, {CTRLDOWN}e{CTRLUP}
}
}
Return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, JSLover, Kirtman, Leef_me, Maestr0, Miguel, XstatyK and 59 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