Jump to content
fchelp

Send not working on active window

Recommended Posts

fchelp

Hi, i'm new to autoit and am learning to play around with it.

 

I'm trying to make a script that would automatically make program full screen, the keyboard shortcut from the program is CTRL + f, so i wrote this script

WinActivate("[CLASS:#32770]", "")
Send("^f")

WinActivate works perfect, it activates the correct program, but send ctrl+f doesn't work, nothing happens.

 

Thanks in advance. 

Share this post


Link to post
Share on other sites
Earthshine

gonna need more code than that to test anything. what application are you trying to automate?


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
jdelaney

popups can't become full screen.  I take that back, they can be, but applications are generally not only a popup, they have some primary window, which is probably what you really want to be full screen, yes?

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
fchelp

Thanks so much for the quick help

1 minute ago, Earthshine said:

gonna need more code than that to test anything. what application are you trying to automate?

Vivotek Live Client. (it's a CCTV camera viewer)

Just now, jdelaney said:

popups can't become full screen.

It's not a popup, and even more the program has a button and a keyboard shortcut to make it full screen.

Share this post


Link to post
Share on other sites
jdelaney

You are activating a popup...that's what class:32770 is.  Use the spy tool, and try again.  Also, popups are generally blockers, so when present, you can't send to the main window.  You'll need to close them.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Earthshine

CLASS 32770 is a Dialog box. They do pop up to tell us things.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fchelp
On 2/8/2018 at 0:00 PM, jdelaney said:

You are activating a popup...that's what class:32770 is.  Use the spy tool, and try again.

I'm selecting the the header of the program.

2018-02-08_120303.png

 

 

Thanks!

Edited by fchelp

Share this post


Link to post
Share on other sites
Earthshine

try this

WinWait("[CLASS:#32770]", "")
Send("^f")

 

  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
jdelaney

What an odd application.  Does the spy tool grab the controls inside it?  Maybe change the rate at which the keys are pressed:

AutoItSetOption

Or, just try to get the window handle, and make it full screen

WinSetState ( "title", "text", flag )

Also, that class of window is probably in use by many of your applications...you'll need to do winlist, and loop through the returned array to find the one specific to your application.  Probably better just to use the title to grab it.

WinGetHandle("LiveClient")

Last edit: get the handle returned from your function, and consolewrite it, then compare it against the spy tool's handle.  If they are not the same, then you are grabbing the wrong popup.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
fchelp
4 minutes ago, Earthshine said:

try this

WinWait("[CLASS:#32770]", "")
Send("^f")

 

Thanks! but it's doesn't work, it doesn't even pause the script to wait for the program to be active, it just quits.

2 minutes ago, jdelaney said:

What an odd application.  Does the spy tool grab the controls inside it?  Maybe change the rate at which the keys are pressed:

AutoItSetOption

Or, just try to get the window handle, and make it full screen

WinSetState ( "title", "text", flag )

 

What Should i set the AutoItSetOption?

 

Sorry but how do i use this code?

WinSetState ( "title", "text", flag )

Thank in advance

 

Share this post


Link to post
Share on other sites
jdelaney
$hWindow = WinGetHandle("LiveClient")
ConsoleWrite($hWindow & @CRLF)
WinSetState($hWindow,"",@SW_MAXIMIZE)

Look at the help file for autoitsetoptions...the key send ones.  There is one for the break between character sends, and one for the length of the send of each character.

When the functions are in codeblocks, you can click them to see the helpfile...or if they are in scite, click them, and press F1 to see the helpfile.

Edited by jdelaney
  • Like 2

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
fchelp
15 minutes ago, jdelaney said:

What an odd application.  Does the spy tool grab the controls inside it?  Maybe change the rate at which the keys are pressed:

AutoItSetOption

Or, just try to get the window handle, and make it full screen

WinSetState ( "title", "text", flag )

Also, that class of window is probably in use by many of your applications...you'll need to do winlist, and loop through the returned array to find the one specific to your application.  Probably better just to use the title to grab it.

WinGetHandle("LiveClient")

Last edit: get the handle returned from your function, and consolewrite it, then compare it against the spy tool's handle.  If they are not the same, then you are grabbing the wrong popup.

Thanks but my issue is not about maximizing the window, it's about running a keyboard shortcut in the program.

WinActivate ("[CLASS:#32770]", "") finds the correct program, so no worries there (i see that LiveClient become the active window), my issue is that for some reason the shortcut doesn't run in the program what could be the reason?

Thanks

Share this post


Link to post
Share on other sites
jdelaney

Welcome to the world of Send().  It is not reliable.  Could be any number of things.

Use ControlClick for best results, if possible.

Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Earthshine

try pressing that button that makes it go full screen that you pointed out. What does the Info Tool say about that?

  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fchelp
2 minutes ago, jdelaney said:

Welcome to the world of Send().  It is not reliable.  Could be any number of things.

Use ControlClick for best results, if possible.

I'm going to try using ControlClick again (i tried it before and it didn't work, so i deleted the code, now i have to rewrite it)

1 minute ago, Earthshine said:

try pressing that button that makes it go full screen that you pointed out. What does the Info Tool say about that?

2018-02-08_123505.png

 

Thanks!

Share this post


Link to post
Share on other sites
Earthshine

does it work?


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fchelp
1 minute ago, Earthshine said:

does it work?

I just tried this 

WinActivate ("[CLASS:#32770]", "")
WinWait("[CLASS:#32770]", "")
ControlClick ( "[CLASS:#32770]", "", "[ID:254]" )

And it didn't work

Share this post


Link to post
Share on other sites
jdelaney

Your screenshot is for a different ID...try:

$hWindow = WinGetHandle("LiveClient")
ConsoleWrite($hWindow & @CRLF)
WinSetState($hWindow,"",@SW_MAXIMIZE)
$hControl = ControlGetHandle($hWindow,"",134)
ConsoleWrite($hControl & @CRLF)
ControlClick($hWindow,"",$hControl)

Verify the console outputed handles are the proper ones in the spy tool.

Note: I am intentionally removing the class as the window identifier, because that's so generic it can grab a ton of windows, which may cause you debugging nightmares later.

Edited by jdelaney
  • Like 2

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
fchelp
54 minutes ago, jdelaney said:

Your screenshot is for a different ID...try:

$hWindow = WinGetHandle("LiveClient")
ConsoleWrite($hWindow & @CRLF)
WinSetState($hWindow,"",@SW_MAXIMIZE)
$hControl = ControlGetHandle($hWindow,"",134)
ConsoleWrite($hControl & @CRLF)
ControlClick($hWindow,"",$hControl)

Verify the console outputed handles are the proper ones in the spy tool.

Note: I am intentionally removing the class as the window identifier, because that's so generic it can grab a ton of windows, which may cause you debugging nightmares later.

Thanks so so much!! this works!

Is there a way to read the value of a variable? (i want to compare the Handle and Control ID the script finds and the spy tool find are the same) 

Thanks

Share this post


Link to post
Share on other sites
Earthshine

i verify by making sure that the handle i have, there is a control with text that I search for to know I have the right one. not sure if ID is way to go but do try and post back. in your example, you only have ID, no text, but you could also check that the text was an empty string = ""

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×