Cat holds computer components shop.
Child yells "20 years" and falls from kindergarten roof to his death.
20100723
20100719
20100716
0xac (prg05)
#language :: c/c++ (mingw)
#purpose :: alarm clock
#date :: 16072010
#author :: gerganov
Information...
*uncommented code
*winapi bloats the exe
*open source (no license)
*prevents os standby/sleep
*with command line argument
*with countdown
http://roboet.hit.bg/blog_storage/0xac.zip
#searchterms :: prevent laptop from going to sleep, prevent windows from going to sleep, stop standby, prevent standby, prevent computer from going to sleep
#purpose :: alarm clock
#date :: 16072010
#author :: gerganov
Information...
*uncommented code
*winapi bloats the exe
*open source (no license)
*prevents os standby/sleep
*with command line argument
*with countdown
http://roboet.hit.bg/blog_storage/0xac.zip
#searchterms :: prevent laptop from going to sleep, prevent windows from going to sleep, stop standby, prevent standby, prevent computer from going to sleep
_getch() (prg04)
#language :: c/c++ (mingw)
#purpose :: winapi getch implement
#date :: 16072010
#author :: gerganov
TCHAR _getch()
{
         DWORD mode;
         TCHAR chr = 0;
         DWORD cnt;
         //get a handle to stdin
         HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
         //save the current input mode...
         GetConsoleMode(hStdIn,&mode);
         // Clear the mode
         // turn off ENABLE_ECHO_INPUT
         // and ENABLE_LINE_INPUT
         // so that the output will not be echoed
         // and will not pause until the end of
         // a line for input.
         SetConsoleMode(hStdIn,0);
         // Read in 1 char from the input buffer.
         ReadConsole(hStdIn,&chr,sizeof(TCHAR),&cnt,NULL);
         //restore the current input mode.
         SetConsoleMode(hStdIn, mode);
         return chr;
}
#searchterms :: winapi getch implement, readconsole getch, _getch(), getch(), press a key to continue, pause program, no echo get, get char, winapi getch, conio.h getch, winapi conio.h
#purpose :: winapi getch implement
#date :: 16072010
#author :: gerganov
TCHAR _getch()
{
         DWORD mode;
         TCHAR chr = 0;
         DWORD cnt;
         //get a handle to stdin
         HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
         //save the current input mode...
         GetConsoleMode(hStdIn,&mode);
         // Clear the mode
         // turn off ENABLE_ECHO_INPUT
         // and ENABLE_LINE_INPUT
         // so that the output will not be echoed
         // and will not pause until the end of
         // a line for input.
         SetConsoleMode(hStdIn,0);
         // Read in 1 char from the input buffer.
         ReadConsole(hStdIn,&chr,sizeof(TCHAR),&cnt,NULL);
         //restore the current input mode.
         SetConsoleMode(hStdIn, mode);
         return chr;
}
#searchterms :: winapi getch implement, readconsole getch, _getch(), getch(), press a key to continue, pause program, no echo get, get char, winapi getch, conio.h getch, winapi conio.h
20100714
dir(skype2mail.elements) (prg03)
#language :: python (2.6.4)
#date :: 14072010
#author :: gerganov
#============================================
#List processes and check if process is running...
import win32com.client
WMI = GetObject('winmgmts:')
processes = WMI.InstancesOf('Win32_Process')
procnames = [process.Properties_('Name').Value for process in processes]
for name in procnames:
         #check for name here
#============================================
#============================================
#Send e-mail with attachment(s) from Outlook Client...
import win32com.client
def sendmail(txt, sbj, rec, prf="Outlook"):
         s = win32com.client.Dispatch("Mapi.Session")
         o = win32com.client.Dispatch("Outlook.Application")
         s.Logon(prf)
         emsg = o.CreateItem(0)
         emsg.To = rec #can be added as argument, if multiple
         emsg.Subject = sbj
         emsg.Body = txt
         attachment1 = "..." #can be added as argument, if mulptiple
         emsg.Attachments.Add(attachment1)
         emsg.Send()
         s.Logoff()
         return
#============================================
#============================================
#Use Skype4Py and Python for Skype manipulation (SkypeAPI)...
import Skype4Py #http://sourceforge.net/projects/skype4py/
skype = Skype4Py.Skype()
skype.Attach() #Skype spawns a dialog - press Allow
#dir(skype) for available Functions and Variables
#documentation - http://skype4py.sourceforge.net/doc/html/
#============================================
#============================================
#Sleep with countdown...
def vsleep(act,sec):
         while(sec!=0):
                 print act + "(" + str(sec) + ") \r",
                 time.sleep(1.0)
                 sec -= 1
         print " "
         return
