WINCC脚本整理

合集下载

wincc 常用脚本

wincc 常用脚本

DeactivateRTProject ();//退出系统#pragma code("useadmin.dll")#include"PWRT_api.h"#pragma code()char* CUser=NULL;CUser=GetTagChar("@CurrentUser");if (strlen(CUser)==0){PWRTSilentLogin("operator","123456");//用户“operator",密码"123456”登录}OpenPicture("@MAIN.pdl");}在画面中结合不同按钮来组态下面 C 操作LoginAction for login (for example, "mouse click" event):#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');LogoutAction for logout (for example, "mouse click" event):#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogout();PWRTLogin 参数必须是CHAR 字符。

它指定了显示对话框的监视器。

如果只使用一个监视器,那么保留默认参数“c”或者指定“1”。

注意可以使用PASSLoginDialog 函数来代替PWRTLogin 或者PWRTLogout 函数。

这个函数需要和函数PWRTLogin 相同的参数。

wincc-全套脚本总结

wincc-全套脚本总结
"data_FLAG",1
)
}
-------------------------------------
——————7、对话框调用——————
BOOL A;
BOOL B;
}
// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END
return 0;
}
=====================================================
int value;
value=GetTagBit("IM_in");//"IM_in"为触发的变量。
if(value==1)
{
SetVisible("lianxi.pdl","按钮8",TRUE);//lianxi.pdl为控制对象所在画etVisible("lianxi.pdl","按钮8",FALSE);//lianxi.pdl
SetPropWord(lpszPictureName,"qushi","ValueAxisEndValue",Hi);
————————————————————————
——————4、获取位号————————
SetTagChar("TrendTagName1","ProcessValueArchive\\PT111");//Return-Type: BOOL

WINCC常用 脚本

WINCC常用 脚本
----------------------------------------------
11、在画面中显示用户名
1.组态静态文本
2.字体属性中的文本,连接系统变量@CurrentUser
----------------------------------------------
(2)新密码设置(C)
SetOutputValueChar(lpszPictureName,lpszObjectName,GetInputValueChar(lpszPictureName,lpszObjectName));
注:字符串格式的输入输出域》事件》属性主题》输出/输入》输出值》更改》以上代码。
{
MessageBox (Handle, "新密码和旧密码不能相同 !", "请重新输入密码", MB_OK |
MB_ICONEXCLAMATION | MB_SYSTEMMODAL);
}
else
{
// this 2 lines are necessary to get the DSN-Name of the project
a=MsgBox("hello!",vbYesNo)
If vbYes=a Then
objCon2.text="ok" '如点击是,则按钮文本变为ok
Else
objCon2.text="no" '如点击否,则按钮文本变为no
End If
注:放置按钮,起名按钮1.
----------------------------------------------

wincc-脚本大全

wincc-脚本大全
if (RetMsg==IDOK)
{
SetTagBit("TJ_ANNIU",1);
MessageBox (hwnd, "停机", "停机警告", MB_OK|MB_SYSTEMMODAL|MB_SETFOREGROUND);
SetTagBit("TJ_ANNIU",0);
}
else B=0;
}
else
————————————————————————
——————4、获取位号————————
SetTagChar("TrendTagName1","ProcessValueArchive\\PT111");//Return-Type: BOOL
SetTagSWord("TrendHi",200);
SetTagSWord("TrendLo",0);
z=GetTagBit("202搅拌机运行"); //取得PLC搅拌机的运行状态
if(z!=0)
{
switch(y)
{
case 0:
x=x-4;
if(x<=0)
y=1;
break;
default :
x=x+4;
if(x>=25)
y=0;
break;
}
}
return x;
}
——————12、运行时图形产生动态旋转——————
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char*

WINCC常用脚本说明

WINCC常用脚本说明
格式:GetTagByte("",); 实例:GetTagByte("WSJ_A_GDBL");
GetTagByte("WSJ_A_OFWO5");
4.写变量赋值
格式:SetTagByte("",); 实例:SetTagByte("WSJ_A_GDBL",1);
SetTagByte("WSJ_A_OFWO5",1);
c) 使用 VBS 脚本通过 ODBC 访问数据库
1) 连接数据库:
实例: YX = HMIRuntime.Tags("CP_A_GDH").READ
strConnectiOnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=dbzs1;Password=dbzs1;Initial Catalog=DBZS1;Data Source=10.65.248.20\WINCC"
5.调用 windows dialog
格式:MsgBox("", vbYesNo, "CONFIRM") 实例:MsgBox("确定工单开始?", vbYesNo, "CONFIRM") = vbYes Then
6.提示 Messagebox
格式:MsgBox("") 实例:MsgBox("CP 工单开始取消")
"
'V
="WSJ_REPORT
'"&GDH&"','"&BC&"','"&PCH&"','"&PH&"','"&Silo&"',"&CL&",'"&CStr(Now)&"',3"

