Jump to content

MouseDrag Movement in a background window


Recommended Posts

Hi,

The following is my script for auto clicking within a program call Wnd. With this codes, the control click function still runs although the program Wnd is in the background.

Dim $On
Dim $handle = WinGetHandle("Wnd")

While 1
    While $On = True
    ControlClick( $handle, "", "" ,"left" , 1 , 441 , 106 )
    Sleep(800)
    ControlClick( $handle, "", "" ,"left" , 1 , 441 , 106 )
    Sleep(5000)
    WEnd
    Sleep(100)
WEnd

I wanted to add a mouse drag function but it doesn't work within the program.

I tried MouseClickDrag and it targes my whole monitor screen. May I ask for guidance on how to use MouseClickDrag within the program Wnd only?

Thank you very much.

Link to comment
Share on other sites

That's easy just exit the inner loop when window is not active:

Dim $On
Dim $handle = WinGetHandle("Wnd")

While 1
    While $On = True
        If Not WinActive($handle) Then ExitLoop
        ControlClick($handle, "", "", "left", 1, 441, 106)
        Sleep(800)
        ControlClick($handle, "", "", "left", 1, 441, 106)
        Sleep(5000)
    WEnd
    Sleep(100)
WEnd

 

Link to comment
Share on other sites

1 hour ago, AutoBert said:

That's easy just exit the inner loop when window is not active:

Dim $On
Dim $handle = WinGetHandle("Wnd")

While 1
    While $On = True
        If Not WinActive($handle) Then ExitLoop
        ControlClick($handle, "", "", "left", 1, 441, 106)
        Sleep(800)
        ControlClick($handle, "", "", "left", 1, 441, 106)
        Sleep(5000)
    WEnd
    Sleep(100)
WEnd

 

Hello, Thank you very much for your reply.

However, as i have tested, the controlclick from the original codes can be use even when the window is in the background.

However, the ControlClick does not make the mouse cursor drag. 

Is there any other way that you can advise besides the Control Click to achieve the mouse drag behavior?

Thank you very much for your kind response.

Link to comment
Share on other sites

Why would you need a mouse drag behavior on a background window? What do you expect the mouse in the foreground window to do then?

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

Would you please be so kind to post your solution so it might be useful for other users in the future?

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

Hi, to be honest, It's not as fantastic as what you all think.

Is just that i sacrifice my screen while letting the sequence run.

That's all.

But I'm quite curious, is there a limitation to Windows Operating System that there wasn't a "ControlClickDrag" programmed in AutoIT?

Link to comment
Share on other sites

9 minutes ago, CrvzLee said:

Apology for the double reply as i could not find the edit button. in my research, i found something like this   https://www.autoitscript.com/forum/topic/147988-controlclick-down-and-up/ but i couldnt get it incorporated to my sequence. So i end up giving up.

and something call ControlMove (https://www.autoitscript.com/autoit3/docs/functions/ControlMove.htm) which i can't seem to get it to work. Any advise? 

9 minutes ago, CrvzLee said:

 

 

Link to comment
Share on other sites

Thing is, you don't say exactly what it is you are trying to accomplish with a pseudo ControlClickDrag. It could help with a suggestion for another path to take.

There is not one in autoit because it cannot be accomplished with the windows api.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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