Azu Posted July 20, 2006 Share Posted July 20, 2006 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? Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 The answer is actually in the topic, currently RIGHT BELOW THIS ONE!! The Topic github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 (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 July 20, 2006 by Azu Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 I was referring to MouseClickPlus: expandcollapse popup;=============================================================================== ; ; 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 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? Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 (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 July 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 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? 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. Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 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 isexpandcollapse popup#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 Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 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 !! ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 Thanks.. it runs without errors now 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 Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 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") github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 It still doesn't do anything.. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 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 Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 (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. Edit3: I still can't get it to work! expandcollapse popupOpt("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 July 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 (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 July 20, 2006 by Azu Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 It is. But when you try to pass "56" as Int it won't work. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 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.. Link to comment Share on other sites More sharing options...
jvanegmond Posted July 20, 2006 Share Posted July 20, 2006 It should be working by now. I think everything is being taken into account, perhaps you should PM simucal with the problem. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Azu Posted July 20, 2006 Author Share Posted July 20, 2006 I don't understand.. "by now"? Does it have a delayed reaction? Like half an hour afterwords, it will do it? :S Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now