프로그래밍

3일차 코딩배우는데... 돈줄게 알려줘

제목 길게 쓰면 안들어올거 같아서ㅠㅠ 말 짧게 썼어요 미안해요. 파이썬 혼자 독학해서 나름 다 만들었다구 생각했는데 창이 떴다 꺼져요. 조그맣지만 수정+꿀팁 주실분에게 5천원 혹은 커피 보내드릴게요ㅠㅠ 

 

주변에 프로그래머가 없어서 물어볼 분이 없어요ㅠㅠ 코린이에게 도움주실 천사분 댓글 달아주세요. 

 

파일이 안올라가는데 gpu 체크 자동 클릭(원래 클릭 안겹치게) 디스플레이와 작업표시줄별 계산+ 창 안보이게.. 이건데.. 왜 안먹는지ㅠㅠ

 

이쁘게 만들고 싶어서 이미지 뜨고 더블클릭해서 실행되게 만드는것도 실패했어요

----------------------------------------------------

import time
import psutil
import os
import pygame
import pyautogui

# 좌표 및 디스플레이 정보
coordinates_set1 = [
    {'click': (2383, 779), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1081}},
    {'click': (2383, 779), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1081}},
    {'click': (2383, 779), 'display_info': {'width': 2560, 'height': '1600', 'taskbar_height': 1081}},
    {'click': (2308, 1184), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 811}},
]

coordinates_set2 = [
    {'click': (1612, 552), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1232}},
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},
    {'click': (2176, 794), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1071}},
    {'click': (2190, 778), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1081}},
    {'click': (2190, 778), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1081}},
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},
]

coordinates_set3 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}},  
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1968, 788), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1075}10
    {'click': (2023, 785), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1077}10
    {'click': (2023, 785), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1077}10
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},  
]

coordinates_set4 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1803, 799), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1067}
    {'click': (1802, 799), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1067}
    {'click': (1802, 799), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1067}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}}, 
]

coordinates_set5 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1623, 772), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1085}
    {'click': (1623, 772), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1085}
    {'click': (1623, 772), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1085}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},  
]

coordinates_set6 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1366, 791), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1073}
    {'click': (1366, 791), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1073}
    {'click': (1366, 791), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1073}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},  
]

coordinates_set7 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (2386, 542), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1239}
    {'click': (2386, 542), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1239}
    {'click': (2386, 542), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1239}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}
]

coordinates_set8 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (2221, 532), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1245}
    {'click': (2221, 532), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1245}
    {'click': (2221, 532), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1245}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},  
]

coordinates_set9 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (2019, 528), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1248}
    {'click': (2019, 528), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1248}
    {'click': (2019, 528), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1248}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}}, 
]

coordinates_set10 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1809, 567), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1222}
    {'click': (1809, 567), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1222}
    {'click': (1803, 575), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1217}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}}, 
]

coordinates_set11 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1592, 468), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1288}
    {'click': (1592, 468), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1288}
    {'click': (1592, 468), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1288}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}},  
]

coordinates_set12 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
    {'click': (445, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (943, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}},  
    {'click': (1441, 1235), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 777}}, 
    {'click': (1397, 484), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1277}
    {'click': (1397, 484), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1277}
    {'click': (1397, 484), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1277}
    {'click': (2208, 1188), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 808}
]

coordinates_set13 = [
    {'click': (1615, 557), 'display_info': {'width': 2560, 'height': 1600, 'taskbar_height': 1229}}, 
]


# Add coordinates for set 3, set 4, ..., set 12

# Add coordinates for set 13, set 14, ..., set 24

mp3_path_set1 = os.path.join("ANYMACRO", "song", "jjanggu_3sec.mp3")
mp3_path_set2 = os.path.join("ANYMACRO", "song", "yoasoibi_2min.mp3")
# You can change the mp3_path_set2 to the path of other mp3 files later

def check_gpu_usage():
    gpu_percent = psutil.cpu_percent(interval=1, percpu=False)
    return gpu_percent


