Python Forum

Full Version: Scrolling in Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi I am new to python. Can anyone help me. I am writing a small program in which I need to scroll up or down in order to find a button and then it will open up a sub window and then I need to perform a series of click then close the sub window, then move on to the next button then perform the same series of clicks.

This is the python I wrote I don't know how to add the scrolling function into it. Anyone can help?

This is the code:
https://paste.pythondiscord.com/UJ3Q

Thanks!
I remember putting a scrollbar in a text frame, frame2, within a window, so I could scroll up and down in the text as the output grew. That looked like this:

vsb = tk.Scrollbar(frame2, orient="vertical", command=text_area.yview)
vsb.grid(row=0, column=1, sticky='ns')
text_area.configure(yscrollcommand=vsb.set)
But if you search tkinter scrollbar, I'm sure you'll find what you want!
(Nov-23-2023, 07:02 AM)Pedroski55 Wrote: [ -> ]I remember putting a scrollbar in a text frame, frame2, within a window, so I could scroll up and down in the text as the output grew. That looked like this:

vsb = tk.Scrollbar(frame2, orient="vertical", command=text_area.yview)
vsb.grid(row=0, column=1, sticky='ns')
text_area.configure(yscrollcommand=vsb.set)
But if you search tkinter scrollbar, I'm sure you'll find what you want!
I answered in the following post it is clearer in terms of what is needed. There is already a subwindow and I can't scroll it. (The subwindow is inside the program I want to scroll.)
Btw let me explain a bit. I am using a program called Cubase. it is a music program. So the full function I would need is:

Main program window:
Find TSTR.jpg Track
Click on it (all the click means left button mouse click)

Find TVEP.jpg Button
Click on it

Find TConnect.jpg Button
Click on it

SUBWINDOW
(Here it opens up a subwindow in Cubase and here is the tricky part where there is a need for scrolling, so I thought if I make Python click on the first item on the list and use scroll function until
it finds the track I need, it would work but here is where it does not work anymore)

Find VEPBell.jpg First track within the sub window
Click on it

Scroll down until it finds VEPSectStr.jpg track

Find VEPConnect.jpg button
Click on it

Find VEPAll.jpg button
Click on it

Find VEPClose.jpg button
Click on it
(Then this returns to the main program window and it needs to find the next track)

Main program window:
Scroll down until it finds TMSS.jpg Track
And click on it

Find TVEP.jpg button
Click on it

Find TConnect.jpg Button
Click on it

Subwindow
Find VEPBell.jpg track (VEPBell is the first one on the list of the subwindow)
Click on it

Scroll down until it finds VEPMSS.jpg Track

Find VEPConnect.jpg Button
Click on it

Find VEPAll.jpg Button
Click on it

Find VEPClose.jpg Button
Click on it


That's what I need if you could help me figure out. Thank you! and Happy thanksgiving.
Youre python program uses something like pyautogui to run a program named Cubase. Is that correct? Next time post code so there is no guessing involved.
Hi I thought I posted a link to the code. But here it is again. I actaully found out where the issue is but still not able to solve it. I want to click on the TSectStr.PNG but it is hidden inside a drop down menu. For some reason python is not able to see this dropdown menu thus it can't click on it.

Is there anyway that python is able to locate and see the dropdown menu images?

Thanks

from imagesearch import imagesearch
from pynput.mouse import Button, Controller
import time
import pyautogui
import time
import os
os.chdir('C:\\Users\\ARCLA\\AppData\\Local\\Programs\\Python\\Python312\\auto_click')


pyautogui.moveTo(2000, 1500)
pyautogui.click()

pyautogui.hotkey('y')

pyautogui.write('Violin I A STR VEP')

pyautogui.hotkey('enter')

print('Looking for "TSectStr.PNG" button...')
x, y = imagesearch("TSectStr.PNG", 0.8)
if x != -1 and y != -1:
    print('Button "TSectStr.PNG" found, clicking...')
    pyautogui.moveTo(x+10,y+10)
    pyautogui.click(button="left")
If I can make python see the images in this drop down menu then I will be able to solve all the other issues.

I tested it with just a screen shot of the drop down menu. Python was able to locate the image (button) and click on the screen shot dropdown menu in Paint. It is not able to locate and see it when it is inside the program Cubase after typing the hot key "y" to make the drop down menu show up then python is stuck and unable to see it.