Jump to content
kcvinu

How to know if a button is clicked

Recommended Posts

kcvinu

Hi all,

I have searched this forum for a solution. But i couldn't find one. I have a third party application and it has a button. I need to start my script when that button is clicked. I have tried with "GUIGetMsg" function but didn't work. I have all the information about that program like window title and button handle etc. Please help.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
VIP

Example in F1 work fine!

Example()

Func Example()
    Local $hGUI = GUICreate("Example", 300, 200)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
            Case $idClose
                MsgBox(0,"","YouPess Close")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Regards,
 

Share this post


Link to post
Share on other sites
kcvinu

Hi  

Trong, i have already said that gui getmsg is not working for me. Because it is a third party app. not created by me. So how can i use GuiGetMsg ?

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
kcvinu

Hi 

l3ill, i didn't get your point. 

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
l3ill

Well, you are trying to run a script the second you push a button in a 3rd party software.

Which is proving to be a challenge.

My suggestion is to start your 3rd party program with your script.

Which can in turn push this button and any other functions you care to add.

Example:

I have a cubase (music mixing software) template that I start anytime I want to practice.

It needs 20-40 seconds to load and there are several pop ups that have to be clicked for it to continue loading.

I made a script that starts cubase with the practice template and continues running, watching for the pop ups and clicks on them as they appear.

Just a suggestion on a different way to proceed, may or may not be viable for your situation.

good luck !

Bill

  • Like 1

Share this post


Link to post
Share on other sites
kcvinu

Hi 

l3ill, That's a good idea. I can wrap the 3rd party app inside my script. Thank you for this suggestion. But What about  my question ?. Is that an impossible task ?

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
VIP

I'm a idiot? Sorry I did not read carefully!


Regards,
 

Share this post


Link to post
Share on other sites
kcvinu

Hi 

Trong, it's oke. No problem..

:)


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
SmOke_N

_WinAPI_SetWindowsHookEx for monitoring/interacting 3rd party applications.

  • Like 1

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
kcvinu

Hi 

SmOke_N, Thank you. Let me try. :)

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

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

  • Similar Content

    • Skysnake
      By Skysnake
      I need to automate a specific GUI from a legacy system written in C.
      The spy tool gives me this

      I use this code
      Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
      I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
      I also tried the control ID as text "404" - same result
      What am I missing?
      Skysnake
       
    • JNutt
      By JNutt
       

       
       
      I'm trying to use mouseclick in a panel above.  I want to click on a list item, such as 'Estimated'.  (I've given up on trying to use control click for this).  I'm using window info coordinates from 'Control' tab.

      ; click 'Columns' WinActivate("Innovaya Studio with Sage (Archtectural 2017_V1.invx") MouseClick("primary", 292, 88, 1, 1) WinActivate("Select Browsing Properties") Sleep(1000) MouseClick("primary", 27, 70, 0,0) Sleep(2000) Send("{TAB}{TAB}{TAB}{TAB}{TAB}") Sleep(1000) Send("{ENTER}") ControlClick( But when I used the code Autoit doesn't click where the coordinates are.  In the scipts it is the second MouseClick that won't work.  Any ideas?
    • Miliardsto
      By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
    • ur
      By ur
      I am clicking on a button on to submit o form UI.
      Problem is, the code working on windows 10,7, server 2012 r2 but not on windows server 2008.
      I checked the IDs also on that OS, they didn't change.
      Even the ControlClick is returning the status as success only but button is not getting clicked.
      But controlsettext on other fields are working.
      ;$MartConfigWindow is window object ControlClick($MartConfigWindow, "", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:2]")  
    • lattey
      By lattey
      I used the window info tool to get what I've got below, but it just doesn't click the button. I run the script, nothing happens. 
      WinActivate("SELECTION") Sleep(200) ControlClick("SELECTION", "", "[CLASS:Button;INSTANCE:2]") i think maybe the autoit cannot detect the windows. So what i do:
       
      MouseClick( "", 503, 500) local $blanktitle = WinGetTitle("[ACTIVE]") If StringInStr($blanktitle, "SELECTION") Then msgbox("","", "got") WinActivate($blanktitle) ControlClick($blanktitle, "", "[CLASS:Button;INSTANCE:2]") Endif The script can detect the windows as the it is prompt "got" message. But it just doesn't click the button.
      Please help.
      Thanks for any help you can offer.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.