Jump to content

Recommended Posts

Posted (edited)

Hi,

I am trying to send press shift down to an inactive window and afterwards left clicking the mouse. The window has no controls, hence i send a ControlClick without controls.

ControlSend($hwdn, "", "", "{SHIFTDOWN}")
Sleep(500)
ControlClick($hwdn, "", "", "Left", 1, 401, 307)

This sometimes works, sometimes doesn't, it seems to depend on the internal state of the window, i really don't know. What does fix it is activating the window manually, pressing shift shortly (sometimes takes a few tries, but typically 1) and then deactivating the window and executing the above code again. At some point it breaks again and i have to repeat the manual intervention (i know i could  script activating the window, but i would like to do it in the background). Also, this works fine for other interactions, but the shift down seems to be something special. Sending text and what not works fine.

Anyone has a clue what could be going on here?

I have also been playing around with the _SendMessage function, but that doesn't seem to register the shift down event at all.

Func WindowClick_ShiftDown_Plus($hwnd,$x,$y)
    Local $WM_MOUSEMOVE     =  0x0200
    Local $VK_LSHIFT         =  0xA0
    Local $MK_LBUTTON       =  0x0001
    Local $WM_LBUTTONDOWN   =  0x0201
    Local $WM_LBUTTONUP     =  0x0202
    Local Const $WM_KEYDOWN = 0x0100
    Local Const $WM_KEYUP   = 0x0101
    _SendMessage($hWnd, $WM_KEYDOWN, $VK_LSHIFT, 0)
    Sleep(100)
    _SendMessage($hwnd, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($x, $y))
    Sleep(50)
    _SendMessage($hwnd, $WM_LBUTTONUP, $MK_LBUTTON, _WinAPI_MakeLong($x, $y))
   Sleep(100)
   _SendMessage($hWnd, $WM_KEYUP, $VK_LSHIFT, 0)
EndFunc

 

Thanks for any help!

Edited by cageman
Posted (edited)
18 hours ago, Nine said:

hmmm, what is the application you are trying to automate this way ?  I am sure there is a better solution...

internal application of a client, but its a shortcut in the application that cannot be changed, that is for sure.

Edited by cageman

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...