jamief00
Members-
Posts
9 -
Joined
-
Last visited
jamief00's Achievements
Seeker (1/7)
0
Reputation
-
Script not working as Scheduled Task
jamief00 replied to jamief00's topic in AutoIt General Help and Support
Did you bother to read my post? I'm well aware of what happens when the screen is locked, which is why I'm using _SendMouseMove. -
The following script works perfectly when run on a machine with the screen unlocked. However when running as a scheduled job, or running on a remote machine and then disconnecting means it doesn't work properly (the script stops working at the _MouseClickPlus calls (i.e. they don't work). Not sure why they don't work when the screen is locked as they look to be using standard user32.dll calls? Dim $backofficeUser $backofficeUser = "Backoffice [" & StringUpper(@UserName) &"]" ;MsgBox(0, "1", $backofficeUser) ;MsgBox(0, "1", @UserName) Run ("C:\Program Files\WMS\LISA\LISABOff.exe") ;WinWaitActive("Logon - Backoffice") Sleep(5000) ControlClick("Logon - Backoffice", "", "[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;WinWaitActive($backofficeUser) Sleep(5000) AutoItSetOption("MouseCoordMode",0) _MouseClickPLus($backofficeUser, "left", 56, 858, 1) Sleep(1000) ControlFocus ( $backofficeUser, "", "[CLASS:SSListbarWndClass; INSTANCE:1]" ) Sleep(1000) _SendMouseMove($backofficeUser, 67, 410) Sleep(1000) _SendMouseMove($backofficeUser, 67, 411) Sleep(2000) ControlClick($backofficeUser, "", "[CLASS:SSListbarWndClass; INSTANCE:1]", "left", 1, 67, 410) _MouseClickPLus($backofficeUser, "left", 67, 410, 1) ;WinWaitActive($backofficeUser) sleep(10000) ControlClick($backofficeUser, "", "[CLASS:ListView20WndClass; INSTANCE:3]", "left", 1, 196, 29) ControlClick($backofficeUser, "", "[CLASS:ThunderRT6CheckBox; INSTANCE:7]") ControlClick($backofficeUser, "", "[CLASS:ThunderRT6CheckBox; INSTANCE:8]") ControlClick($backofficeUser, "", "[CLASS:ThunderRT6CommandButton; INSTANCE:3]") ;WinWaitActive("Price Feed Update") sleep(2000) ControlClick("Price Feed Update", "", "[CLASS:Button; INSTANCE:1]") ;OK Button ;ControlClick("Price Feed Update", "", "[CLASS:Button; INSTANCE:2]") ;Cancel Button _MouseClickPLus is ;=============================================================================== ; 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", "PostMessage", _ "hwnd", ControlGetHandle($Window, "", "[CLASS:SSListbarWndClass; INSTANCE:1]") , _ "int", $WM_MOUSEMOVE, _ "int", 0, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", ControlGetHandle($Window, "", "[CLASS:SSListbarWndClass; INSTANCE:1]"), _ "int", $ButtonDown, _ "int", $Button, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", ControlGetHandle($Window, "", "[CLASS:SSListbarWndClass; INSTANCE:1]"), _ "int", $ButtonUp, _ "int", $Button, _ "long", _MakeLong($X, $Y)) Next EndFunc ;==>_MouseClickPlus Func _SendMouseMove($Window, $X = "", $Y = "", $Speed = 10) Local $WM_MOUSEMOVE = 0x0200 Local $WinHandle = WinGetHandle($Window) Local $i = 0 Local $MouseCoord = MouseGetPos() $StartX = $MouseCoord[0] $StartY = $MouseCoord[1] If $X = "" OR $Y = "" Then $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf $StopX = $X $StopY = $Y If $Speed > 0 Then $JumpX = ($StopX - $StartX) / $Speed $JumpY = ($StopY - $StartY) / $Speed For $i = 1 to $Speed $X = $X + $JumpX $Y = $Y + $JumpY $lCoords = _MakeLong($X, $Y) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) Sleep(10) Next EndIf $lCoords = _MakeLong($StopX, $StopY) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) EndFunc And _SendMouseMove is Func _SendMouseMove($Window, $X = "", $Y = "", $Speed = 10) Local $WM_MOUSEMOVE = 0x0200 Local $WinHandle = WinGetHandle($Window) Local $i = 0 Local $MouseCoord = MouseGetPos() $StartX = $MouseCoord[0] $StartY = $MouseCoord[1] If $X = "" OR $Y = "" Then $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf $StopX = $X $StopY = $Y If $Speed > 0 Then $JumpX = ($StopX - $StartX) / $Speed $JumpY = ($StopY - $StartY) / $Speed For $i = 1 to $Speed $X = $X + $JumpX $Y = $Y + $JumpY $lCoords = _MakeLong($X, $Y) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) Sleep(10) Next EndIf $lCoords = _MakeLong($StopX, $StopY) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) EndFunc Func __SendMessageCall($WinHandle, $iAction, $iParam, $lCoords) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", $WinHandle, _ "int", $iAction, _ "int", $iParam, _ "long", $lCoords) EndFunc Func _MakeLong($LoWord, $HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc ;==>_MakeLong To my knowledge this should work whether the screen is locked or not, as it is using low-level user32 calls. Can anyone see why it would stop working at the _MouseClickPLus($backofficeUser, "left", 67, 410, 1) line? Thanks.
-
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
It was essentially this: Func _SendMouseMove($Window, $X = "", $Y = "", $Speed = 10) Local $WM_MOUSEMOVE = 0x0200 Local $WinHandle = WinGetHandle($Window) Local $i = 0 Local $MouseCoord = MouseGetPos() $StartX = $MouseCoord[0] $StartY = $MouseCoord[1] If $X = "" OR $Y = "" Then $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf $StopX = $X $StopY = $Y If $Speed > 0 Then $JumpX = ($StopX - $StartX) / $Speed $JumpY = ($StopY - $StartY) / $Speed For $i = 1 to $Speed $X = $X + $JumpX $Y = $Y + $JumpY $lCoords = _MakeLong($X, $Y) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) Sleep(10) Next EndIf $lCoords = _MakeLong($StopX, $StopY) __SendMessageCall($WinHandle, $WM_MOUSEMOVE, 0, $lCoords) EndFunc Func __SendMessageCall($WinHandle, $iAction, $iParam, $lCoords) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", $WinHandle, _ "int", $iAction, _ "int", $iParam, _ "long", $lCoords) EndFunc -
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
Well, managed to get a little further, using the _MouseClickPlus script. I use the _SendMouseMove and then _MouseClickPLus commands, and it appears to click the button. However I then get the following error: --------------------------- Backoffice --------------------------- Initialisation of price feed failed with the following error : Automation error An outgoing call cannot be made since the application is dispatching an input-synchronous call. --------------------------- OK --------------------------- -
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
Yes - using Au3Info, the whole control is highlighted and has the same classname... -
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
I used Au3Info.exe Initially my screen is like this: I used ControlClick($backofficeUser, "", "[CLASS:SSListbarWndClass; INSTANCE:1]", "left", 1, 56, 858) Which works fine, and gives me this: However no matter what I try (coordinates wise), I can't get controlclick to work on the price feed update button. There are no keyboard shortcuts on this control. THe only thing that works in MouseClick, but that isn't suitable as this needs to be a scheduled job. ControlClick($backofficeUser, "", "[CLASS:SSListbarWndClass; INSTANCE:1]", "left", 1, 51, 377) Doesn't work. -
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
The coordinates I used above are correct - confirmed with mouseclick (prob a copy paste error in my post above). The issue is that the control doesn't seem to receive ControlClick events. Can anyone help? -
ControlClick not working on Listbar type control
jamief00 replied to jamief00's topic in AutoIt General Help and Support
Hi - I need to use the coordinates, as the control is an "outlook" style listbar. I need to click the "Price Feed Update". The coordinates are correct, its just that the control doesn't seem to receive the correct events. Using Spy++, when I do it manually I get <00038> 00890140 R WM_NCHITTEST nHittest:HTCLIENT <00039> 00890140 S WM_MOUSEACTIVATE hwndTopLevel:004D00F4 nHittest:HTCLIENT uMsg:WM_LBUTTONDOWN <00040> 00890140 R WM_MOUSEACTIVATE fuActivate:MA_ACTIVATE <00041> 00890140 S WM_SETCURSOR hwnd:00890140 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN <00042> 00890140 S WM_NCHITTEST xPos:59 yPos:448 <00043> 00890140 R WM_NCHITTEST nHittest:HTCLIENT <00044> 00890140 R WM_SETCURSOR fHaltProcessing:False <00045> 00890140 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:59 yPos:376 <00046> 00890140 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:59 yPos:376 However ControlClick does <00001> 005600F4 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:51 yPos:379 <00002> 005600F4 P WM_LBUTTONUP fwKeys:0000 xPos:51 yPos:379 <00003> 005600F4 S WM_CAPTURECHANGED hwndNewCapture:00000000 <00004> 005600F4 R WM_CAPTURECHANGED -
I have a script which needs to be executed by scheduled job - everything works when I'm logged on (I used MouseClick for one event). However when I switch to using ControlClick, it doesn't work. The control is >>>> Window <<<< Title: Backoffice [JFR] Class: ThunderRT6MDIForm Position: -4, -4 Size: 1288, 1002 Style: 0x17CF0000 ExStyle: 0x00040100 Handle: 0x00180212 >>>> Control <<<< Class: SSListbarWndClass Instance: 1 ClassnameNN: SSListbarWndClass1 Name: Advanced (Class): [CLASS:SSListbarWndClass; INSTANCE:1] ID: Text: Position: 0, 3 Size: 113, 903 ControlClick Coords: 57, 417 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x00110368 >>>> Mouse <<<< Position: 57, 489 Cursor ID: 0 Color: 0x848284 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Blank Form >>>> Hidden Text <<<< I'm using ControlClick($backofficeUser, "", "SSListbarWndClass", "left", 1, 57, 489) Which doesn't work, but the following does MouseClick("left", 57, 489) Can anyone help?