wincc 全套脚本总结

wincc 全套脚本总结

} -------------------------------------
——————6、时间同步——————
void SetCpuTime() { #pragma code("kernel32.dll"); void GetLocalTime(SYSTEMTIME *lpst); #pragma code(); SYSTEMTIME time BOOL ret; //printf("Start function SetCpuTime\r\n"); GetLocalTime(&time); ret= SetTagMultiWait("%d%d%d%d%d%d%d",
"data_FLAG",1
) }
-------------------------------------
——————7、对话框调用——————
BOOL A; BOOL B; HWND hwnd=NULL; int RetMsg; A=GetTagBit("TJ_ANNIU"); //Return-Type: BOOL hwnd=FindWindow(NULL,"WinCC-运行系统 - "); if (A==0)
MB_OK|MB_SYSTEMMODAL|MB_SETFOREGROUND); SetTagBit("TJ_ANNIU",0);
} else B=0; } else { } ------------------------------------------
——————8、声音报警——————
#pragma code("Winmm.dll") VOID WINAPI PlaySoundA(char* pszSound,char* hmode,DWORD dwflag); #pragma code()

wincc中常用C脚本

wincc中常用C脚本

查看文章wincc常用C动作2010-06-27 10:311.用户注销:#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogout();2.用户登录:#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');3.关闭项目并退出wincc:ExitWinCC ();4.退出运行到wincc资源管理器:DeactivateRTProject ();5.结束监控并关闭计算机(会弹出确认对话框)HWND hWnd = NULL;//Author:Smartsysint iRet;hWnd = FindWindow(NULL,"WinCC-运行系统 - ");iRet=MessageBox(hWnd,"结束监控并关闭计算机","关闭操作站",MB_YESNO|MB_ICONWARNING|MB_APPLMODAL);if(iRet==IDYES)DMExitWinCCEx (DM_SDMODE_POWEROFF);6.点击事件弹出对话框,通过点击弹出对话框的确定和取消按钮实现对变量的置位或取消:int r;r=MessageBox(NULL, "YES为开,NO为关", "确定开命令:", MB_YESNO|MB_SYSTEMMODAL);if (r==IDYES)SetTagBit("TAGNAME",TRUE);elseSetTagBit("TAGNAME",FALSE);7.开显示关显示:(要在内部变量中建立三个二进制变量COLSE_DISPLAY、DISPLAY_NO和DISPLAY_COMMENT)// Funktion: Bit in Doppelwort setzen;if (GetTagBitWait("COLSE_DISPLAY")==1 ){SetTagBit("COLSE_DISPLAY",0);SetTagBit("DISPLAY_NO",0); //Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);}else{SetTagBit("COLSE_DISPLAY",1);SetTagBit("DISPLAY_NO",1); //Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);}8.开阀确认:BOOL a;a=GetTagBit("30T制水启动"); //Return-Type :short intif (a==0){if(MessageBox(NULL,"真的要启动制水吗?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) == 6) { SetTagBit("30T制水启动",1);//Return-Type :BOOL}}else{if(MessageBox(NULL,"真的要停止制水吗?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) == 6) { SetTagBit("30T制水停止",1);}}9.将WinCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow(NULL,"WinCC-Runtime - "); //如果运行语言为英文if (WinCCHwnd==0) WinCCHwnd=FindWindow(NULL,"WinCC-运行系统 - "); //如果运行语言为中文CloseWindow(WinCCHwnd);10.显示或不显示(其中hiddVtext为内部的二进制变量)if(GetTagBit("hiddVtext")==0) //Return-Type: BOOL{SetTagBit("hiddVtext",TRUE); //Return-Type: BOOL//Return-Type: BOOL}else{SetTagBit("hiddVtext",FALSE);}10.打开编辑画面的脚本#pragma option(mbcs)#ifdef RUN_ON_WEBNAVIGATOR#elseHWND hExplorerWindow= NULL;HWND hRuntimeWindow= NULL;hExplorerWindow= FindWindow("WinCCExplorerFrameWndClass",NULL);hRuntimeWindow= FindWindow("PDLRTisAliveAndWaitsForYou",NULL);if(hExplorerWindow){ShowWindow(hExplorerWindow, SW_MINIMIZE); // This entry is only necessary for Windows 2000ShowWindow(hExplorerWindow, SW_SHOWNORMAL);SetForegroundWindow(hExplorerWindow);}elseprintf("\r\n SetForeground failed");#endif11.如何在WINCC中制作一个保持型按钮方法1:if( GetTagBit("M10") )SetTagBit("M10",0);elseSetTagBit("M10",1);方法2:SetTagBit("M1.0",(SHORT)!GetTagBit("M1.0"));求反指令,如果为1点击变为0,如果为0点击变为1方法3:或者做两个按钮,按钮一:显示,直接连接m1.0,是--不显示,否--显示。

