AutoHotkey Community

It is currently May 26th, 2012, 4:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: March 19th, 2009, 4:13 pm 
Offline

Joined: September 19th, 2008, 9:07 pm
Posts: 15
Hi,
Could someone tell my if I can send a command to skype using the Skype APi client script (http://www.autohotkey.com/forum/topic36712.html), without opening the GUI?
Example:

If I want to send the command: "set userstatus DND"


Thank You
Vega


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Yes I think
PostPosted: March 19th, 2009, 11:08 pm 
Offline

Joined: June 18th, 2006, 8:47 am
Posts: 346
Location: Phoenix, AZ
It should work if the window is hidden or Minimized if i understand what I read here. http://www.autohotkey.com/docs/misc/SendMessage.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2009, 4:58 pm 
Offline

Joined: August 9th, 2007, 10:18 am
Posts: 11
Try this.
I've changed my code from "http://www.autohotkey.com/forum/topic36712.html&highlight=skype+api" to be GUI-less, or better, to leave the GUI invisible:

Code:

;---------------------------------------------------------------------------
; Define constants
;---------------------------------------------------------------------------
SKYPECONTROLAPI_ATTACH_SUCCESS               = 0
SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1
SKYPECONTROLAPI_ATTACH_REFUSED               = 2
SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE         = 3
SKYPECONTROLAPI_ATTACH_API_AVAILABLE         = 0x8001
WM_COPYDATA = 0x4a


;---------------------------------------------------------------------------
; Register Skype messages
;---------------------------------------------------------------------------
SkypeControlAPIDiscover := DllCall( "RegisterWindowMessage", Str,"SkypeControlAPIDiscover" )
SkypeControlAPIAttach := DllCall( "RegisterWindowMessage", Str,"SkypeControlAPIAttach" )

;---------------------------------------------------------------------------
; Invisible GUI
;---------------------------------------------------------------------------
Gui, Show, x0 y0 h0 w0

    ;---------------------------------------------------------------------------
    ; Obtain id of (this) client window
    ;---------------------------------------------------------------------------
    hGui := WinExist("A")

    OnMessage(SkypeControlAPIAttach, "SkypeAttach")
    OnMessage(WM_COPYDATA, "SkypeReceive")

    SendMessage, SkypeControlAPIDiscover, hGui,,, ahk_id 0xFFFF 
Return


;---------------------------------------------------------------------------
; Writes text to the Skype API by sending WM_COPYDATA message
;---------------------------------------------------------------------------
writeApi(textToWrite) {

    global

    ;---------------------------------------------------------------------------
    ; Escape if Skype API is not available
    ;---------------------------------------------------------------------------
    If !hSKYPE_API
        Return

    ;---------------------------------------------------------------------------
    ; Fill the CopyDataStruct structure to be sent by WM_COPYDATA
    ;---------------------------------------------------------------------------
    DetectHiddenWindows On
    SetTitleMatchMode 2

    VarSetCapacity(CopyDataStruct, 12, 0)  ; Set up the structure's memory area.
    NumPut(StrLen(textToWrite) + 1, CopyDataStruct, 4)  ; OS requires that this be done.
    NumPut(&textToWrite, CopyDataStruct, 8)  ; Set lpData to point to the string itself.

    ;---------------------------------------------------------------------------
    ; Issue WM_COPYDATA message to Skype API
    ;---------------------------------------------------------------------------
    SendMessage, WM_COPYDATA, hGui, &CopyDataStruct,, ahk_id %hSKYPE_API%
}


;---------------------------------------------------------------------------
; This function is invoked upon incoming SkypeControlAPIAttach message
;---------------------------------------------------------------------------
SkypeAttach(wParam, lParam, msg, hwnd) {

    global

    ;---------------------------------------------------------------------------
    ; The Skype API handle is returned with WPARAM, if successfully attached
    ;---------------------------------------------------------------------------
    If (lParam = SKYPECONTROLAPI_ATTACH_SUCCESS)
        hSKYPE_API := wParam
}


;---------------------------------------------------------------------------
; This function is invoked upon incoming WM_COPYDATA message
; It is the sample on the bottom of the OnMessage() help page
;---------------------------------------------------------------------------
SkypeReceive(wParam, lParam) {


    ;---------------------------------------------------------------------------
    ; This is the address of CopyDataStruct's lpData member
    ;---------------------------------------------------------------------------
    lpDataAddress := lParam + 8  ; .
    lpData := 0

    ;---------------------------------------------------------------------------
    ; For each byte in the lpData integer
    ;---------------------------------------------------------------------------
    Loop 4  ; For each byte in the lpData integer
    {
        ;---------------------------------------------------------------------------
        ; Build the integer from its bytes
        ;---------------------------------------------------------------------------
        lpData := lpData | (*lpDataAddress << 8 * (A_Index - 1))
        ;---------------------------------------------------------------------------
        ; Move on to the next byte
        ;---------------------------------------------------------------------------
        lpDataAddress += 1
    }

    ;---------------------------------------------------------------------------
    ; lpData contains the address of the string to be copied
    ; (must be a zero-terminated string)
    ;---------------------------------------------------------------------------
    DataLength := DllCall("lstrlen", UInt, lpData)
    If DataLength <= 0
        msgbox blank received
    Else
    {
        VarSetCapacity(textReceived, DataLength)
        DllCall("lstrcpy", "str", textReceived, "uint", lpData)  ; Copy the string out of the structure.
        msgbox % textReceived
    }

    Return true
}



Use the writeApi("set userstatus DND") function to send out your command, and find received messages in "SkypeReceive".


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 20th, 2009, 10:06 pm 
Offline

Joined: June 20th, 2009, 10:03 pm
Posts: 13
This is an old thread, but is anyone using this? Could someone provide an example of a script that uses this API (ie: dial phone number on the clipboard?)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Miguel, notsoobvious, Yahoo [Bot] and 11 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