Программа управления компьютером GetAdmin

Вопросы о разработке собственного драйвера или об отладке существующих
Benutzeravatar
instalator
guru
Beiträge: 1258
Registriert: 09.11.2014, 16:50
Wohnort: Барнаул
Kontaktdaten:

Re: Программа управления компьютером GetAdmin

Beitrag von instalator » 12.05.2016, 13:30

ford7 hat geschrieben:Скопипастил ваш скрипт, ругается на отсутствие модуля:
Spoiler: Show hidden text
12:49:59.342 [info] javascript.0 Stop script script.js.Getadmin2
12:50:34.009 [info] javascript.0 Start javascript script.js.Getadmin2
12:50:34.012 [error] javascript.0 script.js.Getadmin2: Cannot find module '/opt/iobroker/node_modules/iobroker.javascript/node_modules/ping' at script.js.Getadmin2:14:12
12:50:34.012 [info] javascript.0 script.js.Getadmin2: registered 7 subscriptions and 1 schedule
Драйвера установлены
Добавь модуль в настройки драйвера js
Dateianhänge
23424234.png
Высокий уровень Децибел вреден для здоровья!
Мой блог

Benutzeravatar
instalator
guru
Beiträge: 1258
Registriert: 09.11.2014, 16:50
Wohnort: Барнаул
Kontaktdaten:

Re: Программа управления компьютером GetAdmin

Beitrag von instalator » 12.05.2016, 13:47

ford7 hat geschrieben:
aurodionov hat geschrieben:Нужен скрипт который попингу отследить время включения компа, какой нить таймер, с переменной таймера брать значение и отображать в виз, по окончании отсчета вырубить комп

Пишу с пульта....
Эхх... вот скриптописец из меня просто писец )))
Тут вариантов много, например так, но это не точный таймер получится.

Code: Alles auswählen

createState('timer', 0);
var timer;

on({id: 'javascript.0.timer', change: 'any'}, function (obj) {
    if (obj.newState.val > 0){
         timer = setTimeout(function() {
            setState('javascript.0.timer', obj.newState.val - 1);
            log('Прошла секунда');
    	}, 1000);
    } else {
        clearTimeout (timer);
        log('ТУТ ВЫКЛЮЧАЕМ КОМП');
    }
});
Можно через schedule сделать. По крону проверяем каждую минуту например переменную и если она больше нуля то отнимаем и записывае новое значение в переменную. Как нибудь так:

Code: Alles auswählen

createState('timer', 0);
 schedule("* * * * *", function () {
    var timer = getState('javascript.0.timer').val;
    if (timer > 0){
       setState('javascript.0.timer', timer - 1);
    } else if (timer === 0){
        setState('javascript.0.timer', 'Время вышло');
        log('ТУТ ВЫКЛЮЧАЕМ КОМП');
    }
});
Высокий уровень Децибел вреден для здоровья!
Мой блог

rh1212
starter
Beiträge: 79
Registriert: 17.02.2018, 14:44

Re: Программа управления компьютером GetAdmin

Beitrag von rh1212 » 21.03.2018, 19:16

Hello!

Unfortunately I have found no info about this in English. First of thanks instalator for the great tool, so far shutting down my PC using iobroker is working perfectly. However, is there a way I can let my PC press a specific key (such as Space, Delete, or any other) without opening the browser on the host computer?
This is not my field so maybe I missed the way if its available or I misunderstood something.
Thanks a lot!

Benutzeravatar
instalator
guru
Beiträge: 1258
Registriert: 09.11.2014, 16:50
Wohnort: Барнаул
Kontaktdaten:

Re: Программа управления компьютером GetAdmin

Beitrag von instalator » 22.03.2018, 02:46

rh1212 hat geschrieben:Hello!

Unfortunately I have found no info about this in English. First of thanks instalator for the great tool, so far shutting down my PC using iobroker is working perfectly. However, is there a way I can let my PC press a specific key (such as Space, Delete, or any other) without opening the browser on the host computer?
This is not my field so maybe I missed the way if its available or I misunderstood something.
Thanks a lot!
https://blog.instalator.ru/archives/47
there under the spoiler list of supported keys
Высокий уровень Децибел вреден для здоровья!
Мой блог

rh1212
starter
Beiträge: 79
Registriert: 17.02.2018, 14:44

Re: Программа управления компьютером GetAdmin

Beitrag von rh1212 » 22.03.2018, 08:46

instalator hat geschrieben:
rh1212 hat geschrieben:Hello!