Wincc常用C脚本及常用功能

Wincc常用C脚本及常用功能

打开用户管理器ProgramExecute("Passcs.exe");取消激活#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)HWND hwnd=NULL;int iRet;hwnd=FindWindow(NULL,"WinCC-运行系统- "); //获得句柄iRet=MessageBox(hwnd,"是否取消激活?","Deactivate",MB_OKCANCEL|MB_ICONW ARNING|MB_APPLMODAL);if(iRet==1)DeactivateRTProject (); //Return-Type: BOOL}关闭计算机#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)HWND hwnd=NULL;int iRet;hwnd=FindWindow(NULL,"WinCC-运行系统- ");iRet=MessageBox(hwnd,"是否关闭计算机?","ShutDown",MB_OKCANCEL|MB_ICONW ARNING|MB_APPLMODAL);if(iRet==1)DMExitWinCCEx(DM_SDMODE_SYSTEM);}====================================================================== 登陆代码:#pragma code(“useadmin.dll”)#include <pwrt_api.h>#pragma code()PWRTLogin (‘e’);====================================取消激活(Deactivate)DeactivateRTProject();======================================Wincc变量操作GetTagDWord(“变量名称”); 获取Wincc变量值SetTagDWord(“变量“,设定值);设置Wincc变量对文本读写操作写操作#include "apdefap.h"void OnLButtonUp(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)FILE* lpFile;char *shuzhu[6]={"tag_1","tag_2","tag_3","tag_4","tag_5","tag_6"};char* lpszStr;int i,j;lpszStr=SysMalloc(60); //Return-Type: void*lpFile = fopen("D:\\test.txt", "w+");for(i=0;i<6;i++){lpszStr=GetTagChar(shuzhu[i]);strcat(lpszStr,"\r\n");if(lpFile == NULL){ printf("can not open file\r\n"); return;}fprintf(lpFile, lpszStr);}SysFree(lpszStr);fclose(lpFile);}读操作#include "apdefap.h"void OnLButtonUp(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)char* shuzhu[6]={"tag_1","tag_2","tag_3","tag_4","tag_5","tag_6"};char tmp[255];int i=0;int ChrNumLine=38;FILE *fp;fp=fopen("D:\\test.txt","r");if (fp==NULL){return;}else{rewind(fp);while(!feof(fp)){fgets(tmp,ChrNumLine,fp);SetTagChar(shuzhu[i],tmp);i++;}}fclose(fp);}画面窗口显示界面切换SetPictureName(lpszPictureName,"PicWindow_button","produce_manage_button.pdl"); SetVisible(lpszPictureName,"PicWindow_button",1);注:PicWindow_button是画面窗口名称;produce_manage_button.pdl是要显示的子画面。

最新WINCC脚本整理

最新WINCC脚本整理

切换按钮001 SetTagBit("TE_BOOL",!GetTagBit("TE_BOOL"));002 BOOL AA=GetTagBit("TE_BOOL");if(A) SetTagBit("TE_BOOL",0);Else SetTagBit("TE_BOOL",1);003 SetTagBit("TE_BOOL ",1-GetTagBit("TE_BOOL "));I O 域处的格式化输入输出在I/O域的输出值事件处的动作Float F_TAG;F_TAG =GetTagFloat("TE_FLOAT");return(F_TAG /100);WINCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow("PDLRTisAliveAndWaitsForYou",NULL);CloseWindow(WinCCHwnd);WINDOWS中提供的标准对话框{ BOOL bool1;HWND Hwnd;int iRet;Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) printf("\r\nGetWinCC Handle Failed!");iRet=MessageBox(Hwnd,"确认合闸","确认对话框",MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);switch (iRet){case IDYES: printf("user do YES\r\n");SetTagBit("TE_QUEST",1);break;case IDNO: printf("user do NO\r\n");SetTagBit("TE_QUEST",0);break;case IDCANCEL: printf("user do CANCEL\r\n");break;}}本画框的功能是点击按钮的时候弹出windows询问对话框其中“确认合闸”为对话内容,对话框的名称为“确认对话框”用户不同显示不同的按钮你可以在用户管理器给每个用户不同的权限,使他们对按钮有不同的操作权,这是最简便的。

wincc脚本全集

wincc脚本全集

——————1、wincc全局脚本动作-------隐藏控件——————#include "apdefap.h"int gscAction( void ){// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_ENDint value;value=GetTagBit("IM_in");//"IM_in"为触发的变量。

