Jump to content
Macro Express Forums

Cant seem to set focus


eatc7402
 Share

Recommended Posts

Im attempting to set focus to a control with no luck... using the following.

Doesnt seem to work.

 

Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"

Text Type: <SHIFT>S

Get Control %C1% (Resize: )

Set Focus to %C1%

 

the Resiize control does get activated correctly, but i cant to get the

focus on it to perform furthur operations.

 

eatc7402

Link to comment
Share on other sites

Im attempting to set focus to a control with no luck... using the following.

Doesnt seem to work.

 

Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"

Text Type: <SHIFT>S

Get Control %C1% (Resize: )

Set Focus to %C1%

 

the Resiize control does get activated correctly, but i cant to get the

focus on it to perform furthur operations.

 

eatc7402

You most likely need a delay between your Text Type command and your Get Control command.

 

I don't know which version of PSP you're using, but I just tested your script using PSP 7, and it worked exactly as I expected it would. Which is to say, it didn't work until I added a .5 second delay after the Text Type command. It would probably work consistently with a shorter delay or with a window specific delay (such as: Wait for window title: Resize).

Link to comment
Share on other sites

You most likely need a delay between your Text Type command and your Get Control command.

 

I don't know which version of PSP you're using, but I just tested your script using PSP 7, and it worked exactly as I expected it would. Which is to say, it didn't work until I added a .5 second delay after the Text Type command. It would probably work consistently with a shorter delay or with a window specific delay (such as: Wait for window title: Resize).

 

well i manged to get focus but the control does not seem to react to typing...

ive changed to the following but theres nop reaction to the 'enter'

text...

 

Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"

// wait for aadvertising window to disapper

Wait Time Delay 5 Seconds

Text Type: <SHIFT>S

Delay 0.5 Seconds

Get Control %C1% (Resize: )

Wait for Control %C1% to gain focus

Text Type:<ENTER>

Delay 1 Seconds

 

eatc7402

Link to comment
Share on other sites

well i manged to get focus but the control does not seem to react to typing...

ive changed to the following but theres nop reaction to the 'enter'

text...

 

Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"

// wait for aadvertising window to disapper

Wait Time Delay 5 Seconds

Text Type: <SHIFT>S

Delay 0.5 Seconds

Get Control %C1% (Resize: )

Wait for Control %C1% to gain focus

Text Type:<ENTER>

Delay 1 Seconds

 

eatc7402

In the macro text you provided just now, you've removed your Set Focus command. That is going to cause you some problems.

Make sure you are setting the focus in your macro. That might fix your problem.

 

Some other observations:

When you say "advertising window" in your Remark code, I presume you are referring to the Splash screen that opens when you

first launch PSP.

 

If you are launching from scratch, you will need to open a file before you will be able to open the Resize window. So, you'll either

need to add code into your macro to open a blank Image file, or you will need to open an already existing image (jpg, gif,

etc.).

 

I built a macro that does what I think you're trying to do.

 

Of course, mine is built without knowing where you are setting your %C1% control, but it works just fine regardless of where I set

it on the Resize window.

 

Here is the Scripting Editor Text (basic):

// If PSP Is Already Running, There Will Be No Splash Screen to Wait For.
If Window Title "Jasc Paint Shop Pro - " is running
 Variable Set String %T1% "Skip Delay"
End If
Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"
// When Launching PSP, This Delay Will 'Pause' The Macro Till the Spash Screen Has Gone.
If Variable %T1% <> "Skip Delay"
 Delay 5 Seconds
 Text Type: <CONTROL>n
 Wait For Window Title: "New Image"
 Text Type: 8<TAB>11<TAB>i<ENTER>
 Wait Text Playback
End If
Text Type: <SHIFT>s
Wait For Window Title: "Resize"
Get Control %C1% (Resize: Button)
Set Focus to %C1%
Text Type: <ENTER>

Here is the Direct Editor Text (you can copy and paste this directly into a blank macro to create this macro in your system)

<REM2:If PSP Is Already Running, There Will Be No Splash Screen to Wait For.><IFOTH:04:2:Jasc Paint Shop Pro - ><TVAR2:01:01:Skip Delay><ENDIF><LAUNCHYES3:0:0112Jasc Paint Shop Pro<LAUNCH:C:\Program Files\Jasc Software Inc\Paint Shop Pro 7\psp.exe><REM2:When Launching PSP, This Delay Will 'Pause' The Macro Till the Spash Screen Has Gone.><IFVAR2:1:01:2:Skip Delay><DELAY:5><TEXTTYPE:<CONTROL>n><WAITWIN2:000010:000000:New Image><TEXTTYPE:8<TAB>11<TAB>i<ENTER>><WAITPB><ENDIF><TEXTTYPE:<SHIFT>s><WAITWIN2:000010:000000:Resize><GETCONTROL2:01:PSP.EXE:#32770Resize001:1Button><SETFOCUS:01><TEXTTYPE:<ENTER>>

Link to comment
Share on other sites

In the macro text you provided just now, you've removed your Set Focus command. That is going to cause you some problems.

Make sure you are setting the focus in your macro. That might fix your problem.

 

 

 

 

Here is the Scripting Editor Text (basic):

// If PSP Is Already Running, There Will Be No Splash Screen to Wait For.
If Window Title "Jasc Paint Shop Pro - " is running
 Variable Set String %T1% "Skip Delay"
End If
Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"
// When Launching PSP, This Delay Will 'Pause' The Macro Till the Spash Screen Has Gone.
If Variable %T1% <> "Skip Delay"
 Delay 5 Seconds
 Text Type: <CONTROL>n
 Wait For Window Title: "New Image"
 Text Type: 8<TAB>11<TAB>i<ENTER>
 Wait Text Playback
End If
Text Type: <SHIFT>s
Wait For Window Title: "Resize"
Get Control %C1% (Resize: Button)
Set Focus to %C1%
Text Type: <ENTER>

 

===========================

yes indeed it was the set focus that was missing. Hers my code that now works. It also appears that 'wait fors' are important.

 

Activate or Launch: "Jasc Paint Shop Pro" OR "psp.exe"
  // wait for splash window to disapper
  Wait Time Delay 5 Seconds
  Text Type: <SHIFT>S
  Wait For Window Title: "Resize"
  Get Control %C1% (Resize: Button)
  Set Focus to %C1%
  Text Type: <ENTER>
  Delay 1 Seconds

 

Thanks, im a newbie to ME, but not witing code. Your small 'tutorial'

was most helpful.

 

eatc7402

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...