자동 클릭

테크 2010/08/24 15:50
import time
import win32api
import win32con

def click():
	win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
	win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

if __name__ == "__main__":
	# 타겟을 지정하기 위한 유예 시간 5초
	time.sleep(5)

	# 10분에 한 번씩 클릭
	while True:
		click()
		time.sleep(10 * 60)
저작자 표시

'테크' 카테고리의 다른 글

자동 클릭  (0) 2010/08/24
OpenOffice.org Basic Program (2/N)  (0) 2010/08/15
OpenOffice.org Basic Program (1/N)  (0) 2010/08/12
VLC 자막 글꼴이 바뀌지 않는 경우  (0) 2010/08/09
티스토리에 Syntax Highlighter 적용  (0) 2010/08/07
Zone.Identifier 파일  (0) 2010/08/03
Posted by 레타라슈
TAG Python
3. Arrays
- Simple Arrays
변수이름 뒤에 괄호와 함께 배열 요소의 수를 위한 규격(?)을 적어주어 배열을 선언한다.
Dim MyArray(3)
0부터 시작해서 괄호 안에 적힌 번호까지의 변수 MyArray(0) ~ MyArray(3)을 사용할 수 있다.
(시작 번호를 1로 바꾸는 방법과 VBA 호환성 옵션은 문제를 야기할 수 있기 때문에 생략하겠다.)
다른 방법으로, 범위를 지정해서 배열을 선언할 수 있으며 음수도 사용 가능하다.
Dim MyInteger1(5 To 10) As Integer
Dim MyInteger2(-10 To -5) As Integer

- Multi-Dimensional Data Fields
,(comma)를 이용해서 다차원의 배열을 선언할 수 있다.
Dim MyInteger(5, 5) As Integer

- Dynamic Changes in the Dimentions of Data Fields
배열의 크기는 재지정이 가능하고, 그 때 Preserve 키워드로 변수의 값도 유지할 수 있다.
Dim MyInteger(4) As Integer
ReDim MyInteger(10) As Integer
ReDim Preserve MyInteger(20) As Integer

- Determining the Dimensions of Data Fields
LBound(), UBound() 함수는 배열의 처음과 끝 번호를 알려준다.
Dim MyInteger(10) As Integer
Dim n As Integer
n = 47
Redim MyInteger(n) As Integer
MsgBox(LBound(MyInteger))	' displays: 0
MsgBox(UBound(MyInteger))	' displays: 47
Dim MyInteger(10, 13 To 28) As Integer
MsgBox(LBound(MyInteger))	' displays: 13
MsgBox(UBound(MyInteger))	' displays: 28

- Empty Arrays
Dim MyInteger() As Integer
MsgBox(LBound(MyInteger))	' display: 0
MsgBox(UBound(MyInteger))	' display: -1

4. Operators
- Mathmatical Operators
+, &, -, *, /, \, ^, MOD

- Logical Operators
AND, OR, XOR, NOT, EQV, IMP

- Comparison Operators
=, <>, >, >=, <, <=

5. Procedures and Functions
- Procedures
Sub Test
	' ... here is the actual code of the procedure
End Sub

- Functions
Function Test
	' ... here is the actual code of the function
	Test = 123
End Function
Function Test As Integer
	' ... here is the actual code of the function
	Test = 123
End Function

- Terminating Procedures and Functions Prematurely
Sub Test
	' ...
	Exit Sub
	' ...
End Sub

- Passing Parameters
Sub Test
	Dim A As Integer
	A = 10
	ChangeValue(A)
	' The parameter A now has the value 20
	ChangeNothing(A)
	' The parameter A not changed
End Sub

Sub ChangeValue(TheValue As Integer)
	TheValue = 20
End Sub

Sub ChangeNothing(ByVal TheValue As Integer)
	TheValue = 10
End Sub

- Optional Parameters
Sub Test
	Dim T As Boolean
	T = Func()
	' T is True
	T = Func(10)
	' T is False
End Sub

Function Func(Optional A As Integer)
	Func = IsMissing(A)
End Function

6. Scope and Life Span of Variables
Public 키워드는 Dim 대신 사용할 수 있으며 선언된 변수가 모듈간에 참조될 수 있다.
Private 키워드는 선언하는 변수의 참조 범위를 모듈 내로 제한한다.
Global 키워드는 Public 키워드와 유사하지만 매크로 실행 후에도 변수의 값이 유지된다.
Static 키워드는 프로시저나 함수의 실행 후에도 값이 유지되기 원할 때 사용한다.
Global A As Integer
Public B As Integer
Private C As Integer

Sub Test
	Static D As Integer
End Sub

7. Constants
Const A As Integer = 10
상수는 기본적으로 모듈 내로 참조 범위를 한정한다.
다른 모듈에서 참조할 수 있게 하려면 Public 키워드를 사용하면 된다.
Public Const A As Integer = 10
저작자 표시

'테크' 카테고리의 다른 글

