Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Medakan
Novice


Joined: 15 Dec 2015
Posts: 41
Location: Seattle

PostPosted: Sun Aug 13, 2017 12:55 am   

Mouse click event in Map window with VBScript?
 
The reason I need a mouse click event in the map window is to clear highlighted rooms (highlighted via the #PATHHIGH command) since there is no other way I can figure to remove it without a mouse click in the map window.

Here are some older posts that touch the subject here on the forums:



Anyone have experience with VBScript in zMUD and want to help me figure this out? Or can point me to some good tutorials and reference materials to help me try to figure it out?


Here is something I found on stackoverflow.com that might just need to be modified to work... not sure (link quoted below): https://stackoverflow.com/questions/36310246/vbs-send-mouse-clicks

Quote:
Here is a routine to send a left or right click to a window (using relative references) in VBA for Excel. Similar to AppActivate, you just need the window title.

The arguments when you call the SendClick routine are:

Window Title (String)
Buttons (1 = Left, 2 = Right, -1 = Move mouse only; no click)
x (Relative position to window Left)
y (Relative position to window Top)
Enjoy!



Code:
'Declare mouse events
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
'Declare sleep
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

' Window location
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type

Public Function WindowHandle(ByVal sTitle As String) As Long
    WindowHandle = FindWindow(vbNullString, sTitle)
End Function

Public Sub SendClick(sWnd As String, b As Integer, x As Long, y As Long)
    Dim pWnd As Long, pRec As RECT

    pWnd = WindowHandle(sWnd)
    GetWindowRect pWnd, pRec

    SetCursorPos pRec.Left + x, pRec.Top + y
    Sleep 50
    If b = 2 Then
        mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
        Sleep 50
        mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
    ElseIf b <> -1 Then
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        Sleep 50
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    End If
End Sub
_________________
Taziar Medakan @ WoTMUD
Reply with quote
Medakan
Novice


Joined: 15 Dec 2015
Posts: 41
Location: Seattle

PostPosted: Sun Aug 13, 2017 1:41 am   
 
One interesting thing I have noticed is if I mouse click on a single room (other than current position room) and then any input via the command line clears that room highlight and places it back over the room of current position. This does not happen though if more than one room is highlighted via mouse click or #PATHHIGH command, only a single room and only if current room position is not highlighted. Just interesting.

Recall also works the same as above, only clearing if one room is selected. More than one room highlighted and the highlighted stay even though the room position changes to the recall point.
_________________
Taziar Medakan @ WoTMUD
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Fri Aug 18, 2017 8:23 pm   
 
Is it possible to have it send a click to CMUD as a whole and not just to a specific child window?
_________________
Discord: Shalimarwildcat
Reply with quote
Medakan
Novice


Joined: 15 Dec 2015
Posts: 41
Location: Seattle

PostPosted: Thu Oct 05, 2017 9:17 pm   
 
Any gurus still around that have experience using VBscript in zMUD? I am still interested in trying to figure this out.

I found in one of the manuals:

Quote:
In Visual Basic, you would do something like this:

dim cc as Object
dim ss as Object
dim o as Object

Set cc = CreateObject( "Zmud.Application")
Set ss = cc.CurrentSession
N = ss.NumAliases
for I = 0 to N-1
Set o = ss.AliasNum(I)
Call lstAliases.AddItem(o.Name)
next

Set cc = Nothing

In zMUD, you would do something like this:

#VAR cc %comcreate("Zmud.Application")
#VAR ss @cc.CurrentSession
#VAR N @ss.NumAliases
#LOOP 0,@N-1 {#ECHO @ss.AliasNum(%i).Name}
#VAR cc ""
_________________
Taziar Medakan @ WoTMUD
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net