if(value==1){SetVisible("lianxi.pdl","按钮8",TRUE);//lianxi.pdl为控制对象所在画面名,“按钮8”为对象名称}else{SetVisible("lianxi.pdl","按钮8",FALSE);//lianxi.pdl}// WINCC:PICNAME_SECTION_START// syntax: #define PicNameInAction "PictureName"// next PicID : 1// WINCC:PICNAME_SECTION_ENDreturn 0;}=====================================================说明:在触发器里选择变量IM_in——————2、wincc全局脚本动作----提示框——————#include "apdefap.h"int gscAction( void ){// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_ENDint value;value=GetTagBit("IM_in");if(value==1){MessageBox(NULL,"请确认三厅相关门是否关好,或者请解锁。

关于WINCC的C脚本的使用总结

关于WINCC的C脚本的使用总结

Wincc的脚本功能及其强大,可以通过C脚本实现各种功能,但是脚本比较繁琐,始终不得其道,经过对比研究,发现了一些规律
1.全局脚本的实现
打开全局脚本编辑器,在“动作”-“全局动作“-新建动作,出现脚本编辑器的正文
可以看到正文已经有一部分内容,这些内容包括自带的全局脚本的声明及注释内容,都需要更改,也更改不了。

在第一大括号后,我们可以自己编用户脚本了,用户脚本一般是这样的结构:首先对数据和变量进行声明,即对其数据类型进行声明;然后,对变量进行取属性,转换变量,用value1=GetTagDWord("AI0");(这是个例子),意思是把AI0的值取出给value1了,然后就可以对value1进行计算了,计算后再置属性,转换变量,用
SetTagDWord("AI0",value1);
其他的地方注意符号和空格,然后编译,编译过了之后保存,并生成头文件,然后就见证奇迹吧。

下图是依次点亮的脚本
下图是液位高高报警的脚本。

WINCC脚本个人经验总结

WINCC脚本个人经验总结
long _main(char* lpszPictureName, char* lpszObjectName, char*
lpszPropertyName)
{
#pragma code(\"Winmm.dll\")
void WINAPI PlaySoundA(char *pszSound,char *hmode,DWORD dwflay);
long _main(char* lpszPictureName, char* lpszObjectName, char*
lpszPropertyName)
{
#pragma code(\"Winmm.dll\")
void WINAPI PlaySoundA(char *pszSound,char *hmode,DWORD dwflay);
解答:
重新启动以及在运行期间,您希望HMI系统达到最小的实用性而不使用登录窗口。然而,对于高级操作,登录功能应当保留。此外,如果没有用户登录,则有一个缺省的用户自动登录。缺省用户的权限可以在用户管理器中根据需要设定。
可使用下面的C脚本执行此项功能,请按照下列步骤进行:
将附件中的函数“Silentlogin.pas”复制到项目中的“PAS”子文件夹中。
#pragma code()
if(GetTagBit(\"112排泥备泵故障\"))
PlaySoundA(\"d:\\\\\\\\winnt\\\\\\\\media\\\\\\\\Mircosoft sound.wav\",NULL,8);
return 1020;
}重新启动后,不使用登录窗口如何以一个缺省用户的身份自动登录?怎样确保运行期间有个缺省用户始终处于登入状态?即使另外一个用户已经预先退出。

WINCC动画脚本集萃

WINCC动画脚本集萃

WINCC动画脚本集萃WINCC电机风扇旋转(几何---起始角度):#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static DWORD f=20;if (GetTagBit("DI电机运行信号")) {f= f+30;if (f==360) (f=0);}return f;}电机风扇旋转(几何---结束角度):#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static DWORD i=80;if (GetTagBit("DI电机运行信号")) {i = i+30;if (i==360) (i=0);}return i;}**物料水平右移动(几何---位置X)(停车后,物料回到原点)** #include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}if (!GetTagBit("DI电机运行信号")) (a=350);return a;}物料水平右移动(几何---位置X)(停车后,物料停在该点)#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}return a;}物料向上移动(几何---位置Y)(停车后,物料停在该点)#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int b=450;if (GetTagBit("DI电机运行信号") && (b>=290)) {b-=10;if (b<=280) (b=450);}return b;}年月日(静态文本)#include ""char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%04d/%02d/%02d",ptm->tm_year-100+2000,ptm->tm_mon+1,p tm->tm_mday);return(p);}时分秒(静态文本)#include ""char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min, ptm->tm_sec) ;return(p);}登陆到指定的用户名无须手动输入(按钮操作)#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code("")#include ""#pragma code()PWRTSilentLogin("用户名", "口令");}**显示登陆对话框无须热键(按钮操作)**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code ("")#include ""#pragma code( )PWRTLogin('c');}退出WINCC运行(按钮操作)#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){{DeactivateRTProject ();}}单位递增按钮(到上限不提示出错)#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value>90) (value=上限);else value=value+10;SetTagDWord("AI标签",value);}单位递减按钮(到下限不提示出错)#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value<10) (value=下限);else value=value-10;SetTagDWord("AI标签",value);}**单位递增按钮(到上限提示出错)**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value<=90) (value=value+10);else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**单位递减按钮(到下限提示出错)**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value>0) (value=value-10);else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**自动登陆到指定的用户(画面属性--其它—授权)**#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){#pragma code("")#include ""#pragma code()PWRTSilentLogin("用户名", "口令");return(0X0);}**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)** #include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int 上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗","启动!",MB_YESNO|MB_ICONQUESTION|MB_APPLM ODAL);printf("\\Example 3\\");if (上位启动信号==IDNO) (printf("User selected NO button \\"));else (SetTagByte("上位启动信号",1));}elseMessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗","启动!",MB_YESNOCANCEL|MB _ICONQUESTION|MB_APPLMODAL);if (上位启动信号==IDCANCEL) (printf("User selected NO button \\"));else{if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));else (SetTagByte("上位启动信号",0));}}elseMessageBox(hWnd," 电源未备妥,请查证后重试!","启动!", MB_OK|MB_ICONHAND|MB_APPLMODAL);}**搅拌器左侧扇页(几何—宽度)**#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int h=50;static int u=0;if (GetTagBit("DI电机运行信号")){if ((h>0)&&(h<=50)){(h-=2);return h;}if ((u>=0)&&(u<50)){(u+=2);return u;}u=0;h=50;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=50;u=0;return h;return u;}}**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)** #include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int h=75;static int u=125;if (GetTagBit("DI电机运行信号")) {if ((h>=75)&&(h<125)){(h+=2);return h;}if ((u<=125)&&(u>75)){(u-=2);return u;}u=125;h=75;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=75;u=125;return h;return u;}}**显示层按钮**SubX6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X630 9X94AE2X0000X653E_On LButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)Dim objScreenDim CountLayerSet objScreen = ("layer")For CountLayer=1 To 32 Step 1(CountLayer).Visible = vbFalseNext(n).Visible = vbTrueEnd Subn=层数+1初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){WinExec(" -hardcopy",SW_SHOWNORMAL);}**一个圈代表电机两种状态**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){char* opentag="DI1电机运行信号";char* closetag="DI2电机运行信号";BOOL open,close;open = GetTagBit(opentag); close = GetTagBit(closetag); if (open)return CO_GREEN;if (close)return CO_BLUE;。

WINCC动画脚本集锦

WINCC动画脚本集锦

WINCC动画脚本电机风扇旋转(几何---起始角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static DWORD f=20;if (GetTagBit("DI电机运行信号")) {f= f+30;if (f==360) (f=0);}return f;}电机风扇旋转(几何---结束角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static DWORD i=80;if (GetTagBit("DI电机运行信号")) {i = i+30;if (i==360) (i=0);}return i;}**物料水平右移动(几何---位置X)(停车后,物料回到原点)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}if (!GetTagBit("DI电机运行信号")) (a=350);return a;}物料水平右移动(几何---位置X)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}return a;}物料向上移动(几何---位置Y)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int b=450;if (GetTagBit("DI电机运行信号") && (b>=290)) {b-=10;if (b<=280) (b=450);}return b;}年月日(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%04d/%02d/%02d",ptm->tm_year-100+2000,ptm->tm_mon+1,ptm->tm_mday);return(p);}时分秒(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec);return(p);}登陆到指定的用户名无须手动输入(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");}**显示登陆对话框无须热键(按钮操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code( )PWRTLogin('c');}退出WINCC运行(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){DeactivateRTProject ();}}单位递增按钮(到上限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value>90) (value=上限);else value=value+10;SetTagDWord("AI标签",value);}单位递减按钮(到下限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value<10) (value=下限);else value=value-10;SetTagDWord("AI标签",value);}**单位递增按钮(到上限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName)DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value<=90) (value=value+10);else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**单位递减按钮(到下限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value>0) (value=value-10);else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**自动登陆到指定的用户(画面属性--其它—授权)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");return(0X0);}**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int 上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗?","启动!",MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);printf("\r\nExample 3\r\n");if (上位启动信号==IDNO) (printf("User selected NO button \r\n"));else (SetTagByte("上位启动信号",1));}elseMessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)HWND hWnd=NULL;int上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗?","启动!",MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPLMODAL);if (上位启动信号==IDCANCEL) (printf("User selected NO button\r\n"));else{if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));else (SetTagByte("上位启动信号",0));}}elseMessageBox(hWnd," 电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**搅拌器左侧扇页(几何—宽度)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int h=50;static int u=0;if (GetTagBit("DI电机运行信号"))if ((h>0)&&(h<=50)){(h-=2);return h;}if ((u>=0)&&(u<50)){(u+=2);return u;}u=0;h=50;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=50;u=0;return h;return u;}}**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName)static int h=75;static int u=125;if (GetTagBit("DI电机运行信号")){if ((h>=75)&&(h<125)){(h+=2);return h;}if ((u<=125)&&(u>75)){(u-=2);return u;}u=125;h=75;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=75;u=125;return h;return u;}}**显示层按钮**SubX6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X6309X94AE2X00 00X653E_OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByValy)Dim objScreenDim CountLayerSet objScreen = HMIRuntime.Screens("layer")For CountLayer=1 To 32 Step 1yers(CountLayer).Visible = vbFalseNextyers(n).Visible = vbTrueEnd Subn=层数+1初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){WinExec("PRTSCR.EXE -hardcopy",SW_SHOWNORMAL);}**一个圈代表电机两种状态**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){char* opentag="DI1电机运行信号";char* closetag="DI2电机运行信号";BOOL open,close; open = GetTagBit(opentag); close = GetTagBit(closetag);if (open)return CO_GREEN;if (close)return CO_BLUE;。

WINCC脚本整理

WINCC脚本整理

切换按钮001SetTagBit("TE_BOOL",!GetTagBit("TE_BOOL"));002BOOL AA=GetTagBit("TE_BOOL");if(A)SetTagBit("TE_BOOL",0);ElseSetTagBit("TE_BOOL",1);003SetTagBit("TE_BOOL ",1-GetTagBit("TE_BOOL "));I O域处的xx输入输出在I/O域的输出值事件处的动作Float F_TAG;F_TAG =GetTagFloat("TE_FLOAT");return(F_TAG /100);WINCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow("PDLRTisAliveAndWaitsForYou",NULL); CloseWindow(WinCCHwnd);WINDOWSxx提供的标准对话框{BOOL bool1;HWND Hwnd;int iRet;Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) printf("\r\nGetWinCC Handle Failed!");iRet=MessageBox(Hwnd,"确认合闸","确认对话框",MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEM MODAL);switch (iRet){case IDYES:printf("user do YES\r\n");SetTagBit("TE_QUEST",1);break;case IDNO:printf("user do NO\r\n");SetTagBit("TE_QUEST",0);break;case IDCANCEL:printf("user do CANCEL\r\n");break;}}本画框的功能是点击按钮的时候弹出windows询问对话框其中“确认合闸”为对话内容,对话框的名称为“确认对话框”用户不同显示不同的按钮你可以在用户管理器给每个用户不同的权限,使他们对按钮有不同的操作权,这是最简便的。

