• Anmelden

1

Mittwoch, 11. April 2012, 00:32

Einfaches Mausskript

Hi ich suche ein simples Mausskript für den rmxp. in der script-db ist eins vorhanden, scheint aber nicht richtig zu funktionieren. das skript sollte die x und y screen koordinaten vom mauszeiger abfragen können und es sollte eine abfrage möglich sein ob geklickt wird. mehr muss das skript nicht können.
hoffe ihr könnt mir helfen, danke im vorraus.

Reborn

hat beim Stromkonzern schon Rabatt

Motto: Wer noch was vom Wochenende weis, hat es nie erlebt!

  • Nachricht senden

2

Sonntag, 15. April 2012, 12:42

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module Mouse
  GetCursorPos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  GetWindowRect = Win32API.new('user32', 'GetWindowRect', ['p', 'p'], 'i')
  ScreenToClient = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  GetClientRect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
  GetPrivateProfileStringA = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  FindWindow = Win32API.new('user32', 'FindWindow', %w(p p), 'l')
  GetAsyncKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
 
  def Mouse.pressed?(key)
    return (GetAsyncKeyState.call(key) & 0x01) == 1
  end
 
  def Mouse.x()
    return nil if Mouse.mousePos.nil?
    return Mouse.mousePos[0]
  end
 
  def Mouse.y()
    return nil if Mouse.mousePos.nil?
    return Mouse.mousePos()[1]
  end
 
  def Mouse.mousePos()
    x, y = Mouse.screenToClient(*Mouse.getPos)
    width, height = Mouse.clientSize()
    if (x.nil? || y.nil?)
      return nil
    end
    if x >= 0 && y >= 0 && x < width && y < height
      return x, y
    else
      return nil
    end
  end
 
  def Mouse.getPos()
    pos = [0, 0].pack('ll')
    if GetCursorPos.call(pos) != 0
      return pos.unpack('ll')
    else
      return nil
    end
  end
 
  def Mouse.screenToClient(x, y)
    return nil unless x && y
    pos = [x, y].pack('ll')
    if ScreenToClient.call(getHandle(), pos) != 0
      return pos.unpack('ll')
    else
      return nil
    end
  end
 
  def Mouse.clientSize()
    rect = [0, 0, 0, 0].pack('l4')
    GetClientRect.call(getHandle(), rect)
    right, bottom = rect.unpack('l4')[2..3]
    return right, bottom
  end
 
  def Mouse.getHandle()
    gameName = "\0" * 256
    GetPrivateProfileStringA.call('Game', 'Title', '', gameName, 255, ".\\Game.ini")
    gameName.delete!("\0")
    if ($DEBUG)
      result = FindWindow.call('RGSS Player', 0) 
    else
      result = FindWindow.call('RGSS Player', gameName)
    end
    return result
  end
end
Mehr als a Allgäuer ka a Mensch it wera.


Wie soll ich wissen was ich denke, bevor ich nicht höre was ich sage?


Spoiler: OpenSource-Projects
NES-Emulator - a simple NES-Emulator
ERDL - a embedded Ruby Interpreter with the abilltiy to render images with DirectX ERDL shall be 100% compatible to RPGXP-Ruby Scripts
zum Lesen den Text mit der Maus markieren

3

Sonntag, 15. April 2012, 16:13

Danke für dass du dir die Mühe gemacht hast. Könntest du mir auch noch verraten wie ich das script aufrufe, die position abspeichere ect. ?

Reborn

hat beim Stromkonzern schon Rabatt

Motto: Wer noch was vom Wochenende weis, hat es nie erlebt!

  • Nachricht senden

4

Sonntag, 15. April 2012, 20:53

Mouse.x bzw. Mouse.y geben die Koordinaten zurück, Mouse.pressed?(1) gibt zurück ob die linke Maustaste gerade gedrückt wird.
Abfragen ob gerade die Maustaste gedrückt wird, tust du dann am besten über ein Conditional Branch und fügst dort als Script Mouse.pressed?(1) ein. Die Koordinaten speicher du über ein Call Script z. B. so: $game_variables[id] = Mouse.x
Mehr als a Allgäuer ka a Mensch it wera.


Wie soll ich wissen was ich denke, bevor ich nicht höre was ich sage?


Spoiler: OpenSource-Projects
NES-Emulator - a simple NES-Emulator
ERDL - a embedded Ruby Interpreter with the abilltiy to render images with DirectX ERDL shall be 100% compatible to RPGXP-Ruby Scripts
zum Lesen den Text mit der Maus markieren

5

Mittwoch, 18. April 2012, 19:48

vielen dank :)

Ähnliche Themen

Social Bookmarks