AutoHotkey Community

It is currently May 26th, 2012, 7:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 23, 24, 25, 26, 27, 28, 29 ... 44  Next
Author Message
 Post subject:
PostPosted: May 10th, 2009, 5:28 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Mustang wrote:
What would you suggest for communication between an AHK script and a virtual com port then?

Serial ( COM ) Port Console Script


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 5:50 am 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
I'm not sure if it's due to being a virtual port rather than physical
But running this script gives an error:
Serial ( COM ) Port Console Script wrote:
There is a problem with Serial Port communication.
Failed Dll BuildCommDCB, BCD_Result=0
The Script Will Now Exit.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 6:12 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Mustang wrote:
What would you suggest for communication between an AHK script and a virtual com port then?
I meant that no need to update it, just call them with COM_Invoke().
Code:
COM_Init()
pcomm := COM_CreateObject("MSCommLib.MSComm")

MsgBox, % nCommID := COM_Invoke(pcomm, "CommID")
; COM_Invoke(pcomm, "CommID", nCommID)
MsgBox, % nCommPort := COM_Invoke(pcomm, "CommPort")
; COM_Invoke(pcomm, "CommPort", nCommPort)

COM_Release(pcomm)
COM_Term()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 8:30 am 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
I was originally struggling to find a copy of CoHelper with the DispParams function

But trying out the code posted above hits me with this:
COM Error Notification wrote:
Function Name: "CommID"
ERROR: The COM Object may not be a valid Dispatch Object!
First ensure that COM Library has been initialized through COM_Init()
()

And the same message for CommPort

Infact COM_CreateObject returns a value of 0


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 11:15 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
Mustang wrote:

Infact COM_CreateObject returns a value of 0



then you've not created an object so nothing for invoke to call...


likely need proper/better ID for the com object you want to use.

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 3:37 pm 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
Yes it would seem to be the case
As I say, I'm trying to get Sean's example to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 8:55 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
have you researched the object or the subject generally ?

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2009, 1:50 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
You don't have mscomm32.ocx, do you?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2009, 6:11 am 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
I did have it, but it wasn't registered
Now it is and now COM_CreateObject returns a pointer value
:D

However
nCommID returns -1
and
nCommPort returns 1

Trying to pass nCommPort, or a manually assigned value into the final invoke returns a blank msgbox


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2009, 11:03 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Mustang wrote:
Trying to pass nCommPort, or a manually assigned value into the final invoke returns a blank msgbox
PropertyPut has no return value. Try instead:
Code:
COM_Invoke(pcomm, "CommPort", nCommPort)
MsgBox, % COM_Invoke(pcomm, "CommPort")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2009, 2:54 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
The role of "-0" is changed from Null to the strict Missing parameter. Details in the top post.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2009, 1:47 pm 
Offline

Joined: May 27th, 2009, 10:44 pm
Posts: 17
A little error:
Code:
 COM_Unicode4Ansi(ByRef wString, sString, nSize = "")
    {
        If (nSize = "")
            nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
       ; VarSetCapacity(wString, nSize * 2 + 1)    ;Wrong
        VarSetCapacity(wString, (nSize+1) * 2)     ;Right, i think
        DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1)
        Return    &wString
    }

By YMP, script-coding.info.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2009, 1:57 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
VarSetCapacity ensures the variable can hold at least RequestedCapacity bytes, "in addition to its internal terminator". Since the internal terminator is one byte, Sean's code is correct.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2009, 7:24 pm 
Offline

Joined: May 27th, 2009, 10:44 pm
Posts: 17
Sorry :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2009, 1:03 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
garkin wrote:
Sorry :oops:
Doubt about yourself first, especially when you're a newbie.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 23, 24, 25, 26, 27, 28, 29 ... 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Xx7, 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