Skip to content
조회 수 10576 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

스프레드시트 autohotkey html gmail 스마트폰 이용하여 핑로스 즉시 알림받기

 

 

첫번째

스프레드시트를 설정하겠습니다.

 

 

1.  우선 시트1을 하나 만들고,

google spreadsheets mail torce-4.png

 

 

 

2. 메뉴의 도구 -> 스크립트 편집기를 선택합니다.

google spreadsheets mail torce-5.png

 

 

 

3. 프로젝트 작성합니다.

 

파일 -> 새로만들기 -> 프로젝트를 선택하고

아래의 소스를 그대로 복사한 뒤 

제목을 적고 저장합니다.

 

google spreadsheets mail torce-6.png

 

 

-소스-

* 파란색으로 표시한 시트1은 스프레드시트에서 ajax요청을 기록할 시트 이름입니다. 

//  1. Enter sheet name where data is to be written below

        var SHEET_NAME = "시트1";

         

//  2. Run > setup

//

//  3. Publish > Deploy as web app

//    - enter Project Version name and click 'Save New Version'

//    - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)

//

//  4. Copy the 'Current web app URL' and post this in your form/script action

//

//  5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)

 

var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service

 

// If you don't want to expose either GET or POST methods you can comment out the appropriate function

function doGet(e){

  return handleResponse(e);

}

 

function doPost(e){

  return handleResponse(e);

}

 

function handleResponse(e) {

  // shortly after my original solution Google announced the LockService[1]

  // this prevents concurrent access overwritting data

  // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html

  // we want a public lock, one that locks for all invocations

  var lock = LockService.getPublicLock();

  lock.waitLock(30000);  // wait 30 seconds before conceding defeat.

   

  try {

    // next set where we write the data - you could write to multiple/alternate destinations

    var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));

    var sheet = doc.getSheetByName(SHEET_NAME);

     

    // we'll assume header is in row 1 but you can override with header_row in GET/POST data

    var headRow = e.parameter.header_row || 1;

    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];

    var nextRow = sheet.getLastRow()+1; // get next row

    var row = [];

    // loop through the header columns

    for (i in headers){

      if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column

        row.push(new Date());

      } else { // else use header name to get data

        row.push(e.parameter[headers[i]]);

      }

    }

    // more efficient to set values as [][] array than individually

    sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);

    // return json success results

    return ContentService

          .createTextOutput(JSON.stringify({"result":"success", "row": nextRow}))

          .setMimeType(ContentService.MimeType.JSON);

  } catch(e){

    // if error return this

    return ContentService

          .createTextOutput(JSON.stringify({"result":"error", "error": e}))

          .setMimeType(ContentService.MimeType.JSON);

  } finally { //release lock

    lock.releaseLock();

  }

}

 

function setup() {

    var doc = SpreadsheetApp.getActiveSpreadsheet();

    SCRIPT_PROP.setProperty("key", doc.getId());

}

 

이제 위에서 복사해둔 웹 앱 URL을 통해 ajax GET/POST 요청을 보낼 수 있습니다.

ajax명령어를 사용하려면 skin.html에 jQuery스크립트를 포함해야합니다.

예)<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

 

 

4. 버전을 등록합니다.

반드시 버전을 등록해야하며 만약 스크립트의 바뀐내용을 적용시키려면 게시-웹 앱을 중지한 뒤 버전 삭제 후 다시 등록바랍니다.

 

그래야 수정된 스크립트대로 적용됩니다.

 

google spreadsheets mail torce-7.png

 

google spreadsheets mail torce-8.png

 

 

5. 실행 -> 함수실행 -> setup을 실행하고 

 

google spreadsheets mail torce-9.png

 

 

6. 웹 앱으로 배포를 선택하여 적용합니다. 

google spreadsheets mail torce-10.png

 

이것으로 스프레드시트 적용와 스크립트 적용은 끝났습니다.

 

 

 

7. 핑로스시 스프레드시트로 내용을 전달하는 html 문서를 만들어 봅니다.

 

url은 복사해둔 웹앱 URL을 사용하면 됩니다.

 

다음은 ajax 예제입니다.

$.ajax({

  url: "웹앱URL",

  data: {A:"a", B:"b"},

  type: "POST"

});

중요 : (스프레드시트에는 미리 첫번째 행에 A가 기록된 열과 B가 기록된 열이 존재해야 a, b가 기록됩니다.)

 

 


 

 

 

위의 이미지에 나오는 게시할 수 있는 웹앱URL을 복사후 test.html 파일을 만들때 웹앱URL을 수정합니다.

 

<!DOCTYPE html>

<html lang="ko">

    <head>

        <meta charset="utf-8">

        <title>Ajax upload example</title>

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

 

<script type="text/javascript">

$.ajax({

  url: "웹앱URL",

  data: {A:"a", B:"f"},

  type: "POST"

});

 

</script>

 

 

여기서 timestamp를 기록하고 싶어서 조금 추가했습니다.

 

현재는 스프레드시트의 이 양식을 기준으로

google spreadsheets mail torce-4.png

 

 

var date = new Date();

//var timestamp = date.getTime();

 

 

 $.ajax({

 

  url: "https://script.google.com/macros/s/매크로주소",

 

  data: {timestamp:date, firstName:"googlespreadsheets/pinglosstime.html", lastName:"전화장애", email:"urin79@gmail.com", address:"121.xx.52.137", notes:"핑로스"},

 

  type: "POST"

 

});

 

 

 

8. autohotkey로 핑테스트를 한 뒤  문서를 적용해 봅니다.

 

윈도우 창 정보 알아내기 소스파일 - AHK_Window_Info_v1.7.ahk