# GPU 사용율 체크 함수
def check_gpu_and_play_mp3():
    # GPU 사용율 30초간 체크
    start_time = time.time()
    while time.time() - start_time < 30:
        gpu_percent = check_gpu_usage()
        print(f"GPU 사용율: {gpu_percent}%")

        # 50% 미만인 경우
        if gpu_percent < 50:
            print("GPU 사용율이 50% 미만입니다. 다음 단계로 넘어갑니다.")
            return

        # 50% 이상인 경우
        if gpu_percent >= 50:
            print("GPU 사용율이 50%를 넘습니다.")
            time.sleep(10)  # 10초 대기

            # 10초 후 재측정
            gpu_percent_after_10s = check_gpu_usage()
            if gpu_percent_after_10s >= 50:
                print("10초 후에도 GPU 사용율이 50%를 넘습니다.")

                # 50% 이상을 유지하는 경우
                start_time_50 = time.time()
                while time.time() - start_time_50 < 90:
                    gpu_percent_now = check_gpu_usage()
                    print(f"현재 GPU 사용율: {gpu_percent_now}%")
                    time.sleep(1)

                    # GPU 사용율이 10% 이하로 내려갔을 때
                    if gpu_percent_now <= 10:
                        print("GPU 사용율이 10% 이하로 내려갔습니다.")
                        time.sleep(90)  # 1분 30초 대기
                         play_mp3(os.path.join("ANYMACRO", "song", "jjanggu_3sec.mp3"))  # mp3 재생
                        return
            else:
                print("10초 후 GPU 사용율이 50%를 넘지 못했습니다.")
                return

def play_mp3(file_path):
    pygame.mixer.init()
    pygame.mixer.music.load(file_path)
    pygame.mixer.music.play()
    while pygame.mixer.music.get_busy():
        pygame.time.Clock().tick(10)

def click_coordinates_set(coordinates_set):
    for coord_info in coordinates_set:
        click_point = coord_info['click']
        display_info = coord_info['display_info']
        taskbar_height = display_info.get('taskbar_height', 0)

        # Adjust coordinates based on display information, taskbar height, and Windows scaling factor
        adjusted_click_point = (
            int(click_point[0] * display_info['width'] / 2560),
            int((click_point[1] + taskbar_height) * display_info['height'] / 1600)
        )

        # Click at adjusted coordinates
        pyautogui.click(adjusted_click_point)

def main():
    # 반복 실행
    for _ in range(12):
        # 좌표 4군데를 찍는다
        click_coordinates_set(coordinates_set1)

        # GPU 사용율 체크 함수
        def check_gpu_and_play_mp3():
            # GPU 사용율 30초간 체크
            start_time = time.time()
            while time.time() - start_time < 30:
                    gpu_percent = check_gpu_usage()
            print(f"GPU 사용율: {gpu_percent}%")

                # 50% 미만인 경우
                if gpu_percent < 50:
                    print("GPU 사용율이 50% 미만입니다. 다음 단계로 넘어갑니다.")
                    return

                # 50% 이상인 경우
                if gpu_percent >= 50:
                    print("GPU 사용율이 50%를 넘습니다.")
                    time.sleep(10)  # 10초 대기

                    # 10초 후 재측정
                    gpu_percent_after_10s = check_gpu_usage()
                    if gpu_percent_after_10s >= 50:
                        print("10초 후에도 GPU 사용율이 50%를 넘습니다.")

                        # 50% 이상을 유지하는 경우
                        start_time_50 = time.time()
                        while time.time() - start_time_50 < 90:
                            gpu_percent_now = check_gpu_usage()
                            print(f"현재 GPU 사용율: {gpu_percent_now}%")
                            time.sleep(1)

                             # GPU 사용율이 10% 이하로 내려갔을 때
                                if gpu_percent_now <= 10:
                                    print("GPU 사용율이 10% 이하로 내려갔습니다.")
                                    time.sleep(90)  # 1분 30초 대기
                                    play_mp3(os.path.join("ANYMACRO", "song", "jjanggu_3sec.mp3"))  # mp3 재생
                                    return
                else:
                    print("10초 후 GPU 사용율이 50%를 넘지 못했습니다.")
                    return

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set2)
       
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set3)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set4)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set5)
        
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set6)
        
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set7)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set8)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set9)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set10)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set11)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

        # 좌표 8군데를 찍는다
        click_coordinates_set(coordinates_set12)
        
        # GPU 사용율 체크 함수
        check_gpu_and_play_mp3()

    # 추가로 좌표 13까지 찍는다 (coordinates_set13 사용)  
    click_coordinates_set(coordinates_set13)
        
    # 13세트가 끝난 후 yoasoibi_2min.mp3 재생
    play_mp3(os.path.join("ANYMACRO", "song", "yoasoibi_2min.mp3")))

