r/learnprogramming • • Mar 26 '17

New? READ ME FIRST!

825 Upvotes

Welcome to /r/learnprogramming!

Quick start:

  1. New to programming? Not sure how to start learning? See FAQ - Getting started.
  2. Have a question? Our FAQ covers many common questions; check that first. Also try searching old posts, either via google or via reddit's search.
  3. Your question isn't answered in the FAQ? Please read the following:

Getting debugging help

If your question is about code, make sure it's specific and provides all information up-front. Here's a checklist of what to include:

  1. A concise but descriptive title.
  2. A good description of the problem.
  3. A minimal, easily runnable, and well-formatted program that demonstrates your problem.
  4. The output you expected and what you got instead. If you got an error, include the full error message.

Do your best to solve your problem before posting. The quality of the answers will be proportional to the amount of effort you put into your post. Note that title-only posts are automatically removed.

Also see our full posting guidelines and the subreddit rules. After you post a question, DO NOT delete it!

Asking conceptual questions

Asking conceptual questions is ok, but please check our FAQ and search older posts first.

If you plan on asking a question similar to one in the FAQ, explain what exactly the FAQ didn't address and clarify what you're looking for instead. See our full guidelines on asking conceptual questions for more details.

Subreddit rules

Please read our rules and other policies before posting. If you see somebody breaking a rule, report it! Reports and PMs to the mod team are the quickest ways to bring issues to our attention.


r/learnprogramming • • 2d ago

What have you been working on recently? [November 28, 2026]

6 Upvotes

What have you been working on recently? Feel free to share updates on projects you're working on, brag about any major milestones you've hit, grouse about a challenge you've ran into recently... Any sort of "progress report" is fair game!

A few requests:

  1. If possible, include a link to your source code when sharing a project update. That way, others can learn from your work!
  2. If you've shared something, try commenting on at least one other update -- ask a question, give feedback, compliment something cool... We encourage discussion!
  3. If you don't consider yourself to be a beginner, include about how many years of experience you have.

This thread will remained stickied over the weekend. Link to past threads here.


r/learnprogramming • • 1h ago

Resource Suggestion: Advent of Code starts tonight!

7 Upvotes

For those seeking out a more advanced programming challenge, the yearly Advent Of Code will commence on December 1st.

It's an advent calendar of programming prompts/challenges. Each evening at midnight for the first 12 days of December, a new puzzle will unlock at midnight EST. Each puzzle provides you with an input and asks you to use programming to calculate some result.

There are no limits to what languages, tools, etc. can be used. There are no prizes. The challenge is free for everyone.

The problems are often quite challenging. Even professional programmers often get stuck on some of them. This is probably not an event for folks who are just starting out with coding. But for more advanced learners, fighting with the problems and then going to the discussion threads to see the many different ways that programmers solve them can be very educational.

There's a very active subreddit for the event: r/adventofcode.

Happy coding!

Disclaimer: I am not in any way affiliated. I'm just a fan.


r/learnprogramming • • 16h ago

How to improve logical thinking in programming

56 Upvotes

Hey

I'm 23m working professional,

Yesterday at the office my team lead said he found a pattern in my work

He said I'm mugging up patterns and not thinking logically.

Well I do codeforces , leetcode, hacker rank to improve my programming skills but I understood that he was right

All I do is find a pattern in the problem and try to solve it

Anytime I find a new problem I'm stuck

Because I never saw that before

How to come up with my own solution?? How to improve problem solving and logical thinking???

Open to all the suggestions:)


r/learnprogramming • • 2h ago

Discussion How can I focus longer on programming?

4 Upvotes

I'm a creative person. I like creating things, and I would love to create my own apps and programs. However, I find it hard to concentrate on programming, and I found out that it's not something that I can just do whenever, for example, something like video editing. No, I have to fully concentrate on programming the whole way unless I have already learned something and I have to recall it.
I don't have ADHD. Could this be solved?


r/learnprogramming • • 5h ago

Coding Refresher

6 Upvotes

Is there a free/relatively inexpensive resource for relearning/practicing code?

I was starting to make a lot of strides towards my projects, but after getting this Helpdesk job my time shrank and with it my coding skills.

I was mostly learning C# for unity and started a little C++ after unity pulled the Runtime fee thing, but I really want a way to be able to sit and practice code like an instrument - doing runs, scales, following sheets/tabs, ya know? Just something to help the muscle memory and build a better understanding


