Python Forum
check if the windows title chnaged !
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
check if the windows title chnaged !
#1
hey there ...

im writing a code to check the windows title ... but i need it to loop and wait if active windows changed print the title for the new active window ?

this is my code :
from win32gui import GetWindowText, GetForegroundWindow
from time import sleep

while True:
    sleep(1)
    qan = GetWindowText(GetForegroundWindow())

    print qan
Reply
#2
try something lik
from win32gui import GetWindowText, GetForegroundWindow
from time import sleep

current_title = None
while True:
    new_title = GetWindowText(GetForegroundWindow())
    if new_title != current_title:
        print('New_title: {}'.format(new_title)
        current_title = new_title
    sleep(1)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-12-2018, 10:25 AM)buran Wrote: try something lik
from win32gui import GetWindowText, GetForegroundWindow
from time import sleep

current_title = None
while True:
    new_title = GetWindowText(GetForegroundWindow())
    if new_title != current_title:
        print('New_title: {}'.format(new_title)
        current_title = new_title
    sleep(1)

thanks u its working :
from win32gui import GetWindowText, GetForegroundWindow
from time import sleep
 
current_title = None
while True:

    new_title = GetWindowText(GetForegroundWindow())
    if new_title != current_title:
        print('New_title:' + new_title)
        current_title = new_title
        sleep(1)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  getting windows title and keystrokes !! evilcode1 4 4,194 Nov-22-2018, 05:59 PM
Last Post: evilcode1
  How to change font size of chart title and axis title ? thrupass 5 15,599 Mar-30-2018, 04:02 PM
Last Post: DrFunn1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020