DickWms Posted February 2, 2010 Share Posted February 2, 2010 I'm writing an AutoIt application on an XP computer. The app runs fine on the XP computer and a Vista Home Basic computer. But it does not run reliably on a Windows 7 Home Premium computer when I send the .exe file to a friend. This short program demonstrates the problem.#include <GUIConstantsEx.au3>$window1 = GUICreate("Window 1", 200, 200, 400, 300)$button = GUICtrlCreateButton(" Click ", 80, 100)GUISetState(@SW_SHOW)Opt("MouseCoordMode",0)While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $button WinActivate("Band Master") WinWaitActive("Band Master") Sleep(1000) $pos = MouseGetPos() MouseClick("left",94,140,1,20) MouseMove($pos[0],$pos[1],20) Case $msg[0] = $GUI_EVENT_CLOSE ExitLoop EndSelectWEnd Hitting the "Click" button should cause the cursor to go to the Band Master Window and then return to the "Click" button. He tells me some times the cursor moves to the Band Master window when he hits the "Click" button but most times it doesn't. We have tried the same code to go to a second window that AutoIt created and that worked fine.I don't know what to try to get this simple program to work. Any help would be appreciated.Dick Williams Link to comment Share on other sites More sharing options...
KaFu Posted February 2, 2010 Share Posted February 2, 2010 MouseClick() coords are hardcoded... use wingetpos() to set the coords dynamically... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
DickWms Posted February 3, 2010 Author Share Posted February 3, 2010 MouseClick() coords are hardcoded... use wingetpos() to set the coords dynamically... Thank you for the suggestion. I'm not sure I understand what you had in mind but I gave it a try with the following code. #include <GUIConstantsEx.au3> $window1 = GUICreate("Window 1", 200, 200, 400, 300) $button = GUICtrlCreateButton(" Click ", 80, 100) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $button WinActivate("Band Master") WinWaitActive("Band Master") Sleep(1000) $pos = MouseGetPos() $BMwindow= WinGetPos("Band Master") MouseClick("left",$BMwindow[0] + 94,$BMwindow[1] + 140,1,20) MouseMove($pos[0],$pos[1],20) Case $msg[0] = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd The new code still runs intermittently. Sometimes one mouse click will cause the cursor to move, sometimes it takes multiple clicks. And the cursor doesn't move slow enough for the user to see where it's going. Again, these problems only occur on the Windows7 computer. The new version runs fine on the XP computer. Dick Williams Link to comment Share on other sites More sharing options...
KaFu Posted February 3, 2010 Share Posted February 3, 2010 Now this is strange ... it works fine on my Win7, but I can't see why it does ... in MouseClick("left", 94, 140, 1, 20) you refer to fixed coordinates, but regardless where the target window is located, the script moves the mouse correctly for me. Don't know, but maybe worth a bug report? #include <GUIConstantsEx.au3> $window1 = GUICreate("Window 1", 200, 200, 400, 300) $button = GUICtrlCreateButton(" Click ", 80, 100) GUISetState(@SW_SHOW) Opt("MouseCoordMode", 0) While 1 $msg = GUIGetMsg() Select Case $msg = $button WinActivate("Band Master") WinWaitActive("Band Master") $pos = MouseGetPos() MouseClick("left", 94, 140, 1, 20) MouseMove($pos[0], $pos[1], 20) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Target Window (compile and run) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $msg GUICreate("Band Master") ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Richard Robertson Posted February 3, 2010 Share Posted February 3, 2010 (edited) KaFu, he is using the mouse mode option for coordinates relative to the active window. It's not a bug. Edited February 3, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
KaFu Posted February 3, 2010 Share Posted February 3, 2010 (edited) KaFu, he is using the mouse mode option for coordinates relative to the active window. It's not a bug.Ah , I see... relative to active window, always thought MouseCoordMode = 0 means relative to AutoIt GUI (never used it ). Thanks for the clarification Richard ... then there's nothing to complain about, works fine on my Win7 machine... Edited February 3, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
DickWms Posted February 4, 2010 Author Share Posted February 4, 2010 This exchange hasn't helped me understand why my program, which runs fine on an XP computer, does not run on a Windows7 Home Premium computer. I suspect there may be some peculiarity in the Band Master GUI which causes this but I don't have any idea what that might be and how to get around it. The same version of Band Master is running on both computers. Any ideas will be appreciated. Dick Williams Link to comment Share on other sites More sharing options...
Richard Robertson Posted February 5, 2010 Share Posted February 5, 2010 It's possible that the application has a separate version for XP and 7. Does your friend had UAC active on his computer? It's possible that Windows is preventing the automation. 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