r/learnprogramming • • 13h ago

Topic I’m curious, how many languages are you “fluent” in?

18 Upvotes

Basically the title. Which language(s)? Was it work, school, or a personal project that pulled you toward said language? I’m just curious about the ways people “settle in” so to speak.

Please don’t be “clever” and say English because I said fluent instead of proficient…I beg you.


r/learnprogramming • • 1h ago

Topic How do you learn Hosting and Deployment for free?

1 Upvotes

I have been working in MERN stack and have build some projects. But i've never really deployed any of my apps. I have searched on different platforms for resources fo learn deployment but its always tied to some paid service or a credit card information. I was thinking of building my own VPS, and somehow make it publicly accessible instead of Local Network. Can someone help me?


r/learnprogramming • • 13h ago

What programming language should I focus on as an occasional hobbyist?

6 Upvotes

As in, I sit down to code for a few hours once a month, give or take.

I've been chugging along on a text-based game in TypeScript with Vue. I'm constantly running into quirks and hidden nuances of the languages. Spending my precious hours figuring out the difference between interfaces and types, only to learn that it's pretty much personal preference, makes me feel like I'm wasting time due to the language choice.

Also the fact that I have to juggle several languages with their idiosyncracies: HTML, CSS, TypeScript, JavaScript (when it offers its own quirk), Vue, JSON. Forgetting one language then having to get back into it.

Can I have a more straightforward language? Maybe I should go to just bare JavaScript? I've used several languages in the past, including Java, C#, Python, Lua.


r/learnprogramming • • 4h ago

1st Year Tier-1 CSE: Am I too late for C++ and DSA? Already did some ML.

0 Upvotes

Hey everyone,

I am a first-year CSE student at a tier-1 college. My first semester is ending on December 4th. I am planning to start learning C++ and Data Structures & Algorithms (DSA) now, but I am worried—am I starting too late?

To give some context: I didn't learn much during the first 1.5 to 2 months of college. However, over the last 1.5 months, I have been diving into Data Science and Machine Learning. I've been studying from Data Science from Scratch by Joel Grus and Introduction to Statistical Learning with Python (ISLP).

Currently, I am quite comfortable with Python and its core libraries, including NumPy, Pandas, Matplotlib, Seaborn, and Scikit-Learn. I feel I have built a solid foundation in ML and understand the basic math behind common algorithms like Random Forests, Decision Trees, Gradient Boosting, Linear Regression, XGBoost, HistGradientBoosting, AdaBoost, CatBoost, KNN, K-Means clustering, DBSCAN, and hierarchical modeling. I am also familiar with various model evaluation techniques.

Despite this, I feel an underlying anxiety because I haven't started DSA yet. A lot of my peers are already active on platforms like LeetCode and Codeforces, or are following Striver's sheets.

Given my current progress and the peer pressure, am I actually lagging behind, or is starting DSA in the second semester perfectly fine? I would love to get some perspective and advice on how to balance my ML interest with competitive programming/DSA moving forward.

Thanks!


r/learnprogramming • • 1d ago

Cybersecurity, game development, or deep learning? I can't decide.

40 Upvotes

I'm genuinely interested in all three, and that's the problem.

I've been learning programming and recently completed MIT 6.100L. Now I'm trying to figure out what to explore next.

Cybersecurity, game development, deep learning all three sound equally exciting to me, and I can't seem to settle on one.

For those of you who've been in a similar situation, how did you decide what to pursue? Did you just pick one and see where it took you, or did you find a way to explore everything?

I'd love to hear your experiences and advice.


r/learnprogramming • • 23h ago

I have no A-levels. Am I likely to succeed in software engineering?

7 Upvotes

(Sorry if this is the wrong subreddit)

Like the title says, I have no A-levels as I went to college because I had different goals at the time. I’m happy to put in the time and money into courses like python, Java, C++ and others I need to know as well as study at the open university. So am I likely to succeed in software engineering without A-levels but with programming courses and an open university degree?


r/learnprogramming • • 11h ago

GitHub

0 Upvotes

请问在哪里可以学GitHub的入门知识?谢谢


r/learnprogramming • • 1d ago

Looking for project ideas that solve real-world problems (Java + React + microservices) - not another e-commerce clone

4 Upvotes

Hi everyone,

