View Single Post
Old 7th June 2014, 23:10   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,280
Quote:
!include LogicLib.nsh
!include Win\COM.nsh
!include Win\PropKey.nsh
/*
72c24dd5-d70a-438b-8a42-98424b88afb8 CLSID_WshShell
F935DC21-1CF0-11d0-ADB9-00C04FD58A0B IWshShell
24BE5A30-EDFE-11d2-B933-00104B365C9F IWshShell2
41904400-BE18-11d3-A28B-00104BD35090 IWshShell3
*/
${NSISCOMIFACEDECL}IWshShell2 AppActivate 17 (i,i,*i)i
${NSISCOMIFACEDECL}IWshShell2 SendKeys 18 (i,i)i
System::Call 'OLE32::CLSIDFromProgID(w "WScript.Shell",g.r1)i.r0'
!insertmacro ComHlpr_CreateInProcInstance $1 "{24BE5A30-EDFE-11d2-B933-00104B365C9F}" r0 ""
${If} $0 <> 0
System::Call 'OLEAUT32::SysAllocString(w "Calculator")i.r9'
System::Call '*${SYSSTRUCT_PROPVARIANT}(${VT_BSTR},,ir9)i.r1'
System::Call '*${SYSSTRUCT_PROPVARIANT}(${VT_BOOL},,${VARIANT_TRUE})i.r2'
StrCpy $5 0
startedapp:
${IWshShell2::AppActivate} $0 '(r1,r2,${VARIANT_FALSE}r3)i.r4'
${If} $3 <> ${VARIANT_FALSE}
${AndIf} $4 = 0
System::Call 'OLEAUT32::SysFreeString(ir9)'
System::Call 'OLEAUT32::SysAllocString(w "1 + 2 =")i.r9' ; Do some calculation
${IWshShell2::SendKeys} $0 '(r9,r2)i.r4'
${Else}
Exec calc.exe
Sleep 1111
IntOp $5 $5 + 1
IntCmpU $5 1 "" "" +2
goto startedapp
${EndIf}
System::Call 'OLEAUT32::SysFreeString(ir9)'
System::Free $2
System::Free $1
${IUnknown::Release} $0 ""
${EndIf}
but NSIS is not the best UI automation tool, you should try AutoIt or some other tool...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote