AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] ControlSend interfering with keystrokes.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
drmartell



Joined: 23 Feb 2008
Posts: 19

PostPosted: Sat Oct 31, 2009 12:06 am    Post subject: [SOLVED] ControlSend interfering with keystrokes. Reply with quote

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 Thu Nov 05, 2009 2:31 am; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Oct 31, 2009 12:26 am    Post subject: Reply with quote

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
Back to top
drmartell



Joined: 23 Feb 2008
Posts: 19

PostPosted: Wed Nov 04, 2009 7:26 pm    Post subject: Reply with quote

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! Sad

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 . . .
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Nov 04, 2009 8:35 pm    Post subject: Reply with quote

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
Back to top
drmartell



Joined: 23 Feb 2008
Posts: 19

PostPosted: Wed Nov 04, 2009 10:26 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
drmartell



Joined: 23 Feb 2008
Posts: 19

PostPosted: Thu Nov 05, 2009 2:32 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group