I'm a final-year / PG diploma student (India) and I need to finalize a project topic in the next day or so. Most project lists I've seen are full of e-commerce, "X Management System", and booking apps, and I'd like to build something that solves an actual problem for actual users.

Tech stack I'm planning to use:

- Backend: Java, Spring Boot, Spring Cloud (API Gateway, Eureka/service discovery, config server)

- Frontend: React

- Architecture: Microservices (REST + event-driven where it makes sense, e.g. Kafka or RabbitMQ)

- Auth: Spring Security with JWT / OAuth2 (Keycloak is also an option)

- Database: open to suggestions (PostgreSQL / MySQL / MongoDB, Redis for caching)

- DevOps: Docker, GitHub Actions for CI/CD

- Optional: I'm open to ASP.NET Core for one or two services if the idea benefits from it

What I'm looking for:

- A real problem you've personally faced, or seen in your city, college, workplace, or local businesses

- Something that naturally needs multiple services (e.g. auth, notifications, payments, scheduling, analytics) and doesn't force microservices just for the sake of it

- Scope that a team of [2-4] can build in about [2-3 months]

- Bonus if it has a clear MVP and a few stretch features

What I'd like from your replies:

  1. The problem statement in 1-2 lines
  2. Who the users are
  3. Which services you'd split it into (a rough idea is enough)
  4. Any gotchas you'd warn me about

I've already considered things like clinic queue management, group expense splitting, and water tanker booking, so if you have ideas beyond those, I'd love to hear them. Honest feedback on my stack choices is also welcome.

Thanks in advance!


r/learnprogramming • • 1d ago

Looking for ideas for an app to build for my high school graduation project

4 Upvotes

Hi everyone!
I’m looking for ideas for an app to develop as my high school graduation project.
I’m currently in my final year of a technical high school, studying Information Technology, and I have to create a project for my Programming class. I’ve decided that I want to build an application, but I’m not particularly good at coming up with ideas, so I thought I’d ask for your help!
Is there an app you’ve always wished existed? Something that would make your everyday life easier, either for you or your children? Maybe something interesting, helpful, practical, or just genuinely useful?
I’m open to absolutely anything. It doesn’t matter which programming language would be used, whether the app requires a database or not, or how complex the idea is. At this point, I mainly need an idea or a concept that I could turn into an actual application for my graduation project.
I’d really appreciate any suggestions, no matter how big or small!
Thanks in advance to everyone who takes the time to share an idea!


r/learnprogramming • • 1d ago

Languages What should i consider when choosing between C++ and Rust as my main programming language

4 Upvotes

Currently i only really plan on programming simple tools for myself but in the future i also need to learn programming for engineering. What should i consider when choosing between the two, what are some important considerations and what should i be aware of?


r/learnprogramming • • 1d ago

Looking for recommendations: Best resources to learn DSA from scratch

24 Upvotes

Hello everyone!

I am a first-year Computer Science and Engineering (CSE) student, and I want to start learning Data Structures and Algorithms (DSA) from the absolute ground up.

Could anyone suggest high-quality websites, books, or courses that are beginner-friendly?

I would also love to hear any tips, strategies, or roadmaps you wish you knew when you were starting out.

Thanks in advance for your help!


r/learnprogramming • • 15h ago

LLM What does your agentic coding workflow actually look like?

0 Upvotes

I'm a C++ developer and I've been trying to get more into agentic coding lately, but I'm struggling to find a workflow that actually makes sense to me.

Currently, I see three different approaches:

1. Just let the agent do its thing: I'm obviously much faster initially, but I gradually lose the understanding of my own codebase. Apart from unit tests, the observable behavior of the software and trusting the AI, I don't really know what's happening under the hood. In a personal simulation project, I only noticed some pretty inefficient solutions regarding performance and memory consumption because I happened to look at the implementation.

2. Read and review all the generated code: For this, I need to keep the tasks relatively small so I can properly understand and critically review the code. All those micro-decisions regarding ownership, data structures, unnecessary copies, etc. that I naturally think about while writing code now need to be understood retrospectively. But if I specify everything in great detail, it feels like I'm just programming in natural language and mostly saving myself the typing.

3. Use AI the way I already do at work: Mostly for rubber ducking, boilerplate, interfaces or implementations where I already know how I would write them myself.

But I constantly read about people becoming several times more productive through agentic coding, and I'm starting to wonder whether I'm fundamentally doing something wrong.

  • Do you still read and understand all the generated code?
  • How big are the tasks you delegate, and when do you decide to write something yourself?
  • How do you deal with comprehension debt and the potential technical debt resulting from it?
  • How much time do you actually save when factoring in code review, debugging and maintenance?

I'm not trying to argue against agentic coding. I'm genuinely trying to understand how other people work with it. Right now, it feels like a trade-off between development speed and my own understanding of the software.

I'd especially be interested in hearing from developers working on larger, long-lived software projects, e.g. systems programming, embedded software or simulation, rather than relatively simple CRUD applications or throwaway prototypes.


r/learnprogramming • • 1d ago

Tutorial Django tutorials

0 Upvotes

I have started practicing Django, I created a simple student admission page:
• ⁠Student fills form
• ⁠Django validation takes place
• ⁠After validation data is stored in database
I used DRF for the validation, and aws PostgreSQL and this is a simple thing I want to use to start my journey in backend dev.
Hosted it on render free tier and when I hit the submit button I used a stopwatch to check how it took to submit and it was 00:00:22.23.
Please I’m still learning and I want to know if it’s okay to have that time for submitting and if not what should I study next and I used the DRF for the form validation with an if statement.

Thank you for feedback and time.


r/learnprogramming • • 1d ago

Computer sci tips pls

5 Upvotes

Currently i’m learning DSA (Divide and conquer, stack and queue, Binary search, Greedy….etc) and Back End development (Express.js, node.js……etc) and I need some tips or maybe some resources that could help me.

Also i feel like computer science isn’t for me. I mean it’s normal to feel that way but i’m still trying to find ways to enjoy CS


r/learnprogramming • • 1d ago

If you had 3 months off this winter, what would you focus on?

29 Upvotes

Imagine you had three months completely free this winter.
You have some experience with competitive programming, a decent foundation in math and computer science, and enjoy solving problems on LeetCode and Codeforces.
You're still learning, don't have a particular area of interest yet, but you're disciplined and enjoy challenging yourself.
How would you spend those three months to become a better programmer and software engineer? What would you focus on?


r/learnprogramming • • 1d ago

I really need some advice / venting

6 Upvotes

So i'm a junior in college and i have no internships lined shit i barely have any projects and i just don't know what to do anymore. Majority of the time I've applied I get nothing or maybe I get a coding assessment where I fail it. I understand my resume is probably horrible but I don't know what to do to make it a better. I keep hearing the same things make something you care about, make it technical, do this that and wtv else. HOW??? I can barely keep manage both classes and actually make projects then to practice. It's not as if I spend my time outside of classes doing anything social. So I pretty much have 'unlimited' time to get better. I heard use ai to advance your projects but then I don't know what my project is even about, I heard don't use ai and write manually but then it takes me forever to even finish one stupid project, I heard use ai to prompt and learn along I tried that it feels so fucking boring. It feels like i'm child asking "hey is this good enough?" It's so fucking stupid man. I understand someone would say just "suck it up and continue" and I've been trying to. Outside of all of that look at how ai is advancing, how am i supposed to keep up? how am i supposed to be good enough? even if I am then i get laid off? I'm sorry if I'm coming off very negative but I felt like shit about this and I don't know what to do anymore. I don't want to fail but it feels like that's what going to happen. Anyone could please give me some advice or just reinsurancement idk. I tried to be positive about this in the beginning but I genuinely don't know what to do anymore. I'm so scared.


r/learnprogramming • • 2d ago

Topic [Homework] How is Go actually standardized if there's no ISO standard? (Conflicting answers)

30 Upvotes

Hola a todos,

Estoy trabajando en una tarea sobre la estandarización de lenguajes de programación. Dado que Go no está regulado por un organismo externo como ISO o ECMA, he estado investigando qué reglas sigue, pero encuentro respuestas contradictorias.

Algunas fuentes señalan la Especificación del Lenguaje Go como lo más parecido a un estándar formal. Otras enfatizan que no existe una base independiente y que el lenguaje está completamente dirigido por el Equipo Go de Google. Por otro lado, algunos argumentan que herramientas como gofmt y la Promesa de Compatibilidad de Go 1 son las que realmente normalizan el ecosistema.

Intento comprender el panorama general para mi tarea. ¿Podría alguien explicarme cómo encajan todas estas piezas?

¿Cuál es la respuesta definitiva? ¿Se considera la Especificación del Lenguaje el estándar oficial, o la estandarización en Go se logra únicamente a través de la gobernanza de Google y las herramientas de la comunidad?

