Jump to content

Program doesn't activate visually


 Share

Recommended Posts

I use basic

AutoItSetOption ("CaretCoordMode", 0)
WinActivate("Program")

thing to activate program what I'm running.

Program pops to top, but in the taskbar program isn't activated. Now when I try to send mouse click to it, coordinates doesn't mach with AUInfo coordinates.

I tried also

ControlClick ( "Program", "", (my program ID here), "left", 1 )

but nothing happens.

Basically what I want to do with that program is press couple buttons. Is there better method to do it, or how I can make method above to work?

Link to comment
Share on other sites

ControlClick is the way to go. But from your posting I get the impression that you misinterpret the required parameters. The syntax is:

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]]  )

Title: The title of the window. For notepad this is "Untitled - Notepad"

Text: An (optional) text on the window

ControlId: The Id returned by the GUICtrlCreate.. function.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

ControlClick is the way to go. But from your posting I get the impression that you misinterpret the required parameters. The syntax is:

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]]  )

Title: The title of the window. For notepad this is "Untitled - Notepad"

Text: An (optional) text on the window

ControlId: The Id returned by the GUICtrlCreate.. function.

For example (I took the ID from AUInfo->Control->ID):

ControlClick ( "Calculator", "", 125)

works fine. Number 1 is pressed in windows calculator.

Now when I change "title" -field to program what I want to control and change "controlID" to button what I'd like to be pressed (took that also from AUInfo), it does nothing. I tried also WinActivate and Sleep(1000) before ControlClick line, and it doesn't help.

Why it doesn't work?

Edited by zeruqman
Link to comment
Share on other sites

Can you post a Screenshot of your program (or at least the Window title) and a screenshot of AutoIts Window Info tool (Summary Tab) when you move the mouse over the button you want to click?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

So as the Winow Info Tool can see the button I would use:

ControlClick ("Insert here the window title for your program", "", 1065)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Please run the following code from ScITe and post the console output:

