Jump to content

Can't send clicks to specific Window


Mads
 Share

Recommended Posts

Hi,

I have a bit of a headache over simple script I am trying to create.

I want to send some numbers to a control in a windows, and click a button afterwards.

But I can't seem to get anything working in the specific window.

My tests script:

Opt("MouseCoordMode",0)
Local $hWnd = WinWait("[TITLE:WindowX; CLASS:TfrmMain]", "", 1)
WinActivate($hWnd)
ControlClick($hWnd, "", "[CLASSNN:Edit7]")
ControlSend($hWnd, "", "[CLASSNN:Edit7]", "333")
MouseClick("left", 179, 308, 1,0)
 
For testing purposes I set the mouse pointer in another control.
 
This happens:
Window is activated (if not minimized - anyway to test for state and restore?)
aaaaaaand NOTHING :-(
 
The funny thing is that I have tested this on another PC running the same program, and there it works.
I have tried with notepad instead of the specific program, and that works fine.
 
So it seems that it is something on this PC.
Specs on the PC:
Windows 7 Ultimate
32 Bit
Running script as .Exe file, but have tried with the .au3 with no changes
 
The user security rights are a bit specific on the PC, so that's my best shot at where the problem is. Could that be the cause?
 
Thanks...
 
 
Link to comment
Share on other sites

Use ControlSetText, it get's around the need to 'click' the edit.  Also, rather than click, if it does resist automation, use ControlFocus.

The same should be done for the button(?) click.

Use ControlFocus, and then ControlClick.

You can try to run your script with #requireAdmin.

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 jdelaney,

That worked perfect.

I had to use the #Requireadmin to get it working - or manually right click and "Run as administrator".

Now that's working :-)

However my other program can show a message window if an error occurs. Would that be possible to catch, and give a msgbox about. 

Or better if that messagebox comes, then I do not want to switch windows again back to my mail program.

Would i have to use the activewindows and find if my error box is active?

Properties of the box:

Title: Scan (Same as main window)

Class: TMessageForm

Thanks

 

Link to comment
Share on other sites

You would need to check for the error messages at logical points.

This will grab the dialog's window handle (if it exists):

#include <WinAPI.au3>
$hPopupWindow = _WinAPI_GetWindow($hYourApplicationWindow,6)
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

Hi, 

I think I got the script working as I want.

Instead of the WinAPI_GetWindow solution I just checked for a TMessageForm Window. It is not the most neat solution, but it works.

Thanks for the help.

SorryButImaNewbie - what have you done with PDFCreator? Just interested. :)

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...