No necesito un ensayo completo, solo una explicación clara de qué debo citar como el "estándar" para Go. ¡Gracias!

En resumen: Go no está estandarizado por la ISO. Si tuvieras que escribir un ensayo sobre cómo se estandariza Go actualmente, ¿qué documentos, entidades o herramientas citarías y por qué?


Thank you all so much for taking the time to answer this thread from a young university student who isn't very familiar with the topic. I truly appreciate it from the bottom of my heart. I'll leave this space open for anyone who wants to continue commenting or learn more about what's below. Without a doubt, I was able to answer my question. Thank you.



r/learnprogramming • • 1d ago

i have a poblem

0 Upvotes

soo i crated my own script for a game to farm but i what the script to farm on the game soo i can do what ever i what on my pc but the script start to tipe on my drscktop can you help me pls

my script
import ctypes

import subprocess

import win32gui

import time

import random

import threading

import keyboard

import tkinter as tk

from tkinter import font as tkfont

import vgamepad as vg

# ── CONFIG ──────────────────────────────────────────────────────────────────

WINDOW_TITLE = "BongoCat" # adjust if title differs in your language

TOGGLE_KEY = "F8"

INTERVAL_MIN = 0.055 # pauza intre cicluri (~10-12 cicluri/sec)

INTERVAL_MAX = 0.085

HOLD_MIN = 0.015 # cat timp stau apasate simultan

HOLD_MAX = 0.025

DEBOUNCE = 0.26

# Ruleaza DOAR cand BongoCat este fereastra activa (evita deschiderea tastaturii cand scrii)

ONLY_WHEN_BONGO_FOCUSED = True

PAUSE_ON_WINDOWS_SEARCH = True

KILL_TOUCH_KEYBOARD = True

# Am scos X / Y / SHARE / OPTIONS pentru a evita scurtaturile tastaturii virtuale

# Disponibile: "CROSS", "CIRCLE", "SQUARE", "TRIANGLE", "L1", "R1", "DPAD_UP", "DPAD_DOWN", "DPAD_LEFT", "DPAD_RIGHT"

KEYS = [

"CROSS",

"CIRCLE",

]

# ────────────────────────────────────────────────────────────────────────────

def _ds4_dpad(attr_name: str):

return getattr(vg.DS4_DPAD_DIRECTIONS, attr_name, None)

DS4_DPAD_NONE_VAL = _ds4_dpad("DS4_DPAD_NONE")

BUTTON_MAP = {

"CROSS": vg.DS4_BUTTONS.DS4_BUTTON_CROSS,

"CIRCLE": vg.DS4_BUTTONS.DS4_BUTTON_CIRCLE,

"SQUARE": vg.DS4_BUTTONS.DS4_BUTTON_SQUARE,

"TRIANGLE": vg.DS4_BUTTONS.DS4_BUTTON_TRIANGLE,

"L1": vg.DS4_BUTTONS.DS4_BUTTON_SHOULDER_LEFT,

"R1": vg.DS4_BUTTONS.DS4_BUTTON_SHOULDER_RIGHT,

"DPAD_UP": _ds4_dpad("DS4_DPAD_NORTH") or _ds4_dpad("DPAD_UP"),

"DPAD_DOWN": _ds4_dpad("DS4_DPAD_SOUTH") or _ds4_dpad("DPAD_DOWN"),

"DPAD_LEFT": _ds4_dpad("DS4_DPAD_WEST") or _ds4_dpad("DPAD_LEFT"),

"DPAD_RIGHT": _ds4_dpad("DS4_DPAD_EAST") or _ds4_dpad("DPAD_RIGHT"),

}

DPAD_BUTTONS = {

"DPAD_UP",

"DPAD_DOWN",

"DPAD_LEFT",

"DPAD_RIGHT",

}

BG_MAIN = "#09090b"

BG_CARD = "#121216"

BG_BTN = "#18181f"

BG_BTN_ACT = "#241322"

BORDER_CLR = "#22222b"

FG_WHITE = "#ffffff"

FG_PINK = "#ff5ec4"

FG_MUTED = "#a1a1aa"

DWMWA_USE_IMMERSIVE_DARK_MODE = 20

DWMWA_CAPTION_COLOR = 35

DWMWA_TEXT_COLOR = 36

gamepad = None

running = False

paused_by_bg = False

lock = threading.Lock()

_last_toggle = 0.0

press_count = 0

elapsed_sec = 0

last_tick_time = None

status_label = None

btn_toggle = None

count_label = None

timer_label = None

title_label = None

root = None

def init_gamepad():

global gamepad

if gamepad is None:

gamepad = vg.VDS4Gamepad()

gamepad.reset()

gamepad.update()

def release_all_gamepad():

try:

if gamepad is not None:

gamepad.reset()

gamepad.update()

except Exception:

pass

def close_touch_keyboard():

if not KILL_TOUCH_KEYBOARD:

return

for proc_name in ("TabTip.exe", "TextInputHost.exe"):

try:

subprocess.run(

["taskkill", "/F", "/IM", proc_name],

stdout=subprocess.DEVNULL,

stderr=subprocess.DEVNULL,

creationflags=subprocess.CREATE_NO_WINDOW,

)

except Exception:

pass

def is_windows_search_active() -> bool:

if not PAUSE_ON_WINDOWS_SEARCH:

return False

try:

hwnd = win32gui.GetForegroundWindow()

if not hwnd:

return False

title = (win32gui.GetWindowText(hwnd) or "").strip().lower()

cls_name = (win32gui.GetClassName(hwnd) or "").strip().lower()

search_titles = {"search", "căutare", "start", "searchhost"}

search_classes = {

"windows.ui.core.corewindow",

"searchui.searchwindow",

"launcherframe",

}

if title in search_titles or cls_name in search_classes:

return True

if "search" in cls_name or "searchhost" in title:

return True

except Exception:

pass

return False

def get_target_hwnd():

hwnd = win32gui.FindWindow(None, WINDOW_TITLE)

if hwnd and win32gui.IsWindow(hwnd):

return hwnd

return None

def is_window_open() -> bool:

return get_target_hwnd() is not None

def is_target_focused() -> bool:

if not ONLY_WHEN_BONGO_FOCUSED:

return True

target_hwnd = get_target_hwnd()

if not target_hwnd or win32gui.IsIconic(target_hwnd):

return False

fg_hwnd = win32gui.GetForegroundWindow()

if not fg_hwnd:

return False

if fg_hwnd == target_hwnd:

return True

try:

parent = win32gui.GetParent(fg_hwnd)

while parent:

if parent == target_hwnd:

return True

parent = win32gui.GetParent(parent)

except Exception:

pass

return False

def hex_to_colorref(hex_color: str) -> int:

hex_color = hex_color.lstrip("#")

r = int(hex_color[0:2], 16)

g = int(hex_color[2:4], 16)

b = int(hex_color[4:6], 16)

return (b << 16) | (g << 8) | r

def style_title_bar(window, active_text_hex: str = FG_WHITE):

try:

window.update_idletasks()

hwnd = ctypes.windll.user32.GetParent(window.winfo_id())

if not hwnd:

hwnd = window.winfo_id()

dwm = ctypes.windll.dwmapi

dark_mode = ctypes.c_int(1)

dwm.DwmSetWindowAttribute(

hwnd,

DWMWA_USE_IMMERSIVE_DARK_MODE,

ctypes.byref(dark_mode),

ctypes.sizeof(dark_mode)

)

cap_color = ctypes.c_int(hex_to_colorref(BG_MAIN))

dwm.DwmSetWindowAttribute(

hwnd,

DWMWA_CAPTION_COLOR,

ctypes.byref(cap_color),

ctypes.sizeof(cap_color)

)

txt_color = ctypes.c_int(hex_to_colorref(active_text_hex))

dwm.DwmSetWindowAttribute(

hwnd,

DWMWA_TEXT_COLOR,

ctypes.byref(txt_color),

ctypes.sizeof(txt_color)

)

except Exception:

pass

def format_timer(seconds: int) -> str:

mins, secs = divmod(max(0, seconds), 60)

hours, mins = divmod(mins, 60)

if hours > 0:

return f"{hours:02d}:{mins:02d}:{secs:02d}"

return f"{mins:02d}:{secs:02d}"

def press_keys_simultaneously(key_names):

global press_count

std_buttons = []

dpad_dirs = []

for name in key_names:

upper = name.upper()

val = BUTTON_MAP.get(upper)

if val is None:

print(f"[press] Unknown or unsupported PS button '{name}'")

continue

if upper in DPAD_BUTTONS:

dpad_dirs.append(val)

else:

std_buttons.append(val)

if not std_buttons and not dpad_dirs:

return

try:

if gamepad is None:

init_gamepad()

for btn in std_buttons:

gamepad.press_button(button=btn)

if dpad_dirs:

gamepad.directional_pad(direction=dpad_dirs[-1])

gamepad.update()

hold = random.uniform(HOLD_MIN, HOLD_MAX)

if hold > 0:

time.sleep(hold)

for btn in std_buttons:

gamepad.release_button(button=btn)

if dpad_dirs and DS4_DPAD_NONE_VAL is not None:

gamepad.directional_pad(direction=DS4_DPAD_NONE_VAL)

gamepad.update()

with lock:

press_count += len(std_buttons) + len(dpad_dirs)

except Exception as e:

print(f"[press] Error on PS buttons {key_names}: {e}")

def auto_press_loop():

global running, paused_by_bg

cycle = 0

while True:

with lock:

is_running = running

if not is_running:

paused_by_bg = False

time.sleep(0.05)

continue

if not is_window_open():

release_all_gamepad()

time.sleep(0.2)

continue

if is_windows_search_active() or not is_target_focused():

if not paused_by_bg:

paused_by_bg = True

release_all_gamepad()

close_touch_keyboard()

apply_theme(True, bg_paused=True)

time.sleep(0.08)

continue

if paused_by_bg:

paused_by_bg = False

apply_theme(True, bg_paused=False)

try:

press_keys_simultaneously(KEYS)

cycle += 1

if cycle % 8 == 0:

close_touch_keyboard()

except Exception as e:

print(f"[loop] Error: {e}")

delay = random.uniform(INTERVAL_MIN, INTERVAL_MAX)

if delay > 0:

time.sleep(delay)

def apply_theme(is_active: bool, bg_paused: bool = False):

if not root:

return

active_fg = FG_PINK if (is_active and not bg_paused) else FG_WHITE

def _update():

style_title_bar(root, active_fg)

if title_label:

title_label.config(fg=active_fg)

if status_label:

if not is_active:

status_label.config(text="○ STOPPED", fg=FG_WHITE)

elif bg_paused:

status_label.config(text="⏸ PAUSED", fg=FG_MUTED)

else:

status_label.config(text="● RUNNING", fg=FG_PINK)

if count_label:

count_label.config(fg=active_fg)

if timer_label:

timer_label.config(fg=active_fg)

if btn_toggle:

btn_toggle.config(

text="■ STOP [F8]" if is_active else "▶ START [F8]",

fg=active_fg,

bg=BG_BTN_ACT if (is_active and not bg_paused) else BG_BTN,

activebackground=BG_BTN_ACT,

activeforeground=FG_PINK

)

root.after(0, _update)

def set_not_found_state():

if not root:

return

def _update():

style_title_bar(root, FG_WHITE)

if status_label:

status_label.config(text="✕ WINDOW NOT FOUND", fg=FG_WHITE)

if btn_toggle:

btn_toggle.config(text="▶ START [F8]", fg=FG_WHITE, bg=BG_BTN)

root.after(0, _update)

def toggle_running():

global running, paused_by_bg, _last_toggle, last_tick_time

now = time.time()

if now - _last_toggle < DEBOUNCE:

return

_last_toggle = now

with lock:

next_state = not running

if next_state:

if not is_window_open():

running = False

paused_by_bg = False

set_not_found_state()

return

init_gamepad()

running = True

paused_by_bg = not is_target_focused()

last_tick_time = time.time()

else:

running = False

paused_by_bg = False

last_tick_time = None

release_all_gamepad()

apply_theme(next_state, bg_paused=paused_by_bg if next_state else False)

def reset_stats():

global press_count, elapsed_sec, last_tick_time

with lock:

press_count = 0

elapsed_sec = 0

if running:

last_tick_time = time.time()

refresh_stats_ui()

def refresh_stats_ui():

with lock:

c = press_count

t = elapsed_sec

is_active = running and not paused_by_bg

fg = FG_PINK if is_active else FG_WHITE

if count_label:

count_label.config(text=f"{c:,}", fg=fg)

if timer_label:

timer_label.config(text=format_timer(t), fg=fg)

def ui_tick():

global elapsed_sec, last_tick_time

if not root:

return

with lock:

if running:

now = time.time()

if last_tick_time is not None:

