AutoHotkey Community

It is currently May 27th, 2012, 12:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: September 10th, 2008, 12:06 am 
Hello,

I have a nag screen, which I want to automatically get rid of. To do so I need to press Alt+number where number can be 1, 2 or 3.

Using Window spy, I see that the number appears in the section (Visible Window text)...like shown below. The following is copied and pasted from Windowspy when the nag screen is active. I want to extract the digit that appears and then simulate the pressing of Alt+digit. How do I extract the digit.

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<<<
NagPage
1


Thanks in advance for your help. AHK rocks. Its language is not very difficulty, yet it is very powerful and some people in these forums who are willing to help makes it really valuable.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2008, 6:04 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Refer AHK Doc for WinGetText command. :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2008, 12:52 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
Also, in place of "ALT+Digit", look up "WinClose" or "WinKill". All you need is the title of the screen... If they have title that are really similar, then you may be able to close all of them with 3 lines of code.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 3:17 am 
Thanks for your replies.

If I try to use the Wintext, I only get the following (I am using the example in the AHK documentation and using the Msgbox to get the text):

Startuppage
Nagpage

The code I used is the following:
Code:
^!c::
DetectHiddenText, On
Run, C:\progname\prog.exe
WinWait, progname
WinGetText, text  ; The window found above will be used.
MsgBox, The text is:`n%text%
Return


Hence, Wintext does not give me the relevant text on the nagscreen.

Regarding killing the process, there is no way to just close the nag window. If you look in the processes or applications in the task manager, there is only one program name corresponding to both the main program and the nagpage. If you try to kill that process, the main program and the nagpage both close down.

Thanks anyway. Any further information would be great.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 1:12 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
WinKill would probably kill the program... WinClose will just close the defined window. I use it to close error messages and requests for input in different programs all the time. WinClose may do it for you... No processes involved.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 2:01 pm 
Does not work. I tried the following:

Code:
IfWinExist, ahk_class THENAME
WinClose ahk_class THENAME
Return



Code:
^!c::
IfWinExist, ahk_class THENAME
WinClose ahk_class THENAME
Return


Neither of them works.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 3:18 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
And your giving it the exact name? Maybe to help it find it better, you can use "SetTitleMatchMode, 2" at the top of your script.

Or maybe use:

Code:
IfWinExist, ahk_class THENAME
MsgBox, ahk_class THENAME was found.
Return

To see if it's even finding the window at all.

If Not, Try "WinClose, A" When a nagscreen pops up.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 7:04 pm 
Sivvy, I appreciate your willingness to help. Thanks.

I tried using testing whether it identifies the title using the method you suggested above and it does.

Can I try something else then? As I said, I am not even sure whether the Nag window can be closed. Those three buttons which are present in the Northeast corner of any window, are not present for this window.

Thanks again.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2008, 7:40 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
I have another idea, but first I will attempt your way.

Code:
^!c::
Run, C:\progname\prog.exe
WinWait, progname
WinGetText, text
StringSplit, TextArray, Text, `r, `n
Loop %TextArray0%
{
    If TextArray%A_Index% Is Digit
    {
        NagNum = TextArray%A_Index%
        Break
    }
}
MsgBox, The text is:`n%text%`nThe NagScreen Number is %NagNum%
Return

Hopefully that will get the number for you.

My other idea is...

Code:
Loop
{
    WinWait, , Nagpage
    IfWinActive, , Nagpage
        WinHide, , NagPage
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 1:04 am 
Thanks very much for the code. Unfortunately, it does not work. As i said above, somehow the WinGetText command does not show all the text on the nag window. Window spy does but WinGetText only shows two lines

StartPage
NagPage.

I wonder why.

Thanks again for your help. I suppose this cannot be done very easily.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 1:59 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
The "WinHide" script isn't working either?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 2:25 pm 
Offline

Joined: July 29th, 2005, 5:32 pm
Posts: 179
curioustolearn wrote:
the WinGetText command does not show all the text on the nag window. Window spy does but WinGetText only shows two lines

StartPage
NagPage.

Since window spy can retrieve the txt for you, I think that the txt you are retrieving from your winwait command may be from a different window than you expect (not the nag window..)

Try this as an experiment: manually start your app, & activate the 'nag' window--
Code:
^z::
  WinActive("A")
  WinGetText, text
  MsgBox, %text%
return
..& this hotkey will show what it sees from the current active window.

_________________
.o0[ corey ]0o.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 4:22 pm 
Sivvy, the hide command does not work either.

Freakkk, you were right. The text that I get from your method is different and has the relevant information. I still do not get all the text that is on the nag window, but I do get the most relevant part. The second line from this text is the digit that I want to use to simulate pressing Alt+Digit.

After using your method, I ran the following code (added a line to run the program)

[code]
^!z::
Run, C:\totalcmd\progname.exe
Sleep, 1000
WinActive("A")
WinGetText, text
MsgBox, %text%
return
[\code]

and, I still get the relevant text. However, I DO NOT get the relevant text if I replace Sleep, 1000 by Sleep, 200 because first the program is opened and then the nag window pops up and Sleep, 200 is not enough time. The strange thing is that instead of using Sleep, 1000 in the above code if I use the command Winwait, ahk_class NAGWINDOWCLASS where NAGWINDOWCLASS is the ahk_class of the Nagwindow obtained using Window spy then I again get only the two lines I mentioned in the above posts. This seems strange because despite using ahk_class I do not get the correct information. The problem with Sleep, 1000 is that it may not always work.

But anyhow, if someone can tell me how to extract the digit from the second line from the text that I get using the Freakkk's method, that would be great.

Freakkk and Sivvy thanks again for your help.[/b]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 4:46 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
Code:
StringSplit, TextArray, Text, `r, `n
Loop %TextArray0%
{
    If TextArray%A_Index% Is Digit
    {
        NagNum = TextArray%A_Index%
        Break
    }
}
MsgBox, %NagNum%

Does this work in place of the MsgBox at the end of your code?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 5:56 pm 
With that code I always get the output TextArray2

In case, it is helpful the following is the text output I get using Freakkk's code.

Code:
Nagpage
1
&3
&2
&1
&RegistrationInfo
Program &Information
Startuppage


I want to extract the number that follows Nagpage (which in the above example is 1, but keeps changing between 1, 2 and 3).

Thanks Sivvy. Again, I appreciate your help.[/code]


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group