Sign in to follow this  
Followers 0
Azu

Controlling minimized full-screen apps

25 posts in this topic

Is it possible to control a full screen application that is minimized, and do other things on the computer at the same time, without my real mouse cursor being controlled by autoit, only the one in the minimized full screen application? So that I can move my mouse around and do other stuff without interfering with autoit and without autoit interfering with me?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Sorry forgot to mention.. the things autoit would be clicking on don't have controlids..

The

Func QuickClick($button="left",$x,$y,$clicks=1)

Local $Pos = MouseGetPos()

MouseClick($button,$x,$y,$clicks,0)

MouseMove($Pos[0],$Pos[1],0)

EndFunc

Looks like it would work.. except it won't be able to control an app I have minimized..

Edited by Azu

Share this post


Link to post
Share on other sites

I was referring to MouseClickPlus:

;===============================================================================
;
; Function Name:  _MouseClickPlus()
; Version added:  0.1
; Description:    Sends a click to window, not entirely accurate, but works
;                 minimized.
; Parameter(s):   $Window     =  Title of the window to send click to
;                 $Button     =  "left" or "right" mouse button
;                 $X          =  X coordinate
;                 $Y          =  Y coordinate
;                 $Clicks     =  Number of clicks to send
; Remarks:        You MUST be in "MouseCoordMode" 0 to use this without bugs.
; Author(s):      Insolence <insolence_9@yahoo.com>
;
;===============================================================================
Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202
  
  Local $MK_RBUTTON       =  0x0002  
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200
  
  Local $i                = 0
  
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
  
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
  
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Share this post


Link to post
Share on other sites

Oh.. nice..

But will I have to copy that all for every single click I want it to make? Or is there a way to call it?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's a function so you can call it by just doing this:

_MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)

(Fill in the parameters)

Edit: Example: _MouseClickPlus("AutoIt", "Left", 100, 100, 1)

And put the big function(s) at the end of your script.

Edited by Manadar

Share this post


Link to post
Share on other sites

Oh.. nice..

But will I have to copy that all for every single click I want it to make? Or is there a way to call it?

Your kidding right?

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)

_MouseClickPlus($Window, "left", $X, $Y, $Clicks) To call it?


[center]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.[/center]

Share this post


Link to post
Share on other sites

What am I doing wrong? It's saying

---------------------------

AutoIt Error

---------------------------

Line 3 (File "C:\Documents and Settings\Administrator\Desktop\test.au3"):

_MouseClickPlus($Window = "text.txt", $Button = "left", $X = "58", $Y = "105", $Clicks = 2)

_MouseClickPlus(^ ERROR

Error: Variable used without being declared.

---------------------------

OK

---------------------------

The script is
#include <GUIConstants.au3>

_MouseClickPlus($Window = "text.txt", $Button = "left", $X = "58", $Y = "105", $Clicks = "2")


Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON    =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP    =  0x0202
 
  Local $MK_RBUTTON    =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP    =  0x0205

  Local $WM_MOUSEMOVE    =  0x0200
 
  Local $i              = 0
 
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
 
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
 
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Share this post


Link to post
Share on other sites

I edited but i guess i was too late..

_MouseClickPlus("text.txt", "left","58", "105", "2")

Is how it should have looked. (Like in every other function !! )

Share this post


Link to post
Share on other sites

Thanks.. it runs without errors now :D

But.. it doesn't seem to do anything..

When I run the script nothing happens..

But when I bring up text.txt and click at those coordinates manually with my mouse, it moves the cursor to there.

text.txt is open in notepad btw, and it shows as "text.txt - Notepad" so I changed the script to reflect that.. but still nothing happens.. I don't understand x_x

Share this post


Link to post
Share on other sites

Use the partial name of the window (e.g. Notepad), and then use the Opt("WinTitleMatchMode", 2) in the top of your script (before the mouseclickplus call) Otherwise, the $window parameters needs to be the EXACT FULL title (e.g. "text.txt - Notepad")

Share this post


Link to post
Share on other sites

It still doesn't do anything..

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)

_MouseClickPlus("Notepad", "left","58", "105", "2")

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON    =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP    =  0x0202
 
  Local $MK_RBUTTON    =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP    =  0x0205

  Local $WM_MOUSEMOVE    =  0x0200
 
  Local $i              = 0
 
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
 
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
 
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Share this post


Link to post
Share on other sites

It isn't physically moving your mouse, but it's moving a virtual mouse. I hope you understand that. How are you trying to see wether it has worked or not? That may be the problem.

Share this post


Link to post
Share on other sites

I make a bunch of newlines in a text document, and moved the cursor to the top.. and got the coords for the bottom line.. and tried to set the script to click there.. when I run the script, and then un-minimize the notepad, the cursor is still at the very top, as if autoit didn't click.. O_o

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I've found the problem. You're sending the x,y and clicks parameters as a string. They should be sent as an Int. Dll's are picky when it comes to datatypes (AutoIt has only one datatype)

Edit: I have modified the function to check for errors.. I've also tried doing this myself ^^ It doens't work.. lool.

Edit2: From the original comment: ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs.

:D

Edit3: I still can't get it to work!

Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 0)

_MouseClickPlus("Notepad", "left","","", 1)
If @error Then
    MsgBox(0, "@error", @error)
EndIf

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202

  Local $MK_RBUTTON       =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200

  Local $i                = 0

  If WinGetHandle($Window) = 0 Then
     SetError(2)
  EndIf

  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  Case Else
     SetError(1)
  EndSelect

  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     If Not @error Then
        $X = $MouseCoord[0]
        $Y = $MouseCoord[1]
     Else
        SetError(3)
     EndIF
  EndIf

  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Edited by Manadar

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $WM_MOUSEMOVE, _

"int", 0, _

"long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonDown, _

"int", $Button, _

"long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonUp, _

"int", $Button, _

"long", _MakeLong($X, $Y))"

Shouldn't that be sending it as int?

Edited by Azu

Share this post


Link to post
Share on other sites

How do I pass along the coordinates in a way that the DLL will understand? I've never done anything with DLLs before this.. sorry for being such a newb.. :D

Share this post


Link to post
Share on other sites

It should be working by now. I think everything is being taken into account, perhaps you should PM simucal with the problem.

Share this post


Link to post
Share on other sites

I don't understand.. "by now"?

Does it have a delayed reaction?

Like half an hour afterwords, it will do it?

:S

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