Jump to content

Send not working on active window


fchelp
 Share

Recommended Posts

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. 

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

$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
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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
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.
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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
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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...