Mads Posted January 6, 2015 Share Posted January 6, 2015 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 More sharing options...
jdelaney Posted January 6, 2015 Share Posted January 6, 2015 (edited) 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 January 6, 2015 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 More sharing options...
Mads Posted January 7, 2015 Author Share Posted January 7, 2015 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 More sharing options...
SorryButImaNewbie Posted January 7, 2015 Share Posted January 7, 2015 and if you have problems with ControlSetText (I ran into some for example in PDFCreator) you can try ControlFocus and then Send. Link to comment Share on other sites More sharing options...
jdelaney Posted January 7, 2015 Share Posted January 7, 2015 (edited) 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 January 7, 2015 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 More sharing options...
Mads Posted January 8, 2015 Author Share Posted January 8, 2015 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 More sharing options...
SorryButImaNewbie Posted January 12, 2015 Share Posted January 12, 2015 Saveing Bills from test Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now