Unfortunately I have found no info about this in English. First of thanks instalator for the great tool, so far shutting down my PC using iobroker is working perfectly. However, is there a way I can let my PC press a specific key (such as Space, Delete, or any other) without opening the browser on the host computer?
This is not my field so maybe I missed the way if its available or I misunderstood something.
Thanks a lot!
https://blog.instalator.ru/archives/47
there under the spoiler list of supported keys
Thank you for the answer!
My problem is how do I let windows press that key without using letting my browser open after i send the command over iobroker?
So far everytime i want to send key=Space or volup the browser opens with the link. Is there a way to acoid that?

rh1212
starter
Beiträge: 79
Registriert: 17.02.2018, 14:44

Re: Программа управления компьютером GetAdmin

Beitrag von rh1212 » 22.03.2018, 09:29

Hi instalator,

So after trying around with the iobroker script I could achieve what I want without getting the browser opened when I want to press (SPACE or VOLUP).
I dont know if what I did makes sense or if it was always the solution but I didnt know it, but here it is:
Spoiler: Show hidden text

Code: Alles auswählen


createState('GetAdmin.cmd', '');
createState('GetAdmin.Host', '');
createState('GetAdmin.Port', '');
var request = require('request');

on({id: 'javascript.0.GetAdmin.cmd', change: 'any'}, function (obj) {
    if(obj.newState.val !== '' || typeof obj.newState.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendCmdGetAdmin(obj.newState.val,host,port);
        sendKeyGetAdmin(obj.newState.val,host,port);
        log('Отправляем команду GetAdmin - cmd: '+ obj.newState.val);
        log('Отправляем команду GetAdmin - key: '+ obj.newState.val);
    }else{log('GetAdmin. Не задана команда.');}
});
/***************************************************************************************/
function sendCmdGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?cmd='+value 
    };
    log('Отправляем команду GetAdmin - ' +options.url);
    request(options, function (error, response, body) {
        log('Ответ от сервера - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}

function sendKeyGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?key='+value 
    };
    log('Отправляем команду GetAdmin - ' +options.url);
    request(options, function (error, response, body) {
        log('Ответ от сервера - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}
Line 11 and the function sendKeyGetAdmin are important for this to work. Now you can type SPACE or VOLUP in cmd object and it will do that on my PC without opening the browser.

Benutzeravatar
instalator
guru
Beiträge: 1258
Registriert: 09.11.2014, 16:50
Wohnort: Барнаул
Kontaktdaten:

Re: Программа управления компьютером GetAdmin

Beitrag von instalator » 22.03.2018, 16:29

rh1212 hat geschrieben:Hi instalator,

So after trying around with the iobroker script I could achieve what I want without getting the browser opened when I want to press (SPACE or VOLUP).
I dont know if what I did makes sense or if it was always the solution but I didnt know it, but here it is:

Line 11 and the function sendKeyGetAdmin are important for this to work. Now you can type SPACE or VOLUP in cmd object and it will do that on my PC without opening the browser.
Spoiler: Show hidden text

Code: Alles auswählen

createState('GetAdmin.cmd', '');
createState('GetAdmin.HotKey', '');
createState('GetAdmin.Host', '192.168.1.10'); //!!!!!!CHANGE NEED
createState('GetAdmin.Port', '8585');  		  //!!!!!!CHANGE NEED
var request = require('request');

on({id: 'javascript.0.GetAdmin.cmd', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendCmdGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - cmd: '+ obj.state.val);
    }else{log('GetAdmin. Command not specified');}
});

on({id: 'javascript.0.GetAdmin.HotKey', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendKeyGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - HotKey: '+ obj.state.val);
    } else {log('GetAdmin. Command not specified.');}
});
/***************************************************************************************/
function sendCmdGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?cmd='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}

function sendKeyGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?key='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}
Support hotkey for write in object GetAdmin.HotKey:
Spoiler: Show hidden text
CTRL
RCTRL
ALT
RALT
SHIFT
RSHIFT
WIN
RWIN
ESC
ENT
DEL
INS
VOLUP
VOLDN
MUTE
NEXT
PREV
PLAY
STOP
BACK
SPACE
TAB
NUMP
NUMS
NUMD
NUM*
NUMM
NUML
CAPS
END
HOME
PGDN
PGUP
SCRL
PRNTSCR
SLEEP
DOWN
UP
LEFT
RIGHT
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
NUM0
NUM1
NUM2
NUM3
NUM4
NUM5
NUM6
NUM7
NUM8
NUM9
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Высокий уровень Децибел вреден для здоровья!
Мой блог

rh1212
starter
Beiträge: 79
Registriert: 17.02.2018, 14:44

Re: Программа управления компьютером GetAdmin

Beitrag von rh1212 » 22.03.2018, 16:39

instalator hat geschrieben:
rh1212 hat geschrieben:Hi instalator,

So after trying around with the iobroker script I could achieve what I want without getting the browser opened when I want to press (SPACE or VOLUP).
I dont know if what I did makes sense or if it was always the solution but I didnt know it, but here it is:

Line 11 and the function sendKeyGetAdmin are important for this to work. Now you can type SPACE or VOLUP in cmd object and it will do that on my PC without opening the browser.
Spoiler: Show hidden text

Code: Alles auswählen

createState('GetAdmin.cmd', '');
createState('GetAdmin.HotKey', '');
createState('GetAdmin.Host', '192.168.1.10'); //!!!!!!CHANGE NEED
createState('GetAdmin.Port', '8585');  		  //!!!!!!CHANGE NEED
var request = require('request');

on({id: 'javascript.0.GetAdmin.cmd', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendCmdGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - cmd: '+ obj.state.val);
    }else{log('GetAdmin. Command not specified');}
});

on({id: 'javascript.0.GetAdmin.HotKey', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendKeyGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - HotKey: '+ obj.state.val);
    } else {log('GetAdmin. Command not specified.');}
});
/***************************************************************************************/
function sendCmdGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?cmd='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}

function sendKeyGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?key='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}
Support hotkey for write in object GetAdmin.HotKey:
Spoiler: Show hidden text
CTRL
RCTRL
ALT
RALT
SHIFT
RSHIFT
WIN
RWIN
ESC
ENT
DEL
INS
VOLUP
VOLDN
MUTE
NEXT
PREV
PLAY
STOP
BACK
SPACE
TAB
NUMP
NUMS
NUMD
NUM*
NUMM
NUML
CAPS
END
HOME
PGDN
PGUP
SCRL
PRNTSCR
SLEEP
DOWN
UP
LEFT
RIGHT
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
NUM0
NUM1
NUM2
NUM3
NUM4
NUM5
NUM6
NUM7
NUM8
NUM9
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Thank you very much! You could tell programing is not my area of knowledge! Thanks again!

Benutzeravatar
instalator
guru
Beiträge: 1258
Registriert: 09.11.2014, 16:50
Wohnort: Барнаул
Kontaktdaten:

Re: Программа управления компьютером GetAdmin

Beitrag von instalator » 22.03.2018, 17:35

rh1212 hat geschrieben:
instalator hat geschrieben:
rh1212 hat geschrieben:Hi instalator,

So after trying around with the iobroker script I could achieve what I want without getting the browser opened when I want to press (SPACE or VOLUP).
I dont know if what I did makes sense or if it was always the solution but I didnt know it, but here it is:

Line 11 and the function sendKeyGetAdmin are important for this to work. Now you can type SPACE or VOLUP in cmd object and it will do that on my PC without opening the browser.
Spoiler: Show hidden text

Code: Alles auswählen

createState('GetAdmin.cmd', '');
createState('GetAdmin.HotKey', '');
createState('GetAdmin.Host', '192.168.1.10'); //!!!!!!CHANGE NEED
createState('GetAdmin.Port', '8585');  		  //!!!!!!CHANGE NEED
var request = require('request');

on({id: 'javascript.0.GetAdmin.cmd', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendCmdGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - cmd: '+ obj.state.val);
    }else{log('GetAdmin. Command not specified');}
});

