CrvzLee

MouseDrag Movement in a background window

10 posts in this topic

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.

Share this post


Link to post
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

 

Share this post


Link to post
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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

the reason is so that I can still use my monitor for something else while the sequence is running.

:)

Anyway, i got it sorted out already.

Thank you very much for your help.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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?

Share this post


Link to post
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:

 

 

Share this post


Link to post
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.

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