#============================================
#============================================
#Send e-mail from GMail with Python using Google as SMTP...
import os
import smtplib
import mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Encoders import encode_base64
def googlesend(sbj, txt, *atts):
         gmuser = 'x@gmail.com'
         gmpass = 'xpass'
         gmrecp = 'x@xdomain.xxx'
         msg = MIMEMultipart()
         msg['From'] = gmuser
         msg['To'] = recp
         msg['Subject'] = sbj
         msg.attach(MIMEText(txt))
         for att in atts:
                 msg.attach(getattachment(att))
         mailsvr = smtplib.SMTP('smtp.gmail.com', 587)
         mailsvr.ehlo()
         mailsvr.starttls()
         mailsvr.ehlo()
         mailsvr.login(gmuser, gmpass)
         mailsvr.sendmail(gmuser, recp, msg.as_string())
         mailsvr.close()
         return
def getatts(att):
         contentType, encoding = mimetypes.guess_type(att)
         if contentType is None or encoding is not None:
                 contentType = 'application/octet-stream'
         mainType, subType = contentType.split('/', 1)
         file = open(att, 'rb')
         if mainType == 'text':
                 attachment = MIMEText(file.read())
         elif mainType == 'message':
         attachment = email.message_from_file(file)
         elif mainType == 'image':
         attachment = MIMEImage(file.read(),_subType=subType)
         elif mainType == 'audio':
                 attachment = MIMEAudio(file.read(),_subType=subType)
         else:
                 attrdy = MIMEBase(mainType, subType)
         attrdy.set_payload(file.read())
         encode_base64(attrdy)
         file.close()
         attrdy.add_header('Content-Disposition', 'attachment', filename=os.path.basename(att))
         return attrdy
#============================================
#searchterms :: python and win32com, send outlook e-mail with python, send mail with python, google send mail with python, python skype, skype4py, python and skype4py, documentation skype4py, python list processes, find process python
#date :: 14072010
#author :: gerganov
#============================================
#List processes and check if process is running...
import win32com.client
WMI = GetObject('winmgmts:')
processes = WMI.InstancesOf('Win32_Process')
procnames = [process.Properties_('Name').Value for process in processes]
for name in procnames:
         #check for name here
#============================================
#============================================
#Send e-mail with attachment(s) from Outlook Client...
import win32com.client
def sendmail(txt, sbj, rec, prf="Outlook"):
         s = win32com.client.Dispatch("Mapi.Session")
         o = win32com.client.Dispatch("Outlook.Application")
         s.Logon(prf)
         emsg = o.CreateItem(0)
         emsg.To = rec #can be added as argument, if multiple
         emsg.Subject = sbj
         emsg.Body = txt
         attachment1 = "..." #can be added as argument, if mulptiple
         emsg.Attachments.Add(attachment1)
         emsg.Send()
         s.Logoff()
         return
#============================================
#============================================
#Use Skype4Py and Python for Skype manipulation (SkypeAPI)...
import Skype4Py #http://sourceforge.net/projects/skype4py/
skype = Skype4Py.Skype()
skype.Attach() #Skype spawns a dialog - press Allow
#dir(skype) for available Functions and Variables
#documentation - http://skype4py.sourceforge.net/doc/html/
#============================================
#============================================
#Sleep with countdown...
def vsleep(act,sec):
         while(sec!=0):
                 print act + "(" + str(sec) + ") \r",
                 time.sleep(1.0)
                 sec -= 1
         print " "
         return
#============================================
#============================================
#Send e-mail from GMail with Python using Google as SMTP...
import os
import smtplib
import mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Encoders import encode_base64
def googlesend(sbj, txt, *atts):
         gmuser = 'x@gmail.com'
         gmpass = 'xpass'
         gmrecp = 'x@xdomain.xxx'
         msg = MIMEMultipart()
         msg['From'] = gmuser
         msg['To'] = recp
         msg['Subject'] = sbj
         msg.attach(MIMEText(txt))
         for att in atts:
                 msg.attach(getattachment(att))
         mailsvr = smtplib.SMTP('smtp.gmail.com', 587)
         mailsvr.ehlo()
         mailsvr.starttls()
         mailsvr.ehlo()
         mailsvr.login(gmuser, gmpass)
         mailsvr.sendmail(gmuser, recp, msg.as_string())
         mailsvr.close()
         return
def getatts(att):
         contentType, encoding = mimetypes.guess_type(att)
         if contentType is None or encoding is not None:
                 contentType = 'application/octet-stream'
         mainType, subType = contentType.split('/', 1)
         file = open(att, 'rb')
         if mainType == 'text':
                 attachment = MIMEText(file.read())
         elif mainType == 'message':
         attachment = email.message_from_file(file)
         elif mainType == 'image':
         attachment = MIMEImage(file.read(),_subType=subType)
         elif mainType == 'audio':
                 attachment = MIMEAudio(file.read(),_subType=subType)
         else:
                 attrdy = MIMEBase(mainType, subType)
         attrdy.set_payload(file.read())
         encode_base64(attrdy)
         file.close()
         attrdy.add_header('Content-Disposition', 'attachment', filename=os.path.basename(att))
         return attrdy
#============================================
#searchterms :: python and win32com, send outlook e-mail with python, send mail with python, google send mail with python, python skype, skype4py, python and skype4py, documentation skype4py, python list processes, find process python
Subscribe to:
Posts (Atom)