Отправляет текст в свернутые окна. И туда, где обычный sendkey не работает.
Умеет писать большие и маленькие рус и англ буквы, символы * } () # @ ! ? . , +
Если кто-то хочет оптимизировать код - не возражаю.
в свёрнутом окне почему-то большие буквы не всегда большие.
CODE:
win w=window (-1, "Edit", window ("Новый текстовый документ.txt — Блокнот", "Notepad", -1));
loop()
{
sleep(100);
написать("qwerty йцукен ЙЦУКЕН QWERTY !!!??? *HI* 12345", w); sendkey(13, w);
}
function написать(string str1, win w)
{
int p=130; //пауза для символов
int pp=50; //пауза для букв
int len=size(str1);
char arr[1023];
char rus[63];
string alfa;
strcpy(#arr[0], str1);
int i=0;
int i2=0;
int n=0;
alfa="F<DULT;PBQRKVYJGHCNEA{WXIO}SM >Z";
strcpy(#rus[0], alfa);
rus[1]=188;
rus[6]=186;
rus[21]=219;
rus[26]=221;
rus[29]=222;
rus[30]=190;
char state[256];
external(INT, "SetKeyboardState", "SetKeyboardState", "User32.dll");
for(i=0;i<len;i++)
{
i2=formatci(arr[i]);
if(i2==32) {attach(w,1); postmessage(WM_KEYDOWN, 32, 1, w); sleep(p); postmessage(WM_KEYUP, 32, 3221225472, w); attach(w,0);continue;}//пробел
if(i2==48) {attach(w,1); postmessage(WM_KEYDOWN, 48, 1, w); sleep(p); postmessage(WM_KEYUP, 48, 3221225472, w); attach(w,0);continue;}//0
for(int c=32; c<57; c++);
{
if(i2==c)
{attach(w,1);sleep(p); postmessage(WM_KEYDOWN, c, 1, w);sleep(p); postmessage(WM_KEYUP, c, 3221225472, w); attach(w,0);continue;} //1-9
}
// * } () # @ ! ? . , +
for(n=33;n<=37;n++) //!#$%
{
if(i2==n)
{
attach(w,1);
sendlanguage("00000409", w);
sendkeydown(16,w); sleep(p);
postmessage(WM_KEYDOWN, n+16, 1, w);sleep(p); postmessage(WM_KEYUP, n+16, 3221225472, w);
sendkeyup(16,w); sleep(p);
attach(w,0);
continue;
}
}
if(i2==64) {set("ENG", 50, w, 150, 1); continue;} //@
if(i2==58) {set("RU", 54, w, 150, 1); continue;} //:
if(i2==40) {set("RU", 57, w, 150, 1); continue;} //(
if(i2==41) {set("RU", 48, w, 150, 1); continue;} //)
if(i2==45) {set("--", 189,w, 150, 0); continue;} //-
if(i2==125){set("ENG", 221, w, 150, 1);continue;} //}
if(i2==42) {set("ENG", 56, w, 150, 1); continue;} //звезда
if(i2==59) {set("RU", 52, w, 150, 1); continue;} //;
if(i2==63) {set("ENG", 191,w, 150, 1); continue;} //?
if(i2==46) {set("ENG", 190,w, 150, 0); continue;} //.
if(i2==44) {set("ENG", 188,w, 150, 0); continue;} //,
if(i2==61) {set("RU", 187,w, 150, 0); continue;} //=
//BIG
if (i2>=65)
{
if (i2<=90)
{
sendlanguage("00000409", w);
sleep(pp);
attach(w,1);
for (n=0; n<256; n++)state[n]=0;
GetKeyboardState(address(#state[0]));
state[16]=128;
postmessage(WM_KEYDOWN, 16, 1, w);
SetKeyboardState(address(#state[0]));
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);
postmessage(WM_KEYUP, 16, 3221225472, w);
state[16]=0;
SetKeyboardState(address(#state[0]));
attach(w,0);continue;
}
}
//small
if (i2>=97)
{
if(i2<=122)
{i2=i2-32;
sendlanguage("00000409", w);
sleep(pp);
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);continue;
}
}
//БОЛЬШАЯ
if (i2>=192)
{
if (i2<=223)
{
sendlanguage("00000419", w);
sleep(pp);
i2=i2-192;
i2=formatci(rus[i2]);
attach(w,1);
for (n=0; n<256; n++)state[n]=0;
GetKeyboardState(address(#state[0]));
state[16]=128;
postmessage(WM_KEYDOWN, 16, 1, w);
SetKeyboardState(address(#state[0]));
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);
postmessage(WM_KEYUP, 16, 3221225472, w);
state[16]=0;
SetKeyboardState(address(#state[0]));
attach(w,0);continue;
}
}
//маленькая
if (i2>=224)
{
if (i2<=255)
{
i2=i2-224;
i2=formatci(rus[i2]);
sendlanguage("00000419", w);
sleep(pp);
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);continue;
}
}
}
}
function set(string lang, int k, win w, int p, int n)
{
if(lang=="ENG") lang="00000409";
if(lang=="RU") lang="00000419";
attach(w,1);
sendlanguage(lang, w);
if(n==1) sendkeydown(16,w);
sleep(p);
postmessage(WM_KEYDOWN, k, 1, w); sleep(p); postmessage(WM_KEYUP, k, 3221225472, w);
if(n==1) sendkeyup(16,w);
attach(w,0);
}
loop()
{
sleep(100);
написать("qwerty йцукен ЙЦУКЕН QWERTY !!!??? *HI* 12345", w); sendkey(13, w);
}
function написать(string str1, win w)
{
int p=130; //пауза для символов
int pp=50; //пауза для букв
int len=size(str1);
char arr[1023];
char rus[63];
string alfa;
strcpy(#arr[0], str1);
int i=0;
int i2=0;
int n=0;
alfa="F<DULT;PBQRKVYJGHCNEA{WXIO}SM >Z";
strcpy(#rus[0], alfa);
rus[1]=188;
rus[6]=186;
rus[21]=219;
rus[26]=221;
rus[29]=222;
rus[30]=190;
char state[256];
external(INT, "SetKeyboardState", "SetKeyboardState", "User32.dll");
for(i=0;i<len;i++)
{
i2=formatci(arr[i]);
if(i2==32) {attach(w,1); postmessage(WM_KEYDOWN, 32, 1, w); sleep(p); postmessage(WM_KEYUP, 32, 3221225472, w); attach(w,0);continue;}//пробел
if(i2==48) {attach(w,1); postmessage(WM_KEYDOWN, 48, 1, w); sleep(p); postmessage(WM_KEYUP, 48, 3221225472, w); attach(w,0);continue;}//0
for(int c=32; c<57; c++);
{
if(i2==c)
{attach(w,1);sleep(p); postmessage(WM_KEYDOWN, c, 1, w);sleep(p); postmessage(WM_KEYUP, c, 3221225472, w); attach(w,0);continue;} //1-9
}
// * } () # @ ! ? . , +
for(n=33;n<=37;n++) //!#$%
{
if(i2==n)
{
attach(w,1);
sendlanguage("00000409", w);
sendkeydown(16,w); sleep(p);
postmessage(WM_KEYDOWN, n+16, 1, w);sleep(p); postmessage(WM_KEYUP, n+16, 3221225472, w);
sendkeyup(16,w); sleep(p);
attach(w,0);
continue;
}
}
if(i2==64) {set("ENG", 50, w, 150, 1); continue;} //@
if(i2==58) {set("RU", 54, w, 150, 1); continue;} //:
if(i2==40) {set("RU", 57, w, 150, 1); continue;} //(
if(i2==41) {set("RU", 48, w, 150, 1); continue;} //)
if(i2==45) {set("--", 189,w, 150, 0); continue;} //-
if(i2==125){set("ENG", 221, w, 150, 1);continue;} //}
if(i2==42) {set("ENG", 56, w, 150, 1); continue;} //звезда
if(i2==59) {set("RU", 52, w, 150, 1); continue;} //;
if(i2==63) {set("ENG", 191,w, 150, 1); continue;} //?
if(i2==46) {set("ENG", 190,w, 150, 0); continue;} //.
if(i2==44) {set("ENG", 188,w, 150, 0); continue;} //,
if(i2==61) {set("RU", 187,w, 150, 0); continue;} //=
//BIG
if (i2>=65)
{
if (i2<=90)
{
sendlanguage("00000409", w);
sleep(pp);
attach(w,1);
for (n=0; n<256; n++)state[n]=0;
GetKeyboardState(address(#state[0]));
state[16]=128;
postmessage(WM_KEYDOWN, 16, 1, w);
SetKeyboardState(address(#state[0]));
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);
postmessage(WM_KEYUP, 16, 3221225472, w);
state[16]=0;
SetKeyboardState(address(#state[0]));
attach(w,0);continue;
}
}
//small
if (i2>=97)
{
if(i2<=122)
{i2=i2-32;
sendlanguage("00000409", w);
sleep(pp);
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);continue;
}
}
//БОЛЬШАЯ
if (i2>=192)
{
if (i2<=223)
{
sendlanguage("00000419", w);
sleep(pp);
i2=i2-192;
i2=formatci(rus[i2]);
attach(w,1);
for (n=0; n<256; n++)state[n]=0;
GetKeyboardState(address(#state[0]));
state[16]=128;
postmessage(WM_KEYDOWN, 16, 1, w);
SetKeyboardState(address(#state[0]));
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);
postmessage(WM_KEYUP, 16, 3221225472, w);
state[16]=0;
SetKeyboardState(address(#state[0]));
attach(w,0);continue;
}
}
//маленькая
if (i2>=224)
{
if (i2<=255)
{
i2=i2-224;
i2=formatci(rus[i2]);
sendlanguage("00000419", w);
sleep(pp);
postmessage(WM_KEYDOWN, i2, 1, w);
sleep(pp);
postmessage(WM_KEYUP, i2, 3221225472, w);continue;
}
}
}
}
function set(string lang, int k, win w, int p, int n)
{
if(lang=="ENG") lang="00000409";
if(lang=="RU") lang="00000419";
attach(w,1);
sendlanguage(lang, w);
if(n==1) sendkeydown(16,w);
sleep(p);
postmessage(WM_KEYDOWN, k, 1, w); sleep(p); postmessage(WM_KEYUP, k, 3221225472, w);
if(n==1) sendkeyup(16,w);
attach(w,0);
}