include에 필요한 com.ahk 소스파일 - com.ahk

 

 

#include com.ahk

 

;http://urin79.com/blog/542292

;실행파일로 만들때 예를들어 C:\>pingtest.exe 164.124.101.2 이렇게 파라미터 변수를 선택할 수 있습니다.

ip=%1%

 

 

;ip변수값이 없으면 수동으로 입력한 ip를 대체해서 사용한다는 내용

if !ip

{

; ip="10.1.169.1"

ip="10.1.180.230"

}

 

loop{

 

 

runwait, %comspec% /c "%systemroot%\system32\ping %ip% -n 1 > d:\Ping.txt",, hide

;FileRead, ping, D:\ping.txt

 

if (ver="Windows 7") or (ver="Windows Vista")

{

FileReadLine, ping, D:\ping.txt, 3

}

else

{

FileReadLine, ping, D:\ping.txt, 3

}

 

 

sleep, 1000

; msgbox,%ping%

pingline=%pinglines%%A_Mon%월 %A_MDay%일 %A_Hour%시 %A_Min%분 %A_Sec%초:::%ping%

 

FileAppend, %pingline%`n, D:\pingTest.txt

 

 

; IfInString, pingline, 만료

; IfNotInString, pingline, TTL

IfInString, ping, 만료

{

; msgbox, %pingline%

 

pwb := ComObjCreate( "InternetExplorer.Application" ) ; Create an IE object

pwb.Visible := True ; Make the IE object visible

 

; pwb.Navigate( "D:\백업\html\spreadsheets html\spreadsms.html" )

pwb.Navigate( "http://주소/googlespreadsheets/pinglosstime.html" )

While, pwb.Busy

; While, pwb.Busy

   Continue

sleep, 2000

; msgbox, 와우

 

IfWinExist, 핑로스 알람 스프레드시트에 데이터 전송 - Internet Explorer

WinClose, 핑로스 알람 스프레드시트에 데이터 전송 - Internet Explorer

sleep, 10000

}

sleep, 5000

}

 

 

 

^R::

reload

return

 

 

^X::

ExitApp

return

 
 
 
오랜 시행착오끝에 겨우 성공했습니다.
 
자바스크립트를 원할히 활용할 수 있다면 쉽게 적용했을텐데???

 

#스프레드시트 #autohotkey #html #gmail #스마트폰 #핑로스 #알림받기

로그인 후 댓글쓰기가 가능합니다.

?

  1. 24
    Jan 2015
    15:09

    Windows XP 부팅속도 개선 팁

    CategoryWindowsTip Views1412
    Read More
  2. 24
    Jan 2015
    11:52

    (nPDF) 프린터 인쇄 내용을 PDF 파일로 변환하기

    CategoryWindowsTip Views2271
    Read More
  3. 23
    Jan 2015
    12:56

    JAVA 7 다운로드

    CategoryWindowsTip Views5891
    Read More
  4. 22
    Jan 2015
    13:42

    공유기의 공인IP(Wan) 미할당으로 안되는 증상이 잦은경우 대처방법

    CategoryWindowsTip Views1966
    Read More
  5. 22
    Jan 2015
    13:08

    exFAT 이동식 USB 하드 쓰기 금지 문제 해결방법

    CategoryWindowsTip Views3107
    Read More
  6. 22
    Jan 2015
    13:07

    usb 쓰기가 금지되어 있습니다 해제방법

    CategoryWindowsTip Views1827
    Read More
  7. 14
    Jan 2015
    09:00

    윈도우 XP에서 exFAT 인식 패치방법

    CategoryWindowsTip Views1557
    Read More
  8. 09
    Jan 2015
    18:20

    알리익스프레스에서 산 ralink 802.n usb driver

    CategoryWindowsTip Views1521
    Read More
  9. 09
    Jan 2015
    07:01

    도스용 파티션 매직

    CategoryWindowsTip Views2323
    Read More
  10. 09
    Jan 2015
    06:40

    ISO 파일을 USB로 굽기(USB 윈도우 설치 디스크 만들기)

    CategoryWindowsTip Views4885
    Read More
  11. 09
    Jan 2015
    06:32

    복구콘솔 USB 만들기

    CategoryWindowsTip Views1539
    Read More
  12. 08
    Jan 2015
    23:26

    컴퓨터가 많이 느리다면?

    CategoryWindowsTip Views1777
    Read More
  13. 08
    Jan 2015
    23:24

    XP USB 부팅디스크 만들기 & 고스트

    CategoryWindowsTip Views2089
    Read More
  14. 07
    Jan 2015
    11:59

    애드웨어 클리너

    CategoryWindowsTip Views6856
    Read More
  15. 27
    Dec 2014
    12:45

    마이크로소프트 윈도우가 제공하는 기본적인 실행명령어 모음.

    CategoryWindowsTip Views6305
    Read More
  16. 27
    Dec 2014
    12:40

    autohotkey regwrite ipv6 제거툴

    CategoryWindowsTip Views1540
    Read More
  17. 27
    Dec 2014
    08:59

    윈도우 빠른종료 팁

    CategoryWindowsTip Views1821
    Read More
  18. 23
    Dec 2014
    18:09

    익스플로러 ftp 정상화 시키기

    CategoryWindowsTip Views1660
    Read More
  19. 13
    Dec 2014
    14:07

    엑셀에서 날짜합계 구하는 함수(Sumproduct 함수 이해하기)

    CategoryExcel Views9905
    Read More
  20. 11
    Nov 2014
    08:35

    PHP강좌 MySQL 연동

    CategoryHTMLPHPMSQL Views5801
    Read More
Board Pagination Prev 1 ... 14 15 16 17 18 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소