Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find anywhere on screen

Status
Not open for further replies.

smiler44

Technical User
Sep 18, 2009
83
GB
there are a couple of other recent threads along the same lines but I can go get the posted code to work for me.
I have attachmate 7.11. I would like to find an abbreviation of RCA no matter where on the screen it is.
Would appreciate any help offered. Would appreciate a macro that actually does it as well if possible[bigsmile]

thank you
smiler44
 
please post your code and what you have tried so far.
 
remy988,
I dont reall have any code of my own but used some code written by nyrtfleury14 in a different thread
Below is what I have ended up with but it does not work.
This line test_string$ = Sess0.Screen.Getstring(i, 1, 78)
I is the row, this changes, 1 is the column to start checking from , 78 is how many charectors to check.
I need something like
test_string$ = Sess0.Screen.Getstring(i, 1 , 1-78 and find the 3 characters "you")

This I don't understand
Pos = InStr(test_string$, PA_name$)
If pos <> 0 then


I would like to obtain the row that "you" is found in so the user can find it easy.

thank you
smiler44




' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of created code

While (test_string$<> "you")

ii = 0
for i = 5 to 8 step 1 ' this is the rows to check
ii = ii + 1

test_string$ = Sess0.Screen.Getstring(i, 1, 78)
Pos = InStr(test_string$, PA_name$)
If pos <> 0 then

On Error Goto TheEnd

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End if
next i

Wend

close
action = msgbox("MACRO FINISHED")
TheEnd:
End Sub

 
read skip's post here


also, you can check out the help files, which contains an example

Code:
Sub Main()
	Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

	Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
	Set Sess = Sys.ActiveSession
	Set MyScreen = Sess.Screen

	' This will find the input location on the first 
	' Slide Show screen.
	MyScreen.MoveTo 1, 1
	Set MyArea = MyScreen.Search("==>")
	MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2
End Sub

© 1996 - 2004, Attachmate Corporation. All rights reserved.
 
thank you remy988 I'll give that ago but not tonight.
smiler44
 
remy988,
I have read the link and the posting with code. I have not managed to find a string on the screen if I don't know where it is but I have somehow managed to get the whole row of text into a string, using code I have played around with from the other posts. As I go to the next row the contents of the string changes so I think I may have moved forward. I have started a new post about finding a string within a string. I think if that can be solved the whole macro will be solved.

If you are able to help with that...please :)
smiler44
 
did you try the code from the help file? this does work.

Code:
Sub Main()
	Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

	Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
	Set Sess = Sys.ActiveSession
	Set MyScreen = Sess.Screen

	' This will find the input location on the first 
	' Slide Show screen.
	MyScreen.MoveTo 1, 1
	Set MyArea = MyScreen.Search("==>")
	MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2
End Sub
 
remy988,
thank you have tried it and as you say it does work. I have now spent ages trying to get the cursor position and was about to press enter on this post when I tried something else and hey presto I have it.

msgbox myscreen.col
msgbox myscreen.row


thank you very much

Hopefully for the next few days I can work the full macro out for myself.
Thank you very much remy988 for your patience, really appreciate it

smiler44
 
remy998,
I'm back on this one. Thanks to your patience I have a macro using the above code and some of my own that runs.
I have run into a problem, the code seems to be case sensitive. How can I make it so that's its not case sensitive? The user may write in upper or lower case and the word being searched for may be in upper or lower case.
I need the code to find the word no matter if upper or lower case.

thanks
smiler44
 

Do two searches:
first convert the user input to UCASE, then seach based on UCASE; if not found, then convert the user input to LCASE, then search based on LCASE.


what does your code look like now?
 
remy998,
was hoping to be able to do it with one search but I take it that is beyond attachmate [bigsmile] Thankyou, two searches it may need to be but goodness that will be slow. the user said today that they think the owrd they will be looking for will be in upper case so are happy to type the word to find in upper case so may get away with one search but would like to run a check to make sure they have typed in upper case
I am building the code up one resolved problem at a time. Not sure which problem to tackle first. It could be to restrict the search area to be between rows 8 and 24, the next one will be to present the found information in a way that the user wants it. For now they will except it in a way my skill level can present it. I have pasted the whole code below in case it is useful for anyone.

smiler44

Global g_HostSettleTime%
Global g_szPassword$


dim totalpages as string ' total number of pages of notes
dim currentnote as INTEGER 'string ' current note
dim row as string ' row the searched for row is in
dim foundonpage as string
dim lwtf as string ' word to find before timmed to remove right spaces
dim wtf as string ' word to find one trimmed
Dim mycol as string





Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen



' This section of code contains the woking code


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sess0.Screen.Sendkeys ("<Home>")

lwtf = Sess0.Screen.Getstring(1, 2, 6) ' location of the word to find
wtf = trim(lwtf) ' trims the missing spaces from the right

Sess0.Screen.Sendkeys ("<Home><Enter>")
Sess0.Screen.Sendkeys ("<Home><Enter>")
Sess0.Screen.Sendkeys("<ERASEEOF>")
Sess0.Screen.Sendkeys ("daj<Enter>")
Sess0.Screen.Sendkeys ("s<Home>")
Sess0.Screen.Sendkeys ("ln<enter>")
Sess0.Screen.Sendkeys ("s<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
totalpages = Sess0.Screen.GetString(9, 72, 2) ' gets total number of pages
currentnote = Sess0.Screen.GetString(9, 65, 2) ' gets current page number
'foundonpage = currentnote

do until currentnote = 1


' This will find the location of the searched for word

Set MyArea = MyScreen.Search(wtf) 'finds first instance of word to find
MyScreen.MoveTo MyArea.Bottom, MyArea.Right ' if word is found place cursor by the word



if myscreen.col = 1 then ' word not found
Sess0.Screen.Sendkeys("<Home><Pf7>")
'foundonpage = currentnote
else

msgbox myscreen.row ' word found ' this is temporary, in time i will present this differently
Sess0.Screen.Sendkeys("<Home><Pf7>")
'currentnote = currentnote - 1
'foundonpage = currentnote
'msgbox foundonpage
end if
currentnote = Sess0.Screen.GetString(9, 65, 2)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
loop

System.TimeoutValue = OldSystemTimeout

msgbox "Finished"
End Sub
 
no. my code seems to be very slow and there could be 200 pages of notes to look through.
I do have a couple of macros that run in the blink of an eye, run so quick it worries me that they are missing something but I've not had any complaints.

smilerr44
 
have you thought about converting the input and search to UCASE?
 
remy988,
do you mean convert the word the user types to uppercase? Good idea but I don't know how to. I'll try recording the action in Excel and see if I can work it out from that. I have an awful lot to learn and a lot to do on this macro to get it the way I want it and the way the user wants it. there will be a lot of trial and error and no doubt more questions.
Today the user ran the macro as it cos its better then a manual search and taking into consideration the shot comings of the macro they were quite happy so a big thank you to you for your help

smiler44
 
thank you remy988, can now fo from upper to lower or lower to upper case. as you say, easy.... well easy once you know how:)
smiler44
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top