使用下面的代码,在请求其成员获取图标后,我得到一个指向SysListView32桌面的指针:
import ctypes
def GetDesktopListViewHandle():
import ctypes
FindWindow = ctypes.windll.user32.FindWindowW
GetWindow = ctypes.windll.user32.GetWindow
def GetClassName(hwnd):
buff = ctypes.create_unicode_buffer(100)
ctypes.windll.user32.GetClassNameW(hwnd, buff, 99)
return buff.value
from win32con import GW_CHILD
hwnd = FindWindow('Progman', None)
hwnd = GetWindow(hwnd, GW_CHILD) # SHELLDLL_DefView
hwnd = GetWindow(hwnd, GW_CHILD) # SysListView32
if GetClassName(hwnd) != 'SysListView32':
return 0
return hwnd
def ListView_GetItemCount(hwnd):
import commctrl
import ctypes
SendMessage = ctypes.windll.user32.SendMessageW
return SendMessage(hwnd, commctrl.LVM_GETITEMCOUNT, 0, 0)
class LVITEMW(ctypes.Structure):
_fields_ = [
('mask', ctypes.c_uint32),
('iItem', ctypes.c_int32),
('iSubItem', ctypes.c_int32),
('state', ctypes.c_uint32),
('stateMask', ctypes.c_uint32), …Run Code Online (Sandbox Code Playgroud) 这是我目前的计划:
from tkinter import *
from tkinter import messagebox
from collections import deque
class App():
def __init__(self, *images):
self.root = Tk()
self.root.title("Disease")
self.root.bind("<Button-1>", self.click_event)
self.image_dict = {image: PhotoImage(file=image) for image in images}
self.image_queue = deque(images)
start_image = self.image_dict[self.image_queue[0]]
self.label = Label(self.root, image=start_image)
self.label.image = start_image
self.label.pack()
def change_image(self):
self.image_queue.rotate(-1)
next_image = self.image_queue[0]
self.label.configure(image=self.image_dict[next_image])
self.label.image = self.image_dict[next_image]
def click_event(self, event):
print ("clicked at", event.x, event.y )
if (8 < event.x < 241) and (150 < event.y < 232):
messagebox.showinfo("Description", "- Also …Run Code Online (Sandbox Code Playgroud)