자동 클릭  (0) 2010/08/24
OpenOffice.org Basic Program (2/N)  (0) 2010/08/15
OpenOffice.org Basic Program (1/N)  (0) 2010/08/12
VLC 자막 글꼴이 바뀌지 않는 경우  (0) 2010/08/09
티스토리에 Syntax Highlighter 적용  (0) 2010/08/07
Zone.Identifier 파일  (0) 2010/08/03
Posted by 레타라슈
1. Overview
- Program Lines
줄 단위로 해석을 하는 인터프리트 방식 언어이며 특별히 줄의 마지막을 가리키는 기호를 사용하지 않는다.
만약 한 줄에 많은 내용을 담아야 할 경우 _(underscore)를 사용할 수 있다.
LongExpression	= (Expression1 * Expression2) _
				+ (Expression3 * Expression4) _
				+ (Expression5 * Expression6)
반대로 여러 줄을 한 줄에 나타내기 위해 :(colon)를 사용할 수 있다.
a = 1 : a = a + 1 : a = a + 1

- Comments
주석은 '(apostrophe)를 사용한다.
Dim A	' This comment for variable A is relatively
		' long and stretches over several lines.
		' The comment character must therefore
		' be repeated in each line.

- Markers
변수, 상수, 함수의 이름이 지켜야 할 규칙은 사용하다 보면 알게 된다.
대부분의 프로그래밍 언어가 사용하는 규칙과 많은 차이가 없기 때문에 생략한다.

2. Variables
- Implicit Variable Declaration
언어가 사용하기 쉽게 디자인 되어있어서 명시적으로 변수를 선언하지 않아도 된다.
(문서에는 좋은 프로그래밍 방식이 아니라 비추라 되어있는데, 난 잘 모르겠다.)

- Explicit Variable Declaration
암시적 선언을 강제로 막을 수 있다.
Option Explicit
선언의 쉬운 방법은 어떤 값이든 저장 가능한 가변 타입으로 선언하는 것이다.
Dim MyVar

MyVar = "Hello World"
MyVar = 1
MyVar = 1.0
MyVar = True
타입을 지정해서 선언하는 방법은 아래와 같고, 변수에 타입 기호 넣는 방법도 있다.
Dim MyVar As Integer
Dim MyAnotherVar%
한 줄에 여러 변수를 선언할 수도 있으며, 변수마다 타입은 각각 지정해야 한다.
Dim MyVar1 As Integer, MyVar2 As Integer

- Strings
문자열은 Unicode로 저장되며 하나의 변수에 65535개의 문자를 담을 수 있다.
Dim Variable As String
Dim AnotherVariable$
여러 줄에 문자열을 나타낼 때에는 결합 연산자인 &(ampersand)를 사용하면 된다.
(_에 대해 오타가 아닌가 생각하는 사람은 Program Lines를 다시 읽어보길..)
Dim MyString As String

MyString =	"This string is so long that " & _
			"it has been split over two lines."
문자열 내에 "(quotation) 기호를 넣기 위해서는 두 번 써주면 된다.
Dim MyString As String

MyString = "a ""-quotation mark."

- Numbers
Integer는 -32768 ~ 32767 범위의 숫자를 저장할 수 있다.
Dim Variable As Integer
Dim AnotherVariable%
Long Integer는 -2147483648 ~ 2147483647 범위의 숫자를 저장할 수 있다.
Dim Variable As Long
Dim AnotherVariable&
Single은 어떤 부호든 절대값으로 3.402823x10^38 ~ 1.401298x10^-45 범위의 숫자를 저장할 수 있다.
Dim Variable As Single
Dim AnotherVariable!
Double은 어떤 부호든 절대값으로 1.79769313486232x10^308 ~ 4.94065645841247x10-324 범위의 숫자를 저장할 수 있다.
Dim Variable As Double
Dim AnotherVariable#
Currency는 고정 소수점 변수로 -922337203685477.5808 ~ 922337203685477.5807 범위의 숫자를 저장할 수 있다.
(문서에는 신뢰가 안가는 타입이라 쓰지 말라는 식으로 경고가 붙어있다.)
Dim Variable As Currency
Dim AnotherVariable@
Float은 대입 되는 순간 Single, Double, Currency 중 적절한 타입으로 결정된다.
Dim Variable As Float
(유효숫자 방식 값을 나타내는 방법과 주의할 점은 생략 하겠다.)
16진수난 8진수를 나타내는 방법은 숫자앞에 &H, &O를 붙여주면 된다.
(&O에서 & 뒤는 숫자 0이 아니라 영문자 O다.)
Dim A As Long
Dim B As Long

A = &HFF
B = &O77

- Boolean, Date
숫자 외에 값으로 True, False를 사용하는 Boolean 타입, 날짜나 시간을 저장하는 Date 타입이 있다.
저작자 표시

'테크' 카테고리의 다른 글

자동 클릭  (0) 2010/08/24
OpenOffice.org Basic Program (2/N)  (0) 2010/08/15
OpenOffice.org Basic Program (1/N)  (0) 2010/08/12
VLC 자막 글꼴이 바뀌지 않는 경우  (0) 2010/08/09
티스토리에 Syntax Highlighter 적용  (0) 2010/08/07
Zone.Identifier 파일  (0) 2010/08/03
Posted by 레타라슈