wincc常用C脚本..

内容发布更新时间 : 2024/12/23 18:28:54星期一 下面是文章的全部内容请认真阅读。

long _main(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

static int a=350;

if (GetTagBit(\电机运行信号\&& (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(\电机运行信号\&& (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,\

+1,ptm->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,\

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(\标签\

if (value>90) (value=上限);

else value=value+10; SetTagDWord(\标签\

}

单位递减按钮(到下限不提示出错)

#include \

void OnClick(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

DWORD value;

value=GetTagDWord(\标签\

if (value<10) (value=下限); else value=value-10; SetTagDWord(\标签\

}

**单位递增按钮(到上限提示出错)**

#include \

void OnClick(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

DWORD value; HWND hWnd=NULL ;

hWnd=FindWindow(NULL,\运行系统- \

value=GetTagDWord(\标签\ if (value<=90) (value=value+10);

else MessageBox(hWnd,\已到达上限值!\错误\

SetTagDWord(\标签\

}

**单位递减按钮(到下限提示出错)**

#include \

void OnClick(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

DWORD value; HWND hWnd=NULL ;

hWnd=FindWindow(NULL,\运行系统- \

value=GetTagDWord(\标签\ if (value>0) (value=value-10);

else MessageBox(hWnd,\已到达下限值!\错误\

SetTagDWord(\标签\

}

**自动登陆到指定的用户(画面属性--其它—授权)**

#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 上位启动信号;

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi