serdargksn
Centipat
- Katılım
- 4 Temmuz 2022
- Mesajlar
- 36
Daha fazla
- Cinsiyet
- Erkek
import tkinter as tk
from tkinter import messagebox
import subprocess
def create_shortcut():
first_key = first_key_entry.get()
second_key = second_key_entry.get()
app = app_entry.get()
shortcut = f"{first_key}+{second_key}:{app}"
subprocess.run(["shortcut", "-c", shortcut])
messagebox.showinfo("Success", "Shortcut created successfully!")
root = tk.Tk()
root.title("Shortcut Creator")
first_key_label = tk.Label(root, text="First key:")
first_key_label.grid(row=0, column=0)
first_key_entry = tk.Entry(root)
first_key_entry.grid(row=0, column=1)
second_key_label = tk.Label(root, text="Second key:")
second_key_label.grid(row=1, column=0)
second_key_entry = tk.Entry(root)
second_key_entry.grid(row=1, column=1)
app_label = tk.Label(root, text="Application:")
app_label.grid(row=2, column=0)
app_entry = tk.Entry(root)
app_entry.grid(row=2, column=1)
create_button = tk.Button(root, text="Create", command=create_shortcut)
create_button.grid(row=3, column=1)
root.mainloop()
Hocam shortcut nereye oluşturuluyor onu belirten konum var mı?Merhabalar efendim öncelikle. Yazılımda henüz yeniyim ve kendimi geliştirmek için küçük uygulamalar yapıyorum. Shortcut oluşturucu da bunlardan birisi fakat nedenini anlamadığım bir hata alıyorum. Konuya hakim abilerim ablalarım küçük bir el atarsa çok mutlu olurum. Aşağıda sırasıyla kaynak kodu ve aldığım hatayı paylaşacağım.
Kod:
Python:import tkinter as tk from tkinter import messagebox import subprocess def create_shortcut(): first_key = first_key_entry.get() second_key = second_key_entry.get() app = app_entry.get() shortcut = f"{first_key}+{second_key}:{app}" subprocess.run(["shortcut", "-c", shortcut]) messagebox.showinfo("Success", "Shortcut created successfully!") root = tk.Tk() root.title("Shortcut Creator") first_key_label = tk.Label(root, text="First key:") first_key_label.grid(row=0, column=0) first_key_entry = tk.Entry(root) first_key_entry.grid(row=0, column=1) second_key_label = tk.Label(root, text="Second key:") second_key_label.grid(row=1, column=0) second_key_entry = tk.Entry(root) second_key_entry.grid(row=1, column=1) app_label = tk.Label(root, text="Application:") app_label.grid(row=2, column=0) app_entry = tk.Entry(root) app_entry.grid(row=2, column=1) create_button = tk.Button(root, text="Create", command=create_shortcut) create_button.grid(row=3, column=1) root.mainloop()
Hata:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1948, in __call__
File "main.py", line 10, in create_shortcut
File "subprocess.py", line 546, in run
File "subprocess.py", line 1022, in __init__
File "subprocess.py", line 1491, in _execute_child
FileNotFoundError: [WinError 2] Sistem belirtilen dosyayı bulamıyor.
Durum bu hocalarım. Ayrıca kodu kullanabilirsiniz belki bir yararı dokunur ben de mutlu olurum. Yorumlarınızı bekliyorum.
Hocam o değer zaten yazı kutusunu alıyor diye biliyorum. Fonksiyona almayı gerekmeden yapıyor ama bence sorun kısayolun oluşturulacağı konumu bulamıyor program.first_key_entry gibi değerleri fonksiyon içine almayı dener misin?
import tkinter as tk
from tkinter import messagebox
import subprocess
def create_shortcut():
first_key = first_key_entry.get()
second_key = second_key_entry.get()
app = app_entry.get()
shortcut = f"{first_key}+{second_key}:{app}"
subprocess.run(["shortcut", "-c", shortcut], shell=True)
messagebox.showinfo("Success", "Shortcut created successfully!")
root = tk.Tk()
root.title("Shortcut Creator")
first_key_label = tk.Label(root, text="First key:")
first_key_label.grid(row=0, column=0)
first_key_entry = tk.Entry(root)
first_key_entry.grid(row=0, column=1)
second_key_label = tk.Label(root, text="Second key:")
second_key_label.grid(row=1, column=0)
second_key_entry = tk.Entry(root)
second_key_entry.grid(row=1, column=1)
app_label = tk.Label(root, text="Application:")
app_label.grid(row=2, column=0)
app_entry = tk.Entry(root)
app_entry.grid(row=2, column=1)
create_button = tk.Button(root, text="Create", command=create_shortcut)
create_button.grid(row=3, column=1)
root.mainloop()
Kusura bakmayın başlıkta lütfen yazdığım için 1 saat mute yemiştim cevaplayamadım. Öncelikle hocam uygulamanın amacını yanlış anlamış olabilirsiniz buradaki amaç "keyboard shortcut" oluşturmak. Yani örneğin a ve b tuşu girsin kullanıcı bir de uygulama belirlesin ardından pc bunu kaydedip kullanıcının verdiği tuşlar aynı anda basıldığında ilgili uygulamayı başlatması lazım. Ha eğer yanlış anlamadıysanız ve pc nin kullanıcıdan aldığı verileri nerede tuttuğunu soruyosanız onu ben de bilmiyorum. Sanırım onun için de bir database açmam lazım ama sql bilmiyorum.Hocam shortcut nereye oluşturuluyor onu belirten konum var mı?
deneyeceğim hocamHocam o değer zaten yazı kutusunu alıyor diye biliyorum. Fonksiyona almayı gerekmeden yapıyor ama bence sorun kısayolun oluşturulacağı konumu bulamıyor program.
Python:import tkinter as tk from tkinter import messagebox import subprocess def create_shortcut(): first_key = first_key_entry.get() second_key = second_key_entry.get() app = app_entry.get() shortcut = f"{first_key}+{second_key}:{app}" subprocess.run(["shortcut", "-c", shortcut], shell=True) messagebox.showinfo("Success", "Shortcut created successfully!") root = tk.Tk() root.title("Shortcut Creator") first_key_label = tk.Label(root, text="First key:") first_key_label.grid(row=0, column=0) first_key_entry = tk.Entry(root) first_key_entry.grid(row=0, column=1) second_key_label = tk.Label(root, text="Second key:") second_key_label.grid(row=1, column=0) second_key_entry = tk.Entry(root) second_key_entry.grid(row=1, column=1) app_label = tk.Label(root, text="Application:") app_label.grid(row=2, column=0) app_entry = tk.Entry(root) app_entry.grid(row=2, column=1) create_button = tk.Button(root, text="Create", command=create_shortcut) create_button.grid(row=3, column=1) root.mainloop()
Bir de böyle deneyin. Kutulara ne yazdığınızı bilmediğim için test edemedim.
Ve evet hocam onları görüyor zaten algoritma temiz çalışıyor. Tekrar kusura bakmayın garip bi konu yüzünden mute yemişimfirst_key_entry gibi değerleri fonksiyon içine almayı dener misin?
Hocam shortcutu açamıyorum.Kusura bakmayın başlıkta lütfen yazdığım için 1 saat mute yemiştim cevaplayamadım. Öncelikle hocam uygulamanın amacını yanlış anlamış olabilirsiniz buradaki amaç "keyboard shortcut" oluşturmak. Yani örneğin a ve b tuşu girsin kullanıcı bir de uygulama belirlesin ardından pc bunu kaydedip kullanıcının verdiği tuşlar aynı anda basıldığında ilgili uygulamayı başlatması lazım. Ha eğer yanlış anlamadıysanız ve pc nin kullanıcıdan aldığı verileri nerede tuttuğunu soruyosanız onu ben de bilmiyorum. Sanırım onun için de bir database açmam lazım ama sql bilmiyorum.
deneyeceğim hocam
Ve evet hocam onları görüyor zaten algoritma temiz çalışıyor. Tekrar kusura bakmayın garip bi konu yüzünden mute yemişim
Kodu denedim sonuç değişti. Öncelikle success mesajı geldi ilk kodda gelmiyordu. Terminal ise şunu söyledi:Hocam o değer zaten yazı kutusunu alıyor diye biliyorum. Fonksiyona almayı gerekmeden yapıyor ama bence sorun kısayolun oluşturulacağı konumu bulamıyor program.
Python:import tkinter as tk from tkinter import messagebox import subprocess def create_shortcut(): first_key = first_key_entry.get() second_key = second_key_entry.get() app = app_entry.get() shortcut = f"{first_key}+{second_key}:{app}" subprocess.run(["shortcut", "-c", shortcut], shell=True) messagebox.showinfo("Success", "Shortcut created successfully!") root = tk.Tk() root.title("Shortcut Creator") first_key_label = tk.Label(root, text="First key:") first_key_label.grid(row=0, column=0) first_key_entry = tk.Entry(root) first_key_entry.grid(row=0, column=1) second_key_label = tk.Label(root, text="Second key:") second_key_label.grid(row=1, column=0) second_key_entry = tk.Entry(root) second_key_entry.grid(row=1, column=1) app_label = tk.Label(root, text="Application:") app_label.grid(row=2, column=0) app_entry = tk.Entry(root) app_entry.grid(row=2, column=1) create_button = tk.Button(root, text="Create", command=create_shortcut) create_button.grid(row=3, column=1) root.mainloop()
Bir de böyle deneyin. Kutulara ne yazdığınızı bilmediğim için test edemedim.
büyük ihtimalle ben yanlışım hocam acemiliğimiz çıkıyorHocam shortcutu açamıyorum. Eki Görüntüle 1636243
Garip bir şekilde internette shortcut programı yok. Acaba kodu yanlış mı yazdınız?
Kodu denedim sonuç değişti. Öncelikle success mesajı geldi ilk kodda gelmiyordu. Terminal ise şunu söyledi:
'Shortcut' is not recognized as an internal or external command,
Operable program or batch file.
Shortcut u tanımıyorum diyor beyefendi. Shortcut'u nasıl tanımlayabilirim ki bildiğim 2 kütüphane var zaten asdafgasgagsa
Chat gpt:Sorun bendeymiş hocam. Shell üzerinden yürüdüğü için öyle oluyor.
subprocess.run(["shortcut", "-c", shortcut])
import tkinter as tk
from tkinter import messagebox
import subprocess
def create_shortcut():
first_key = first_key_entry.get()
second_key = second_key_entry.get()
app = app_entry.get()
shortcut = f"{first_key}+{second_key}:{app}"
print("shortcut", "-c", shortcut)
messagebox.showinfo("Success", "Shortcut created successfully!")
root = tk.Tk()
root.title("Shortcut Creator")
first_key_label = tk.Label(root, text="First key:")
first_key_label.grid(row=0, column=0)
first_key_entry = tk.Entry(root)
first_key_entry.grid(row=0, column=1)
second_key_label = tk.Label(root, text="Second key:")
second_key_label.grid(row=1, column=0)
second_key_entry = tk.Entry(root)
second_key_entry.grid(row=1, column=1)
app_label = tk.Label(root, text="Application:")
app_label.grid(row=2, column=0)
app_entry = tk.Entry(root)
app_entry.grid(row=2, column=1)
create_button = tk.Button(root, text="Create", command=create_shortcut)
create_button.grid(row=3, column=1)
root.mainloop()