WINCC登录与注销C脚本程序[整理版]

WINCC登录与注销C脚本程序[整理版]

调用用户管理的C脚本:#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){SSMProgramStart( lpszPictureName, lpszObjectName, "Passcs.exe");}在按钮上用ProgramExecute("Passcs.exe")脚本可以执行用户管理程序做个登陆的画面,放2个按钮,登陆和注销,写脚本:由函数PWRTLogin()来执行登录。

#pragma code("USEADMIN.DLL")#include "PWRT_API.H"#pragma code()PWRTLogin('1');由函数PWRTLogout()来实现注销。

#pragma code("USEADMIN.DLL")#include "PWRT_API.H"#pragma code()PWRTLogout();分别用登录按钮和注销按钮实现,在按钮的事件中输入相应的代码,登录动作(如事件Mouse-click)#pragma code (“useadmin.dll”)#include “PWRT_api.h”#pragma code()PWRTLogin(’c’);- 退出动作(如事件Mouse-click)#pragma code (“useadmin.dll”)#include “PWRT_api.h”#pragma code()PWRTLogout();请参考如何修改当前用户的密码“CC_SewageDi_09_11_27_17_20_29”为自己创建的项目数据库名称;“@CurrentUserName”用当前户名,为WinnCC自身的内部变量,文本变量16位字符集,连接一个输入输出域;“@OldPassword”用当前用户旧密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;“@NewPassword”用当前用户新密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;“@ConfirmationPassword”用当前用户验证密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;在一个确定按钮鼠标动作中输入以下脚本include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code("UseGen.dll")#include "USEGENAP.H"#pragma code()LPCMN_ERROR err;if(strcmp(GetTagChar("@NewPassword"), GetTagChar("@ConfirmationPassword"))==FALSE){if (PWGENConnect("CC_SewageDi_09_11_27_17_20_29",err) ){if(PWGENChangePassword(GetTagChar("@CurrentUserName"),GetTagChar("@OldPassword"),G etTagChar("@NewPassword"),err)){MessageBox(NULL,"密码修改成功!","提示",MB_OK|MB_ICONEXCLAMA TION|MB_SETFOREGROUND|MB_SYSTEMMODAL);SetTagChar("@CurrentUserName","");SetTagChar("@OldPassword","");SetTagChar("@NewPassword","");SetTagChar("@ConfirmationPassword","");}else{if ((strlen(GetTagChar("@NewPassword")) <= 5)&&(strlen(GetTagChar("@OldPassword"))!=0)){MessageBox(NULL,"您输入的新密码个数小于6,请重新输入!","提示",MB_OK|MB_ICONEXCLAMA TION|MB_SETFOREGROUND|MB_SYSTEMMODAL);SetTagChar("@NewPassword","");SetTagChar("@ConfirmationPassword","");}else{MessageBox(NULL,"用户名和密码不一致,请重新输入!","提示",MB_OK|MB_ICONEXCLAMA TION|MB_SETFOREGROUND|MB_SYSTEMMODAL);SetTagChar("@CurrentUserName","");SetTagChar("@OldPassword","");}}}else{MessageBox(NULL,"建立联接失败!","提示",MB_OK|MB_ICONEXCLAMA TION|MB_SETFOREGROUND|MB_SYSTEMMODAL);}PWGENDisconnect(err);}else{MessageBox(NULL,"两次输入的新密码不一致,请重新输入!","提示",MB_OK|MB_ICONEXCLAMA TION|MB_SETFOREGROUND|MB_SYSTEMMODAL);SetTagChar("@NewPassword","");SetTagChar("@ConfirmationPassword","");}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

