AutoHotkey Community

It is currently May 25th, 2012, 3:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: August 2nd, 2007, 10:49 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade

_________________
Image


Last edited by majkinetor on August 10th, 2009, 2:43 pm, edited 23 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 11:19 am 
A Chat ! :shock:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 11:52 am 
Un chat ! :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 10:30 pm 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
This is an excellant example of WM_COPYDATA!!! :)
Script to script communication has been asked frequently-- & this function couldn't be easier to use!

Thanks for wrapping this functionality up so neatly (as always..). Its also nice seeing you pop up in the forum again.. evan if only briefly :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 1:20 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2541
Nice example :)

BoBo¨ wrote:
A Chat ! :shock:
If you like talking to yourself... ;)

MoMo wrote:
Un chat ! :D
:shock: n'est pas un chat...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 11:25 pm 
And the english chat comes from the french word tchatche and from the verb tchatcher which is popular language comming for south of France and which means to speak a lot. This word come itself from the spanish verb chacharear, which was transformed by the algerian slang to become the french verb tchatcher... So nothing to see with the french chat, which is ... an english cat... What else ? Only that : thank to majkinetor, the (big) blue and purple cat, with long teeth, for this (again) good script.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2007, 7:54 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2541
MoMo wrote:
And the english chat comes from the french word tchatche and from the verb tchatcher which is popular language comming for south of France and which means to speak a lot. This word come itself from the spanish verb chacharear, which was transformed by the algerian slang to become the french verb tchatcher... So nothing to see with the french chat, which is ... an english cat... What else ? Only that : thank to majkinetor, the (big) blue and purple cat, with long teeth, for this (again) good script.
pussy != talking
Nice try though... :lol: :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Just a little add-on
PostPosted: August 18th, 2007, 5:36 am 
I don't know if there is any others way to do the communication between 2 app without any GUI, but there is a little function that activate the onMessageHandler with a completely invisible GUI.

this function is meant to be used with the IPC.ahk file.

Code:
IPC_OnMessageNoGui( pLabel ) {
   Gui +LastFound -AlwaysOnTop -Caption +ToolWindow
   Gui, Show   
   IPC_OnMessage(pLabel)
}


I know its very simple, but well, it may help some people.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2008, 11:54 pm 
Does your script require GUI majkinetor?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2008, 12:14 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
No, you can use a message-only window. But that requires some coding. IIRC, some scripts on the forum create them.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2008, 11:48 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
You could use the script's main window...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2008, 4:04 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I was asking myself once, is it smart to subclass main window of AHK. Due to the fact that ahk proc is called for every message, it can probably reduce performance of the script. I am not sure about this though, but it seems logical. I was always hesistant to subclass wndproc in AHK.

He can also use CreateWindowEx to create hidden control and subclass it, in which case it will not receive large number of messages. Then it can receive IPC messages.

_________________
Image


Last edited by majkinetor on January 30th, 2008, 6:46 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2008, 6:26 pm 
majkinetor wrote:
He can also use CreateWindowEx to create hidden control and subclass it, in which case it will not receive large number of messages. Then it can receive IPC messages.
I'm a noob but very interested by IPC. Can you please give us an example ? Thanks by advance.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2008, 10:20 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
majkinetor wrote:
I was asking myself once, is it smart to subclass main window of AHK.
No. The biggest problem is perhaps that ListLines becomes unusable since interacting with the main window executes script. There's no need to subclass the window anyway.

Creating a message window is only of benefit in the off chance that some other part of the script uses OnMessage(WM_COPYDATA).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 1:22 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
There's no need to subclass the window anyway.

Ah, yes.... there is no need for this in this case, thx for the note.

Quote:
I'm a noob but very interested by IPC. Can you please give us an example ? Thanks by advance.

This is a sample of server and client. Client asks for some information that require some time to be calculated (like db access). Client can ask for new information again, before server finishes previous one. Server buffers requests, and sends them back as soon as it calculates. Ports are used as transaction IDs so this can work ok for 2^32 transactions.

This approach was needed because IPC doesn't use PostMessage to send WM_COPYDATA, but SendMessage which waits. PostMessage can't be used with WM_COPYDATA.

Server.ahk
Code:
#SingleInstance, off   ;allow multiple instances

   target := "Klijent"

   Gui, +LastFound     +AlwaysOnTop
   hScript := WinExist()
   
   Gui, Font, s8
   Gui, Add, ListBox,xm   w350 h300 vMyLB,

   Gui, Show,   x600 AutoSize

   IPC_OnMessage("OnMessage")
return

OnMessage:
    GuiControl, , MyLB, %IPC_Port% : %IPC_Message%
   buf .= IPC_PORT " "
   aMessage_%IPC_PORT% := IPC_Message
   if !Timer
   {
      SetTimer, DBGet, -50
      Timer := true
   }
return

DBGet:
   loop
   {
      j := InStr(buf, " "),  port := SubStr(buf, 1, j-1), buf := SubStr(buf, j+1)
       msg := aMessage_%port%

       data := SQLGetData(msg)
       IPC_Send(WinExist(target), data, port)
      
      IfEqual, buf,, break
   }
   Timer := false
return


SQLGetData(msg) {
   sleep 5000
   return "data for:  " msg
}

GuiClose:
   exitapp
return

#include IPC.ahk


Klijent.ahk
Code:
#SingleInstance, off   ;allow multiple instances

   target := "Server"

   Gui, +LastFound     +AlwaysOnTop
   hScript := WinExist()

   Gui, Font, s10
   Gui, Add, Edit,    vMyMsg  w310      , select * from table

   Gui, Font, s8
   Gui, Add, Button, x+5      gOnSend      , Send

   Gui, Add, ListBox,xm   w350 h300 vMyLB,

   Gui, Show,   x200 AutoSize

   port := 0
   IPC_OnMessage("OnMessage")
return

OnMessage:   
     GuiControl, , MyLB, %IPC_Port% : %IPC_Message%
return


OnSend:
   Gui, Submit, NoHide
   port++
   res := IPC_Send( WinExist( target ), MyMsg, port)
return

GuiClose:
   exitapp
return

#include IPC.ahk

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, JamixZol and 29 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