Jump to content

Struggle on converting Logitech LUA to AutoIT


Recommended Posts

Hi

I've changed my mouse from Logitech to non-Logitech one and it's time to discover beauty of AutoIT...

Quite unfortunately I found converting the script that worked inside Logitech software a bit too much for me and google to get done easily in one evening.

The script is very basic, it moves mouse relatively on event (on left click when the right click is depressed) - first it executes one, let me name it 'sequence', of moves and then the other sequence is repetitively played for as long as I hold triggering button(s). The second function is to press a keyboard key both on press and release mouse button 2.

function OnEvent(event, arg, family)
EnablePrimaryMouseButtonEvents(true);


if (event == "MOUSE_BUTTON_PRESSED" and arg == 2)  then

Sleep(5)
PressKey("up")
Sleep(35)
ReleaseKey("up")
Sleep(45)

end

if (event == "MOUSE_BUTTON_RELEASED" and arg == 2)  then

Sleep(5)
PressKey("up")
Sleep(35)
ReleaseKey("up")
Sleep(45)

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1)  then
if (IsMouseButtonPressed(3)) then

Sleep(33)
MoveMouseRelative(-1, 4)
Sleep(1)
MoveMouseRelative(-1, 4)
Sleep(1)
MoveMouseRelative(-1, 10)
Sleep(33)

repeat

MoveMouseRelative(0, 3)
Sleep(1)
MoveMouseRelative(-1, 3)

until not (IsMouseButtonPressed(1))

end
end
end

So here is my try on AutoIT, function has been found on this forum

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

Func _MouseMoveRelative ($iX, $iY)
Local Const $MOUSEEVENTF_MOVE = 0x01
DllCall ("user32.dll", "int", "mouse_event", _
"int", $MOUSEEVENTF_MOVE, _
"int", $iX, _
"int", $iY, _
"int", 0, _
"int", 0)
EndFunc

While 1
If _IsPressed("01", $hDLL) and _IsPressed("02", $hDLL) Then
Sleep(33)
_MouseMoveRelative (-1, 4)
Sleep(1)
_MouseMoveRelative (-1, 4)
Sleep(1)
_MouseMoveRelative (-1, 10)
   While 1
      If _IsPressed("01", $hDLL) and _IsPressed("02", $hDLL) Then
      _MouseMoveRelative (-10, 60)
   EndIf
   WEnd
EndIf
WEnd

There are 2 major problems:

The first one - script doesn't reset after mouse buttons are released, it starts from second loop when I press buttons again.

The second one - it seems like in second loop it doesn't move relatively anymore, instead it works on absolutes

Help?

Thank you

Link to comment
Share on other sites

Certainly I originally wrote this script to help me automate building grids in gridless game. To be exact in CitiesXL you have to make A LOT of mouse operations in order to build certain building, then build a road around it, then select same bulding and so on...

If this sort of automating a singleplayer game is against forum ethics then... Well, fair enough

Link to comment
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
 Share

  • Recently Browsing   0 members

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