切换按钮001SetTagBit("TE_BOOL",!GetTagBit("TE_BOOL"));002BOOL AA=GetTagBit("TE_BOOL");if(A)SetTagBit("TE_BOOL",0);ElseSetTagBit("TE_BOOL",1);003SetTagBit("TE_BOOL ",1-GetTagBit("TE_BOOL "));I O域处的xx输入输出在I/O域的输出值事件处的动作Float F_TAG;F_TAG =GetTagFloat("TE_FLOAT");return(F_TAG /100);WINCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow("PDLRTisAliveAndWaitsForYou",NULL); CloseWindow(WinCCHwnd);WINDOWSxx提供的标准对话框{BOOL bool1;HWND Hwnd;int iRet;Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) printf("\r\nGetWinCC Handle Failed!");iRet=MessageBox(Hwnd,"确认合闸","确认对话框",MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEM MODAL);switch (iRet){case IDYES:printf("user do YES\r\n");SetTagBit("TE_QUEST",1);break;case IDNO:printf("user do NO\r\n");SetTagBit("TE_QUEST",0);break;case IDCANCEL:printf("user do CANCEL\r\n");break;}}本画框的功能是点击按钮的时候弹出windows询问对话框其中“确认合闸”为对话内容,对话框的名称为“确认对话框”用户不同显示不同的按钮你可以在用户管理器给每个用户不同的权限,使他们对按钮有不同的操作权,这是最简便的。

