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 #스마트폰 #핑로스 #알림받기

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

?

List of Articles
번호 분류 제목 날짜 조회 수
917 AutoHotKey #ifwinactive & #ifwinexist 윈도우창 마다 핫키의 용도를 다르게 사용하는 방법 2011.02.14 16518
916 Excel 'C:Documents.xlsx' 을(를) 찾을 수 없습니다. 라는 오류 메시지가 나오는 경우 대처방법 2015.01.28 4765
915 WindowsTip (nPDF) 프린터 인쇄 내용을 PDF 파일로 변환하기 2015.01.24 2271
914 컴퓨터잡담 -응답없음- 으로 멈춰버린 프로그램 대기시간 줄이는 방법 2010.10.01 7819
913 컴퓨터잡담 .htaccess와 워터마킹을 이용한 이미지 링크 방지 2009.06.30 34917
912 WindowsTip 100M Full 속도내기(레지스터리) file 2013.01.11 6506
911 컴퓨터잡담 16진수 헥사, 2진수, 10진수, 8진법 변환 계산기; Hex Calc 2012.02.22 7916
910 컴퓨터잡담 2021년 플래시 플레이어 웹사이트 크롬에서 접속하는 방법 2021.07.05 2559
909 컴퓨터잡담 2023-09-23 서버다운 후 복구완료 secret 2023.09.23 35723
908 컴퓨터잡담 50 개 이상의 Ajax 예제들 2 2010.03.29 18950
907 컴퓨터잡담 50 개 이상의 Ajax 예제들 2010.03.29 18178
906 Server 8기가 램에 맞는 Mysql config 셋팅 값 1 2016.02.22 3856
905 컴퓨터잡담 ACTIVE-X 의 무서움 file 2015.12.26 666
904 컴퓨터잡담 AHK & my Address of Pointer and my Offset 2011.10.11 13160
903 컴퓨터잡담 Ahk Standard Library Collection, 2010 Sep (+Gui) ~ Libs: 100 3 2011.10.11 14189
902 AutoHotKey ahk) autohotkey controlgettext 이름을 마우스커서에 졸졸 따라다니게 하기 file 2014.04.01 12153
901 AutoHotKey ahk) autohotkey 글자 자르기 방법 2013.10.30 34636
900 AutoHotKey ahk) autohotkey 엑셀(Excel)에서 행값 증가시키기 2013.10.30 37410
899 AutoHotKey AHK) AUTOKEY 웹페이지 열지않고 소스 가져오기 또는 로그인 하기 14 2012.05.12 52944
898 AutoHotKey Ahk) ip할당 진단프로그램 file 2011.12.26 12118
Board Pagination Prev 1 2 3 4 5 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소