Sign in to follow this  
Followers 0
DickWms

Autoit Created .exe on Windows 7 Computer

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Now this is strange :huggles: ... it works fine on my Win7, but I can't see why it does :D... 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()

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

KaFu, he is using the mouse mode option for coordinates relative to the active window. It's not a bug.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

KaFu, he is using the mouse mode option for coordinates relative to the active window. It's not a bug.

Ah :huggles:, I see... relative to active window, always thought MouseCoordMode = 0 means relative to AutoIt GUI (never used it :D ). Thanks for the clarification Richard :... then there's nothing to complain about, works fine on my Win7 machine... Edited by KaFu

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

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
Sign in to follow this  
Followers 0