if __name__ == "__main__":
    main()
 

 

3개의 댓글

2024.01.20

import os

os.system('pause')

 

파이썬 콘솔창꺼짐 방지는 이거라는디

0
2024.01.20

커피 아직 있음??

0
2024.01.21

3일자에 저정도라니 ㄷㄷ

0
무분별한 사용은 차단될 수 있습니다.
번호 제목 글쓴이 추천 수 날짜 조회 수
5693 [프로그래밍] 요즘 모바일 개발은 어떤 걸 사용하나요? 12 커피좋아용 0 1 일 전 266
5692 [프로그래밍] 취준생 안드로이드 팀플 주제 머할까요... 8 조강현 0 1 일 전 195
5691 [프로그래밍] 공통코드테이블은 대체 왜 만드냐 9 잠적자 0 3 일 전 400
5690 [프로그래밍] 토이프로젝트 주제 선정 3 개드립눈팅1세대 0 3 일 전 213
5689 [프로그래밍] 엥 구글 플러터 유기각 재는거임?? 4 최수연 0 5 일 전 335
5688 [프로그래밍] 반도체 장비 업계인 있음? 9 캡틴띠모 0 6 일 전 288
5687 [프로그래밍] 안드로이드 책 추천좀 6 집에가게해줘 0 7 일 전 153
5686 [프로그래밍] 폰 스크리닝 해 본 사람 있어? 3 무지개빛푸딩 0 7 일 전 389
5685 [프로그래밍] jsp 트리메뉴 만들고있는데 구상한게가능한지 의견좀물어볼께 11 평택국 0 8 일 전 167
5684 [프로그래밍] JPA 도와줘어억 ㅠ 10 모그리또 0 8 일 전 251
5683 [프로그래밍] 의사는 뽑는 인원 제한하는데 부캠은 왜 제한 안 할까 5 조강현 0 10 일 전 373
5682 [프로그래밍] 그 혹시 게임쪽 종사자 있음? 17 god79ii 0 14 일 전 633
5681 [프로그래밍] 코린이 ㅅㅂ 뭐가 문젠지 모르겠어요 9 집에가게해줘 0 14 일 전 450
5680 [프로그래밍] Dear Imgui 라고 아시나요? 2 년째모쏠 0 14 일 전 246
5679 [프로그래밍] 현업개발자분들 주말엔 편하게 쉴수있나요? 10 키로 0 15 일 전 873
5678 [프로그래밍] 무엇이든 물어보세요. 28 변현제 0 17 일 전 417
5677 [프로그래밍] 개발자보단 엔지니어가 취업이 잘됨 5 iillillill 2 18 일 전 750
5676 [프로그래밍] 프론트엔드 개발자 연봉 1억 넘는 사람 있어? 13 잠적자 0 18 일 전 649
5675 [프로그래밍] Exiftool 이거 일본어 못 읽는데 13 부터시작하는이세... 0 20 일 전 236
5674 [프로그래밍] 반응형 웹페이지가 내가상상한거랑 좀 다르네 4 평택국 0 21 일 전 456