但是如果一定要根据用户不同显示不同的按钮就要用C脚本了下面这段代码可以加在有两个按钮的画面的对象属性--事件--画面对象--其他--打开画面,三个用户名是user1,user2,user3,按钮名称是按钮1,按钮2,你可以自行修改,这里假设已经进行过用户登录的操作,当打开有这两个按钮的画面时执行下列脚本判断用户并显示相应的按钮if (strcmp(GetTagChar("@CurrentUser"),"user1") ){}else{SetVisible(lpszPictureName,"按钮1",TRUE);SetVisible(lpszPictureName,"按纽2",FALSE);}if(strcmp(GetTagChar("@CurrentUser"),"user2") ){}else{SetVisible(lpszPictureName,"按钮1",FALSE);SetVisible(lpszPictureName,"按钮2",TRUE);}if (strcmp(GetTagChar("@CurrentUser"),"user3") ){}else{SetVisible(lpszPictureName,"按钮1",TRUE);SetVisible(lpszPictureName,"按钮2",TRUE);}strcmp是比较字符串的语句,比较文本变量只能用它,帮助里没有的,用它比较读取到的用户名GetTagChar("@CurrentUser")和三个用户名"userX",你把这段语句加到一个按钮的鼠标动作里,看点击按钮会不会两个按钮现实和隐藏。

登录登出对话框#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');PWRTLogin参数必须是CHAR字符。

它指定了显示对话框的监视器。

如果只使用一个监视器,那么保留默认参数“c”或者指定“1”。

#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogout();PWRTLogin参数必须是CHAR字符。

它指定了显示对话框的监视器。

如果只使用一个监视器,那么保留默认参数“c”或者指定“1”。

WinCC如何实现鼠标OnMouseOVer事件用WINDOWAPI函数GetCusorPos获取当前鼠标位置,用GetWindowRect函数获取窗口位置,两值相减得鼠标在WINCCframe上的相对位置。

用全局脚本(设定为1s定时刷新),然后获取要OnMouseOver事件的物体的位置,并与鼠标位置相比较,如一致则触发自己定义的动作。