$RC = WinActivate("Insert here the window title for your program")
ConsoleWrite("WinActivate: " & $RC & "-" & @error & @CRLF)
$RC = WinWaitActive("Insert here the window title for your program")
ConsoleWrite("WinWaitActive: " & $RC & "-" & @error & @CRLF)
$RC = ControlClick ("Insert here the window title for your program", "", 1065)
ConsoleWrite("ControlClick: " & $RC & "-" & @error & @CRLF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Please run the following code from ScITe and post the console output:

$RC = WinActivate("Insert here the window title for your program")
ConsoleWrite("WinActivate: " & $RC & "-" & @error & @CRLF)
$RC = WinWaitActive("Insert here the window title for your program")
ConsoleWrite("WinWaitActive: " & $RC & "-" & @error & @CRLF)
$RC = ControlClick ("Insert here the window title for your program", "", 1065)
ConsoleWrite("ControlClick: " & $RC & "-" & @error & @CRLF)

Here's the output:

>"...AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "...New AutoIt v3 Script.au3" /autoit3dir "...AutoIt3" /UserParams    
+>15:46:40 Starting AutoIt3Wrapper v.1.10.1.14    Environment(Language:0409  Keyboard:0000040B  OS:WIN_XP/Service Pack 3  CPU:X86  ANSI)
>Running AU3Check (1.54.14.0)  from:...AutoIt3
+>15:46:40 AU3Check ended.rc:0
>Running:(3.3.0.0):...autoit3.exe "...New AutoIt v3 Script.au3"    
WinActivate: 1-0
WinWaitActive: 1-0
ControlClick: 0-0
+>15:46:40 AutoIT3.exe ended.rc:0
+>15:46:42 AutoIt3Wrapper Finished
>Exit code: 0    Time: 2.408
Edited by zeruqman
Link to comment
Share on other sites

Very strange. Could you please try the following code and post the results?

$RC = WinActivate("Insert here the window title for your program") 
ConsoleWrite("WinActivate: " & $RC & "-" & @error & @CRLF) 
$RC = WinWaitActive("Insert here the window title for your program") 
ConsoleWrite("WinWaitActive: " & $RC & "-" & @error & @CRLF) 
$RC = ControlClick ("Insert here the window title for your program", "", "[CLASSNN:Button16]") 
ConsoleWrite("ControlClick: " & $RC & "-" & @error & @CRLF)

Is my understanging correct that this button has no text in it (according to the screenshot) or have you removed the button text from the screenshot?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That's correct the button has no text in it (it has text, but I suppose it is image though).

Here's the results:

...AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "...New AutoIt v3 Script.au3" /autoit3dir "...AutoIt3" /UserParams    
+>20:21:22 Starting AutoIt3Wrapper v.1.10.1.14    Environment(Language:0409  Keyboard:0000040B  OS:WIN_XP/Service Pack 3  CPU:X86  ANSI)
>Running AU3Check (1.54.14.0)  from:...AutoIt3
+>20:21:22 AU3Check ended.rc:0
>Running:(3.3.0.0):...autoit3.exe "...New AutoIt v3 Script.au3"    
WinActivate: 1-0
WinWaitActive: 1-0
ControlClick: 0-0
+>20:21:23 AutoIT3.exe ended.rc:0
+>20:21:24 AutoIt3Wrapper Finished
>Exit code: 0    Time: 3.668

Only thing what comes to my mind is that program detects when mouse is over this button, and does something when pressed. When mouse button isn't above it and pressed, it does nothing (wonder though what would be the point). I put MouseMove to top of button and then executed the code you gave me, but ControlClick is still giving 0-0. But I'm so novice in programming that these are just random guesses.

Edited by zeruqman
Link to comment
Share on other sites

That's correct the button has no text in it (it has text, but I suppose it is image though).

Pffft, now I'm running out of ideas!

Whatever we do, we can't click this button with ControlClick.

Another idea would be to calculate the position of the button on the screen and use Mouseclick. You could use WinGetPos to get the X and Y position of the window, add the offset of the button (see your screenshot) and use this coordinates as input to Mouseclick.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I ran the following script:

$place= WinGetPos("Program")
MsgBox(0, "Window x,y:", $place[0] & "," & $place[1])
Sleep (100)
WinActivate("Program")
sleep (100)
MouseMove ($place[0], $place[1])

$pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

(this should just tell where is the top left corner of the program, then move mouse to there, and tell the mouse coordinates)

Output gave me same positions two times, they were something like: X:560 Y:240. The programs' top left corner was somewhere else, the coordinates were quite far away from programs' window.

Now, when I add line:

WinMove("Holdem Indicator", "", 0, 0, 200, 200)

(or without ,200, 200 -part, same result occurs)

in front of my code, the message box gives X:0 Y:0 and the window hasn't changed its' place (or size, and the window isn't 200x200 large by default).

I think that I cannot get window position right, so I can't determine where is programs' buttons at to be clicked with MouseClick.

Ideas?

Edited by zeruqman
Link to comment
Share on other sites

Please see this test program:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $sLicenseText = "This is your License Text Line 1" & @CRLF & _
        "This is your License Text Line 2" & @CRLF & _
        "This is your License Text Line 3"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("User License Agreement", 633, 454, 265, 118)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 617, 401, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetData(-1, $sLicenseText)
$Accept = GUICtrlCreateButton("Accept", 8, 416, 129, 25, 0)
$Decline = GUICtrlCreateButton("Decline", 488, 416, 137, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Sleep(5000)

AutoItSetOption("MouseCoordMode",0)
MouseClick("left",76, 450)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Decline
            MsgBox(0, "", "Decline selected")
            Exit
        Case $Accept
            MsgBox(0, "", "Accept selected")
            ExitLoop
    EndSwitch
WEnd

The mouse is moved relative to the window position. So calculate the x and y-coords for the Mouseclick by moving the mouse to the middle of the button, get the mouse position using the Windowinfo Tool and substract the x- and y-coords of the window.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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