on({id: 'javascript.0.GetAdmin.HotKey', change: 'any'}, function (obj) {
    if(obj.state.val !== '' || typeof obj.state.val !== "undefined"){
        var host = getState('javascript.0.GetAdmin.Host').val;
        var port = getState('javascript.0.GetAdmin.Port').val;
        sendKeyGetAdmin(obj.state.val,host,port);
        log('Send to GetAdmin - HotKey: '+ obj.state.val);
    } else {log('GetAdmin. Command not specified.');}
});
/***************************************************************************************/
function sendCmdGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?cmd='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}

function sendKeyGetAdmin(value, host, port){
    var options = {
        url: 'http://'+host+':'+port+'/?key='+value 
    };
    log('Send to GetAdmin - ' + options.url);
    request(options, function (error, response, body) {
        log('Response code - '+response.statusCode); 
        if (!error && response.statusCode == 200) {

        }
    });
}
Support hotkey for write in object GetAdmin.HotKey:
Spoiler: Show hidden text
CTRL
RCTRL
ALT
RALT
SHIFT
RSHIFT
WIN
RWIN
ESC
ENT
DEL
INS
VOLUP
VOLDN
MUTE
NEXT
PREV
PLAY
STOP
BACK
SPACE
TAB
NUMP
NUMS
NUMD
NUM*
NUMM
NUML
CAPS
END
HOME
PGDN
PGUP
SCRL
PRNTSCR
SLEEP
DOWN
UP
LEFT
RIGHT
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
NUM0
NUM1
NUM2
NUM3
NUM4
NUM5
NUM6
NUM7
NUM8
NUM9
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Thank you very much! You could tell programing is not my area of knowledge! Thanks again!
it's not mine either)
Высокий уровень Децибел вреден для здоровья!
Мой блог

Antworten