#i nclude "apdefap.h"int gscAction( void ){#pragma code("user32.dll");BOOL GetCusorPos(POINT lpPoint); //获取鼠标的位置(绝对位置-对应屏幕分辨率)BOOL GetWindowRect(HWND hwnd,LPRECT lpRect); //获取窗体位置#pragma code();POINT pPos;RECT rRec;HWND hwnd;BOOL bRet,bRet2;long lLeft,lTop,lWidth,lHeight;long lX,lY;char szStr[100];hwnd=FindWindow(NULL,"WinCC-Runtime - "); //如语言为中文应为"WinCC运行系统-"if (hwnd==0) {printf("\r\nError! WinCc Handle is %d",hwnd);goto over;}bRet=GetCursorPos(&pPos);if (bRet==0) goto over;bRet2=GetWindowRect(hwnd,&rRec);if (bRet2==0) goto over;lX=pPos.x-rRec.left;//鼠标对{置lY=pPos.y-rRec.top;//鼠标位置//如果为非全屏模式,需将上述数值中的高height判断减去标题栏的宽度//printf("The Current Cusor Pos is x:%d,y:%d\r\n",pPos.x,pPos.y);//printf("The Cusor Pos in Window is x:%d,y:%d\r\n",pPos.x-lLeft2,pPos.y-lTop2);lLeft=GetLeft("NewPdl0.Pdl","Text1");//Return - Type :long intlTop=GetTop("NewPdl0.Pdl","Text1");//Return - Type :long intlWidth=GetWidth("NewPdl0.Pdl","Text1");//Return - Type :long intlHeight=GetHeight("NewPdl0.Pdl","Text1");//Return - Type :long intif ((lX>=lLeft)&&(lY>=lTop)&&(lX<=lLeft+lWidth)&&(lY<=lTop+lHeight)) { sprintf(szStr,"%d,%d",lX,lY);SetText("NewPdl0.Pdl","Text1",szStr);//Return - Type :char*}//printf("The Text1 Pos is x:%d,y:%d\r\n",lLeft2,lTop-lTop2);over:return 0;}退出WINCC监控时选择退出方式DMExitWinCCEx (DM_SDMODE_SYSTEM);或者使用动态向导通过给变量ExitSystem赋不同的数值实现不同的方式int a;a=GetTagWord("ExitSystem");//返回类型:WORDswitch(a){case 1 :MExitWinCCEx (DM_SDMODE_REBOOT);break;case 2 :DMExitWinCCEx (DM_SDMODE_SYSTEM);break;case 4 :ExitWinCC();break; ////DMExitWinCCEx (DM_SDMODE_WINCC);case 8 :DMExitWinCCEx (DM_SDMODE_LOGOFF);break;}如何实现用户登陆日志wincc中用c脚本实现?break;#pragma code("kernel32.dll")VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);#pragma code()char* username;char buf[128];static char preuser[128];unsigned a,b,c,d,e,f;FILE* fp;SYSTEMTIME sysTime;//读取系统时间,并且复制给变量a,b,c,d,e,fGetLocalTime(&sysTime);a=sysTime.wHour;b=sysTime.wMinute;f=sysTime.wYear; e=sysTime.wMonth;d=sysTime.wDay;c=sysTime.wSecond;username = GetTagChar("@CurrentUser"); //得到当前用户名称fp= fopen("c:\\wincclog.txt", "a+");//创建文件if(strcmp(username, preuser)!=0)//如果当前用户名称和前一个用户名不同{if((strcmp(username, "") != 0)&&(strcmp(preuser, "") == 0))//如果当前用户名称不空同时前一个用户名为空{sprintf(buf, "用户:%s\t登陆时间是:\t %d-%d-%d,%d-%d-%d\n", username,a,b,c,d,e,f);fputs(buf, fp);}else{if((strcmp(username, "") == 0)&&(strcmp(preuser, "") != 0))//如果当前用户名称为空同时前一个用户名不空{sprintf(buf,"用户:%s\t退出时间是:\t%d-%d-%d,%d-%d-%d\n",preuser,a,b,c,d,e,f);fputs(buf, fp);}else{sprintf(buf,"用户:%s\t退出时间是:\t%d-%d-%d,%d-%d-%d\n",preuser,a,b,c,d,e,f);fputs(buf, fp);sprintf(buf,"用户:%s\t登陆时间是:\t%d-%d-%d,%d-%d-%d\n",username,a,b,c,d,e,f);fputs(buf, fp);}}}strcpy(preuser, username);fclose(fp);return 0;用户登陆xx:(包括用户的登陆退出信息,以便查询在什么时间段是哪个用户在使用这个监控软件)设置语言英语SetLanguage(0x409);法语SetLanguage(0x407);德语SetLanguage(0x40C);调用计算器如果在C脚本中仅仅有一句ProgramExecute("CALC.exe")此时不关计算器就切换画面,则计算器都在后台运行。

相关文档
最新文档