elapsed_sec += int(now - last_tick_time)

last_tick_time = now - (now - last_tick_time - int(now - last_tick_time))

refresh_stats_ui()

root.after(200, ui_tick)

def on_hotkey(event):

toggle_running()

def on_close():

global running

with lock:

running = False

release_all_gamepad()

root.destroy()

def build_gui():

global root, status_label, btn_toggle, count_label, timer_label, title_label

root = tk.Tk()

root.title("LGF // Controller")

root.geometry("320x235")

root.resizable(False, False)

root.configure(bg=BG_MAIN)

root.protocol("WM_DELETE_WINDOW", on_close)

root.attributes("-topmost", True)

root.attributes("-alpha", 0.97)

style_title_bar(root, FG_WHITE)

f_title = tkfont.Font(family="Consolas", size=13, weight="bold")

f_stat = tkfont.Font(family="Consolas", size=9, weight="bold")

f_lbl = tkfont.Font(family="Segoe UI", size=8)

f_val = tkfont.Font(family="Consolas", size=14, weight="bold")

f_btn = tkfont.Font(family="Consolas", size=10, weight="bold")

f_mini = tkfont.Font(family="Consolas", size=8)

header = tk.Frame(root, bg=BG_MAIN)

header.pack(fill="x", padx=16, pady=(14, 8))

title_label = tk.Label(

header, text="LOCAL GAME FARM",

font=f_title, bg=BG_MAIN, fg=FG_WHITE

)

title_label.pack(side="left")

status_label = tk.Label(

header, text="○ STOPPED",

font=f_stat, bg=BG_MAIN, fg=FG_WHITE

)

status_label.pack(side="right", pady=(3, 0))

card = tk.Frame(

root, bg=BG_CARD,

highlightbackground=BORDER_CLR, highlightthickness=1

)

card.pack(fill="x", padx=16, pady=(2, 12))

left_box = tk.Frame(card, bg=BG_CARD)

left_box.pack(side="left", expand=True, fill="both", padx=12, pady=10)

tk.Label(

left_box, text="PRESSES / CLICKS",

font=f_lbl, bg=BG_CARD, fg=FG_MUTED

).pack()

count_label = tk.Label(

left_box, text="0",

font=f_val, bg=BG_CARD, fg=FG_WHITE

)

count_label.pack(pady=(2, 0))

divider = tk.Frame(card, bg=BORDER_CLR, width=1)

divider.pack(side="left", fill="y", pady=8)

right_box = tk.Frame(card, bg=BG_CARD)

right_box.pack(side="right", expand=True, fill="both", padx=12, pady=10)

tk.Label(

right_box, text="ACTIVE TIMER",

font=f_lbl, bg=BG_CARD, fg=FG_MUTED

).pack()

timer_label = tk.Label(

right_box, text="00:00",

font=f_val, bg=BG_CARD, fg=FG_WHITE

)

timer_label.pack(pady=(2, 0))

controls = tk.Frame(root, bg=BG_MAIN)

controls.pack(fill="x", padx=16)

btn_toggle = tk.Button(

controls,

text="▶ START [F8]",

font=f_btn,

bg=BG_BTN,

fg=FG_WHITE,

activebackground=BG_BTN_ACT,

activeforeground=FG_PINK,

relief="flat",

bd=0,

highlightthickness=1,

highlightbackground=BORDER_CLR,

pady=8,

cursor="hand2",

command=toggle_running

)

btn_toggle.pack(fill="x")

footer = tk.Frame(root, bg=BG_MAIN)

footer.pack(fill="x", padx=16, pady=(10, 0))

tk.Label(

footer, text=f"Target: {WINDOW_TITLE}",

font=f_mini, bg=BG_MAIN, fg=FG_WHITE

).pack(side="left")

btn_reset = tk.Button(

footer, text="RESET",

font=f_mini, bg=BG_MAIN, fg=FG_WHITE,

activebackground=BG_BTN, activeforeground=FG_PINK,

relief="flat", bd=0, cursor="hand2",

command=reset_stats

)

btn_reset.pack(side="right")

root.after(200, ui_tick)

return root

if __name__ == "__main__":

keyboard.on_press_key(TOGGLE_KEY, on_hotkey)

threading.Thread(target=auto_press_loop, daemon=True).start()

root = build_gui()

print("INFO F8 = Start/Stop | Close window to exit")

root.mainloop()