etay
asked on
msscript.ocx with atl problem
I have this code in vbs:
set WshShell = WScript.CreateObject("WScr ipt.Shell" )
WshShell.AppActivate (" - Conversation")
WshShell.SendKeys ("check")
WshShell.SendKeys ("{ENTER}")
i need to write in c++ with atl. i tried the following:
bstr_t bstrLanguage(L"VBScript");
_bstr_t bstrCode1(L"set WshShell = WScript.CreateObject(\"WSc ript.Shell \")\n");
_bstr_t bstrCode2(L"WshShell.AppAc tivate (\" - Conversation\")\n");
_bstr_t bstrCode3(L"WshShell.SendK eys (\"check\") \n");
_bstr_t bstrCode4(L"WshShell.SendK eys (\"{ENTER}\")\n");
IScriptControlPtr spScriptCtl(__uuidof(Scrip tControl)) ;
spScriptCtl->put_Language( bstrLangua ge);
spScriptCtl->AddCode(bstrC ode1);
spScriptCtl->AddCode(bstrC ode2);
spScriptCtl->AddCode(bstrC ode3);
spScriptCtl->AddCode(bstrC ode4);
this generates an error ( the vbs script works fine).
how to fix it?
set WshShell = WScript.CreateObject("WScr
WshShell.AppActivate (" - Conversation")
WshShell.SendKeys ("check")
WshShell.SendKeys ("{ENTER}")
i need to write in c++ with atl. i tried the following:
bstr_t bstrLanguage(L"VBScript");
_bstr_t bstrCode1(L"set WshShell = WScript.CreateObject(\"WSc
_bstr_t bstrCode2(L"WshShell.AppAc
_bstr_t bstrCode3(L"WshShell.SendK
_bstr_t bstrCode4(L"WshShell.SendK
IScriptControlPtr spScriptCtl(__uuidof(Scrip
spScriptCtl->put_Language(
spScriptCtl->AddCode(bstrC
spScriptCtl->AddCode(bstrC
spScriptCtl->AddCode(bstrC
spScriptCtl->AddCode(bstrC
this generates an error ( the vbs script works fine).
how to fix it?
What's the error it reports ?
Hi,
msscript.ocx seems an unstable little thing to me regarding this article ---> http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q315922
Anyway, just as an approach:
When you use this function in c++:
function StartCalc()
{
var WshShell = new ActiveXObject("WScript.She ll");
var oExec = WshShell.Exec("calc");
WshShell = null;
}
... you'll get the calculator going ... but from design this looks a little different to your code!
I can not test this right now, but why not trying:
function StartConversation()
{
var WshShell = new ActiveXObject("WScript.She ll");
var oExec1 = WshShell.AppActivate(" - Conversation");
var oExec2 = WshShell.SendKeys("check") ;
var oExec3 = WshShell.SendKeys("{ENTER} ");
WshShell = null;
}
Best regards, Raisor
msscript.ocx seems an unstable little thing to me regarding this article ---> http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q315922
Anyway, just as an approach:
When you use this function in c++:
function StartCalc()
{
var WshShell = new ActiveXObject("WScript.She
var oExec = WshShell.Exec("calc");
WshShell = null;
}
... you'll get the calculator going ... but from design this looks a little different to your code!
I can not test this right now, but why not trying:
function StartConversation()
{
var WshShell = new ActiveXObject("WScript.She
var oExec1 = WshShell.AppActivate(" - Conversation");
var oExec2 = WshShell.SendKeys("check")
var oExec3 = WshShell.SendKeys("{ENTER}
WshShell = null;
}
Best regards, Raisor
ASKER
regarding first comment it return an iexplore error reported in the visual studio debug view. & the code itself is not running.
regarding the seond comment , i think you missed the main problem; the problem is not in the vbscript itself but with the VC++ ATL implementing it. javascript wont solve this.
the vb script you have here will add "check" string & send it to any open conversation in the msn messenger.
the purpose of the vc code is to automate this withput vbs file.
regarding the seond comment , i think you missed the main problem; the problem is not in the vbscript itself but with the VC++ ATL implementing it. javascript wont solve this.
the vb script you have here will add "check" string & send it to any open conversation in the msn messenger.
the purpose of the vc code is to automate this withput vbs file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah, I see this is interacting with MSN - okay I just tried the amended code which sent the word check into messenger and then "pressed" return - all works fine here with the amended code
ASKER
thanks purpleblob,
it works.
it works.
Glad to have helped