special_input_device 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/ext/special_input_device/color.c +25 -6
  3. data/ext/special_input_device/color.h +5 -1
  4. data/ext/special_input_device/extconf.rb +2 -2
  5. data/ext/special_input_device/image.c +728 -0
  6. data/ext/special_input_device/image.h +8 -0
  7. data/ext/special_input_device/{interception_connector.c → interception.c} +7 -3
  8. data/ext/special_input_device/{interception_connector.h → interception.h} +0 -0
  9. data/ext/special_input_device/keyboard.c +4 -4
  10. data/ext/special_input_device/mouse.c +26 -28
  11. data/ext/special_input_device/ruby_macro.h +11 -3
  12. data/ext/special_input_device/screen.c +54 -164
  13. data/ext/special_input_device/special_input_device.c +2 -2
  14. data/ext/special_input_device/special_input_device.h +2 -1
  15. data/ext/special_input_device/win32error.c +0 -2
  16. data/ext/special_input_device/window.c +82 -105
  17. data/lib/special_input_device/color.rb +2 -3
  18. data/lib/special_input_device/image.rb +2 -61
  19. data/lib/special_input_device/point.rb +0 -1
  20. data/lib/special_input_device/special_input_device.rb +0 -1
  21. metadata +7 -15
  22. data/lib/special_input_device/image/bmp.rb +0 -89
  23. data/lib/special_input_device/image/error/damaged_image_error.rb +0 -4
  24. data/lib/special_input_device/image/error/image_error.rb +0 -3
  25. data/lib/special_input_device/image/error/unsupported_image_format_error.rb +0 -4
  26. data/lib/special_input_device/table_2d.rb +0 -157
  27. data/stab/keyboard.rb +0 -35
  28. data/stab/mouse.rb +0 -189
  29. data/stab/screen.rb +0 -56
  30. data/stab/win32_error.rb +0 -20
  31. data/stab/window.rb +0 -398
@@ -58,9 +58,14 @@ inline static LPARAM createMouseMessageLParam(SID_WINDOW_DATA *cData) {
58
58
 
59
59
  static VALUE specialInputDevice_window;
60
60
 
61
- static VALUE ruby___window_new(HWND cHandleCode) {
62
- VALUE arguments = ULL2NUM((ULONGLONG) cHandleCode);
63
- return rb_class_new_instance(1, &arguments, specialInputDevice_window);
61
+ static VALUE ruby___window_new(HWND cHWND) {
62
+ VALUE newWindowArguments[1];
63
+ newWindowArguments[0] = ULL2NUM((ULONGLONG) cHWND);
64
+ return rb_class_new_instance(1, newWindowArguments, specialInputDevice_window);
65
+ }
66
+
67
+ inline static HWND ruby___window_get_handle_code(VALUE window) {
68
+ return (HWND) NUM2ULL(rb_iv_get(window, "@handle_code"));
64
69
  }
65
70
 
66
71
  /*
@@ -76,7 +81,7 @@ static VALUE ruby__desktop(VALUE self) {
76
81
  typedef struct {
77
82
  VALUE windowName;
78
83
  VALUE className;
79
- HWND cHandleCode;
84
+ HWND hWND;
80
85
  } SID_WINDOW_FIND_PARAMETER;
81
86
 
82
87
  static BOOLEAN callback_find_helper(VALUE pattern, LPTSTR cString) {
@@ -94,20 +99,20 @@ static BOOLEAN callback_find_helper(VALUE pattern, LPTSTR cString) {
94
99
  return FALSE;
95
100
  }
96
101
 
97
- static BOOL callback_find(HWND cHandleCode, LPARAM cArguments) {
102
+ static BOOL callback_find(HWND cHWND, LPARAM cArguments) {
98
103
  SID_WINDOW_FIND_PARAMETER *cCallbackArguments = (SID_WINDOW_FIND_PARAMETER *) cArguments;
99
104
  TCHAR cClassName[MAXIMUM_WINDOW_NAME_LENGTH * sizeof(TCHAR)];
100
- INT cWindowNameLength = GetWindowTextLength(cHandleCode) + 1;
105
+ INT cWindowNameLength = GetWindowTextLength(cHWND) + 1;
101
106
  LPTSTR cWindowName = (LPTSTR) VirtualAlloc((LPVOID) NULL,
102
107
  (SIZE_T) (cWindowNameLength) * sizeof(TCHAR),
103
108
  MEM_COMMIT, PAGE_READWRITE);
104
- GetClassName(cHandleCode, cClassName, MAXIMUM_WINDOW_NAME_LENGTH);
109
+ GetClassName(cHWND, cClassName, MAXIMUM_WINDOW_NAME_LENGTH);
105
110
  if (callback_find_helper(cCallbackArguments->className, cClassName))
106
111
  return TRUE;
107
- GetWindowText(cHandleCode, cWindowName, cWindowNameLength);
112
+ GetWindowText(cHWND, cWindowName, cWindowNameLength);
108
113
  if (callback_find_helper(cCallbackArguments->windowName, cWindowName))
109
114
  return TRUE;
110
- cCallbackArguments->cHandleCode = cHandleCode;
115
+ cCallbackArguments->hWND = cHWND;
111
116
  SetLastError(0);
112
117
  return FALSE;
113
118
  }
@@ -120,13 +125,13 @@ static BOOL callback_find(HWND cHandleCode, LPARAM cArguments) {
120
125
  * matches.
121
126
  * @param [NilClass, Regex, String] window_name the title of window.
122
127
  * @param [NilClass, Regex, String] class_name the name class or class atom in windows.
123
- * @return [SpecialInputDevice::Window, NilClass]
128
+ * @return [NilClass, SpecialInputDevice::Window]
124
129
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms633497.aspx Windows Dev Center - EnumWindows function
125
130
  */
126
131
  static VALUE ruby__find(VARIABLE_ARGUMENTS_C) {
127
132
  VALUE windowName;
128
133
  VALUE className;
129
- HWND cHandleCode;
134
+ HWND cHWND;
130
135
  SID_WINDOW_FIND_PARAMETER cCallbackArguments;
131
136
  SCAN_ARGUMENTS("02", &windowName, &className);
132
137
  if (windowName != Qnil && !RTEST(RUBY_OBJECT_IS_A_qs(windowName, rb_cRegexp)) &&
@@ -137,12 +142,12 @@ static VALUE ruby__find(VARIABLE_ARGUMENTS_C) {
137
142
  RAISE_TYPE_ERROR(className, "nil, Regexp or String");
138
143
  cCallbackArguments.className = className;
139
144
  cCallbackArguments.windowName = windowName;
140
- cCallbackArguments.cHandleCode = 0;
145
+ cCallbackArguments.hWND = 0;
141
146
  EnumWindows(callback_find, (LPARAM) &cCallbackArguments);
142
- cHandleCode = cCallbackArguments.cHandleCode;
147
+ cHWND = cCallbackArguments.hWND;
143
148
  if (GetLastError())
144
- RAISE_WIN32_ERROR;
145
- return cHandleCode ? ruby___window_new(cHandleCode) : Qnil;
149
+ RAISE_WIN32_ERROR();
150
+ return cHWND ? ruby___window_new(cHWND) : Qnil;
146
151
  }
147
152
 
148
153
  /*
@@ -153,40 +158,35 @@ static VALUE ruby__foreground(VALUE self) {
153
158
  return ruby___window_new(GetForegroundWindow());
154
159
  }
155
160
 
156
- inline static HWND ruby___window_get_handle_code(VALUE window) {
157
- return (HWND) NUM2ULL(rb_iv_get(window, "@handle_code"));
161
+ static VALUE ruby__alloc(VALUE self) {
162
+ return NEW_SIMPLE_DATA_OBJECT(self, SID_WINDOW_DATA);
158
163
  }
159
164
 
160
165
  static VALUE ruby_window_name_EQ(VALUE self, VALUE value) {
161
- HWND cHandleCode = ruby___window_get_handle_code(self);
166
+ HWND cHWND = ruby___window_get_handle_code(self);
162
167
  LPCTSTR cWindowName = RUBY_VALUE_TO_LPCTSTR(value);
163
- SetWindowText(cHandleCode, cWindowName);
168
+ SetWindowText(cHWND, cWindowName);
164
169
  return rb_iv_set(self, "@window_name", value);
165
170
  }
166
171
 
167
- static VALUE ruby__alloc(VALUE self) {
168
- return NEW_SIMPLE_DATA_OBJECT(self, SID_WINDOW_DATA);
169
- }
170
-
171
172
  /*
172
173
  * @!scope class
173
174
  * @overload new(handle_code)
174
175
  * Returns a new instance of <code>Window</code>. Normally, use <code>::find</code> to get a window because it is not
175
176
  * easy to find out a handle code of the window directly.
176
177
  * @param [Integer] handle_code the handle code of the window. Handle code is an Integer for identifying windows.
177
- * @return [SpecialInputDevice::Window] a new instance of <code>Window</code>
178
178
  */
179
179
  static VALUE ruby_initialize(VALUE self, VALUE handleCode) {
180
- HWND cHandleCode = (HWND) NUM2ULL(handleCode);
180
+ HWND cHWND = (HWND) NUM2ULL(handleCode);
181
181
  TCHAR cClassName[MAXIMUM_WINDOW_NAME_LENGTH * sizeof(TCHAR)];
182
- INT cWindowNameLength = GetWindowTextLength(cHandleCode) + 1;
182
+ INT cWindowNameLength = GetWindowTextLength(cHWND) + 1;
183
183
  LPTSTR cWindowName = (LPTSTR) VirtualAlloc((LPVOID) NULL, (SIZE_T) (cWindowNameLength) * sizeof(TCHAR),
184
184
  MEM_COMMIT, PAGE_READWRITE);
185
185
  VALUE className;
186
186
  VALUE windowName;
187
- if (!GetClassName(cHandleCode, cClassName, MAXIMUM_WINDOW_NAME_LENGTH))
188
- RAISE_WIN32_ERROR;
189
- if (!GetWindowText(cHandleCode, cWindowName, cWindowNameLength)) {
187
+ if (!GetClassName(cHWND, cClassName, MAXIMUM_WINDOW_NAME_LENGTH))
188
+ RAISE_WIN32_ERROR();
189
+ if (!GetWindowText(cHWND, cWindowName, cWindowNameLength)) {
190
190
  DWORD cError = GetLastError();
191
191
  switch (cError) {
192
192
  case ERROR_SUCCESS:
@@ -223,15 +223,15 @@ static VALUE ruby_find_child(VARIABLE_ARGUMENTS_C) {
223
223
  LPCTSTR cWindowName;
224
224
  LPCTSTR cClassName;
225
225
  HWND cAfter;
226
- HWND cHandleCode;
226
+ HWND cHWND;
227
227
  SCAN_ARGUMENTS("03", &windowName, &className, &after);
228
228
  cWindowName = windowName == Qnil ? NULL : RUBY_VALUE_TO_LPCTSTR(windowName);
229
229
  cClassName = className == Qnil ? NULL : RUBY_VALUE_TO_LPCTSTR(className);
230
230
  cAfter = after == Qnil ? NULL : ruby___window_get_handle_code(after);
231
- cHandleCode = FindWindowEx(ruby___window_get_handle_code(self), cAfter, cClassName, cWindowName);
232
- if (!cHandleCode)
233
- RAISE_WIN32_ERROR;
234
- return ruby___window_new(cHandleCode);
231
+ cHWND = FindWindowEx(ruby___window_get_handle_code(self), cAfter, cClassName, cWindowName);
232
+ if (!cHWND)
233
+ RAISE_WIN32_ERROR();
234
+ return ruby___window_new(cHWND);
235
235
  }
236
236
 
237
237
  /*
@@ -242,11 +242,11 @@ static VALUE ruby_find_child(VARIABLE_ARGUMENTS_C) {
242
242
  */
243
243
  static VALUE ruby_parent(VARIABLE_ARGUMENTS_C) {
244
244
  VALUE includeOwner;
245
- HWND cHandleCode;
245
+ HWND cHWND;
246
246
  SCAN_ARGUMENTS("01", &includeOwner);
247
- cHandleCode = ruby___window_get_handle_code(self);
247
+ cHWND = ruby___window_get_handle_code(self);
248
248
  return ruby___window_new(
249
- includeOwner && includeOwner != Qnil ? GetAncestor(cHandleCode, GA_PARENT) : GetParent(cHandleCode));
249
+ includeOwner && includeOwner != Qnil ? GetAncestor(cHWND, GA_PARENT) : GetParent(cHWND));
250
250
  }
251
251
 
252
252
  /*
@@ -256,10 +256,10 @@ static VALUE ruby_parent(VARIABLE_ARGUMENTS_C) {
256
256
  */
257
257
  static VALUE ruby_root(VARIABLE_ARGUMENTS_C) {
258
258
  VALUE includeOwner;
259
- HWND cHandleCode;
259
+ HWND cHWND;
260
260
  SCAN_ARGUMENTS("01", &includeOwner);
261
- cHandleCode = ruby___window_get_handle_code(self);
262
- return ruby___window_new(GetAncestor(cHandleCode, includeOwner && includeOwner != Qnil ? GA_ROOT : GA_ROOTOWNER));
261
+ cHWND = ruby___window_get_handle_code(self);
262
+ return ruby___window_new(GetAncestor(cHWND, includeOwner && includeOwner != Qnil ? GA_ROOT : GA_ROOTOWNER));
263
263
  }
264
264
 
265
265
  //</editor-fold>
@@ -275,11 +275,11 @@ static VALUE ruby_root(VARIABLE_ARGUMENTS_C) {
275
275
  */
276
276
  static VALUE ruby_client_rectangle(VALUE self) {
277
277
  RECT cClientRectangle;
278
- HWND cHandleCode = ruby___window_get_handle_code(self);
279
- if (!GetClientRect(cHandleCode, &cClientRectangle))
280
- RAISE_WIN32_ERROR;
281
- if (!ClientToScreen(cHandleCode, (LPPOINT) &cClientRectangle))
282
- RAISE_WIN32_ERROR;
278
+ HWND cHWND = ruby___window_get_handle_code(self);
279
+ if (!GetClientRect(cHWND, &cClientRectangle))
280
+ RAISE_WIN32_ERROR();
281
+ if (!ClientToScreen(cHWND, (LPPOINT) &cClientRectangle))
282
+ RAISE_WIN32_ERROR();
283
283
  cClientRectangle.right += cClientRectangle.left;
284
284
  cClientRectangle.bottom += cClientRectangle.top;
285
285
  return ruby___rectangle_new_from_rect(&cClientRectangle);
@@ -294,7 +294,7 @@ static VALUE ruby_client_rectangle(VALUE self) {
294
294
  static VALUE ruby_window_rectangle(VALUE self) {
295
295
  RECT cWindowRectangle;
296
296
  if (!GetWindowRect(ruby___window_get_handle_code(self), &cWindowRectangle))
297
- RAISE_WIN32_ERROR;
297
+ RAISE_WIN32_ERROR();
298
298
  return ruby___rectangle_new_from_rect(&cWindowRectangle);
299
299
  }
300
300
 
@@ -309,7 +309,7 @@ static VALUE ruby_window_rectangle(VALUE self) {
309
309
  */
310
310
  static VALUE ruby_bring_to_foreground(VALUE self) {
311
311
  if (!SetForegroundWindow(ruby___window_get_handle_code(self)))
312
- RAISE_WIN32_ERROR;
312
+ RAISE_WIN32_ERROR();
313
313
  return self;
314
314
  }
315
315
 
@@ -320,7 +320,7 @@ static VALUE ruby_bring_to_foreground(VALUE self) {
320
320
  */
321
321
  static VALUE ruby_close(VALUE self) {
322
322
  if (!PostMessage(ruby___window_get_handle_code(self), WM_CLOSE, 0, 0))
323
- RAISE_WIN32_ERROR;
323
+ RAISE_WIN32_ERROR();
324
324
  return self;
325
325
  }
326
326
 
@@ -331,7 +331,7 @@ static VALUE ruby_close(VALUE self) {
331
331
  */
332
332
  static VALUE ruby_hide(VALUE self) {
333
333
  if (!ShowWindow(ruby___window_get_handle_code(self), SW_HIDE))
334
- RAISE_WIN32_ERROR;
334
+ RAISE_WIN32_ERROR();
335
335
  return self;
336
336
  }
337
337
 
@@ -342,7 +342,7 @@ static VALUE ruby_hide(VALUE self) {
342
342
  */
343
343
  static VALUE ruby_maximize(VALUE self) {
344
344
  if (!ShowWindow(ruby___window_get_handle_code(self), SW_SHOWMAXIMIZED))
345
- RAISE_WIN32_ERROR;
345
+ RAISE_WIN32_ERROR();
346
346
  return self;
347
347
  }
348
348
 
@@ -353,7 +353,7 @@ static VALUE ruby_maximize(VALUE self) {
353
353
  */
354
354
  static VALUE ruby_minimize(VALUE self) {
355
355
  if (!ShowWindow(ruby___window_get_handle_code(self), SW_SHOWMINIMIZED))
356
- RAISE_WIN32_ERROR;
356
+ RAISE_WIN32_ERROR();
357
357
  return self;
358
358
  }
359
359
 
@@ -370,7 +370,7 @@ static VALUE ruby_move_to(VALUE self, VALUE x, VALUE y) {
370
370
  INT cY = NUM2INT(y);
371
371
  if (!SetWindowPos(ruby___window_get_handle_code(self), NULL, cX, cY, 0, 0,
372
372
  SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER))
373
- RAISE_WIN32_ERROR;
373
+ RAISE_WIN32_ERROR();
374
374
  return self;
375
375
  }
376
376
 
@@ -387,7 +387,7 @@ static VALUE ruby_resize_to(VALUE self, VALUE width, VALUE height) {
387
387
  INT cHeight = NUM2INT(height);
388
388
  if (!SetWindowPos(ruby___window_get_handle_code(self), NULL, 0, 0, cWidth, cHeight,
389
389
  SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER))
390
- RAISE_WIN32_ERROR;
390
+ RAISE_WIN32_ERROR();
391
391
  return self;
392
392
  }
393
393
 
@@ -398,7 +398,7 @@ static VALUE ruby_resize_to(VALUE self, VALUE width, VALUE height) {
398
398
  */
399
399
  static VALUE ruby_restore(VALUE self) {
400
400
  if (!ShowWindow(ruby___window_get_handle_code(self), SW_SHOWNORMAL))
401
- RAISE_WIN32_ERROR;
401
+ RAISE_WIN32_ERROR();
402
402
  return self;
403
403
  }
404
404
 
@@ -415,9 +415,10 @@ static VALUE ruby_restore(VALUE self) {
415
415
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/dd144909.aspx Windows Dev Center - GetPixel function
416
416
  */
417
417
  static VALUE ruby_color_at(VALUE self, VALUE x, VALUE y) {
418
- INT cX = NUM2INT(x);
419
- INT cY = NUM2INT(y);
420
- COLORREF cColor = GetPixel(GetDC(ruby___window_get_handle_code(self)), cX, cY);
418
+ INT cX = NUM2INT(x);
419
+ INT cY = NUM2INT(y);
420
+ HDC cWindowDC = GetDC(ruby___window_get_handle_code(self));
421
+ COLORREF cColor = GetPixel(cWindowDC, cX, cY);
421
422
  return ruby___color_new_from_color_ref(cColor);
422
423
  }
423
424
 
@@ -437,12 +438,11 @@ static VALUE ruby_color_at(VALUE self, VALUE x, VALUE y) {
437
438
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646280.aspx Windows Dev Center - WM_KEYDOWN message
438
439
  */
439
440
  static VALUE ruby_key_hold(VALUE self, VALUE keyCode) {
440
- SID_WINDOW_DATA *cData;
441
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
441
442
  HWND cHWnd = ruby___window_get_handle_code(self);
442
443
  WPARAM cWParam = NUM2USHORT(keyCode);
443
444
  LPARAM cLParam = 1 | (WORD) MapVirtualKeyA(cWParam, MAPVK_VK_TO_VSC) << 16;
444
445
  PostMessage(cHWnd, WM_KEYDOWN, cWParam, cLParam);
445
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
446
446
  switch (cWParam) {
447
447
  case VK_CONTROL:
448
448
  cData->flats |= FLAT_CONTROL;
@@ -487,14 +487,13 @@ static VALUE ruby_key_hold(VALUE self, VALUE keyCode) {
487
487
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646281.aspx Windows Dev Center - WM_KEYUP message
488
488
  */
489
489
  static VALUE ruby_key_release(VALUE self, VALUE keyCode) {
490
- SID_WINDOW_DATA *cData;
490
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
491
491
  HWND cHWnd = ruby___window_get_handle_code(self);
492
492
  WPARAM cWParam = NUM2USHORT(keyCode);
493
493
  LPARAM cLParam = 1;
494
494
  cLParam |= (WORD) MapVirtualKeyA(cWParam, MAPVK_VK_TO_VSC) << 16;
495
495
  cLParam |= 0xA0000000;
496
496
  PostMessage(cHWnd, WM_KEYUP, cWParam, cLParam);
497
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
498
497
  switch (cWParam) {
499
498
  case VK_CONTROL:
500
499
  cData->flats &= ~FLAT_CONTROL;
@@ -540,14 +539,13 @@ static VALUE ruby_key_release(VALUE self, VALUE keyCode) {
540
539
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646281.aspx Windows Dev Center - WM_KEYUP message
541
540
  */
542
541
  static VALUE ruby_key_press(VALUE self, VALUE keyCode) {
543
- SID_WINDOW_DATA *cData;
542
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
544
543
  HWND cHWnd = ruby___window_get_handle_code(self);
545
544
  WPARAM cWParam = NUM2USHORT(keyCode);
546
545
  LPARAM cLParam = 1 | (WORD) MapVirtualKeyA(cWParam, MAPVK_VK_TO_VSC) << 16;
547
546
  PostMessage(cHWnd, WM_KEYDOWN, cWParam, cLParam);
548
547
  cLParam |= 0xA0000000;
549
548
  PostMessage(cHWnd, WM_KEYUP, cWParam, cLParam);
550
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
551
549
  switch (cWParam) {
552
550
  case VK_CONTROL:
553
551
  cData->flats &= ~FLAT_CONTROL;
@@ -598,9 +596,8 @@ static VALUE ruby_key_press(VALUE self, VALUE keyCode) {
598
596
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645616.aspx Windows Dev Center - WM_MOUSEMOVE message
599
597
  */
600
598
  static VALUE ruby_mouse_move_relatively(VALUE self, VALUE x, VALUE y) {
601
- SID_WINDOW_DATA *cData;
599
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
602
600
  HWND cHWnd = ruby___window_get_handle_code(self);
603
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
604
601
  cData->x += NUM2SHORT(x);
605
602
  cData->y += NUM2SHORT(y);
606
603
  PostMessage(cHWnd, WM_MOUSEMOVE, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
@@ -618,9 +615,8 @@ static VALUE ruby_mouse_move_relatively(VALUE self, VALUE x, VALUE y) {
618
615
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645616.aspx Windows Dev Center - WM_MOUSEMOVE message
619
616
  */
620
617
  static VALUE ruby_mouse_move_to(VALUE self, VALUE x, VALUE y) {
621
- SID_WINDOW_DATA *cData;
618
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
622
619
  HWND cHWnd = ruby___window_get_handle_code(self);
623
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
624
620
  cData->x = NUM2SHORT(x);
625
621
  cData->y = NUM2SHORT(y);
626
622
  PostMessage(cHWnd, WM_MOUSEMOVE, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
@@ -641,10 +637,9 @@ static VALUE ruby_mouse_move_to(VALUE self, VALUE x, VALUE y) {
641
637
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645608.aspx Windows Dev Center - WM_LBUTTONUP message
642
638
  */
643
639
  static VALUE ruby_mouse_left_click(VALUE self) {
644
- SID_WINDOW_DATA *cData;
640
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
645
641
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
646
642
  HWND cHWnd = ruby___window_get_handle_code(self);
647
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
648
643
  cData->flats |= FLAT_MOUSE_LEFT;
649
644
  PostMessage(cHWnd, WM_LBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
650
645
  if (cData->leftClick && cData->leftClick + GetDoubleClickTime() <= cCurrentTime)
@@ -664,10 +659,9 @@ static VALUE ruby_mouse_left_click(VALUE self) {
664
659
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645607.aspx Windows Dev Center - WM_LBUTTONDOWN message
665
660
  */
666
661
  static VALUE ruby_mouse_left_down(VALUE self) {
667
- SID_WINDOW_DATA *cData;
662
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
668
663
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
669
664
  HWND cHWnd = ruby___window_get_handle_code(self);
670
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
671
665
  cData->flats |= FLAT_MOUSE_LEFT;
672
666
  PostMessage(cHWnd, WM_LBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
673
667
  if (cData->leftClick && cData->leftClick + GetDoubleClickTime() <= cCurrentTime)
@@ -684,9 +678,8 @@ static VALUE ruby_mouse_left_down(VALUE self) {
684
678
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645608.aspx Windows Dev Center - WM_LBUTTONUP message
685
679
  */
686
680
  static VALUE ruby_mouse_left_up(VALUE self) {
687
- SID_WINDOW_DATA *cData;
681
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
688
682
  HWND cHWnd = ruby___window_get_handle_code(self);
689
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
690
683
  cData->flats &= ~FLAT_MOUSE_LEFT;
691
684
  PostMessage(cHWnd, WM_LBUTTONUP, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
692
685
  return self;
@@ -706,10 +699,9 @@ static VALUE ruby_mouse_left_up(VALUE self) {
706
699
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646243.aspx Windows Dev Center - WM_RBUTTONUP function
707
700
  */
708
701
  static VALUE ruby_mouse_right_click(VALUE self) {
709
- SID_WINDOW_DATA *cData;
702
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
710
703
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
711
704
  HWND cHWnd = ruby___window_get_handle_code(self);
712
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
713
705
  cData->flats |= FLAT_MOUSE_RIGHT;
714
706
  PostMessage(cHWnd, WM_RBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
715
707
  if (cData->rightClick && cData->rightClick + GetDoubleClickTime() <= cCurrentTime)
@@ -729,10 +721,9 @@ static VALUE ruby_mouse_right_click(VALUE self) {
729
721
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646242.aspx Windows Dev Center - WM_RBUTTONDOWN function
730
722
  */
731
723
  static VALUE ruby_mouse_right_down(VALUE self) {
732
- SID_WINDOW_DATA *cData;
724
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
733
725
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
734
726
  HWND cHWnd = ruby___window_get_handle_code(self);
735
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
736
727
  cData->flats |= FLAT_MOUSE_RIGHT;
737
728
  PostMessage(cHWnd, WM_RBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
738
729
  if (cData->rightClick && cData->rightClick + GetDoubleClickTime() <= cCurrentTime)
@@ -749,9 +740,8 @@ static VALUE ruby_mouse_right_down(VALUE self) {
749
740
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646243.aspx Windows Dev Center - WM_RBUTTONUP function
750
741
  */
751
742
  static VALUE ruby_mouse_right_up(VALUE self) {
752
- SID_WINDOW_DATA *cData;
743
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
753
744
  HWND cHWnd = ruby___window_get_handle_code(self);
754
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
755
745
  cData->flats &= ~FLAT_MOUSE_RIGHT;
756
746
  PostMessage(cHWnd, WM_RBUTTONUP, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
757
747
  return self;
@@ -771,10 +761,9 @@ static VALUE ruby_mouse_right_up(VALUE self) {
771
761
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645611.aspx Windows Dev Center - WM_MBUTTONUP function
772
762
  */
773
763
  static VALUE ruby_mouse_middle_click(VALUE self) {
774
- SID_WINDOW_DATA *cData;
764
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
775
765
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
776
766
  HWND cHWnd = ruby___window_get_handle_code(self);
777
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
778
767
  cData->flats |= FLAT_MOUSE_MIDDLE;
779
768
  PostMessage(cHWnd, WM_MBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
780
769
  if (cData->middleClick && cData->middleClick + GetDoubleClickTime() <= cCurrentTime)
@@ -794,10 +783,9 @@ static VALUE ruby_mouse_middle_click(VALUE self) {
794
783
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645610.aspx Windows Dev Center - WM_MBUTTONDOWN function
795
784
  */
796
785
  static VALUE ruby_mouse_middle_down(VALUE self) {
797
- SID_WINDOW_DATA *cData;
786
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
798
787
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
799
788
  HWND cHWnd = ruby___window_get_handle_code(self);
800
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
801
789
  cData->flats |= FLAT_MOUSE_MIDDLE;
802
790
  PostMessage(cHWnd, WM_MBUTTONDOWN, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
803
791
  if (cData->middleClick && cData->middleClick + GetDoubleClickTime() <= cCurrentTime)
@@ -814,9 +802,8 @@ static VALUE ruby_mouse_middle_down(VALUE self) {
814
802
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645611.aspx Windows Dev Center - WM_MBUTTONUP function
815
803
  */
816
804
  static VALUE ruby_mouse_middle_up(VALUE self) {
817
- SID_WINDOW_DATA *cData;
805
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
818
806
  HWND cHWnd = ruby___window_get_handle_code(self);
819
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
820
807
  cData->flats &= ~FLAT_MOUSE_MIDDLE;
821
808
  PostMessage(cHWnd, WM_MBUTTONUP, createMouseMessageWParam(cData), createMouseMessageLParam(cData));
822
809
  return self;
@@ -836,10 +823,9 @@ static VALUE ruby_mouse_middle_up(VALUE self) {
836
823
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646246.aspx Windows Dev Center - WM_XBUTTONUP function
837
824
  */
838
825
  static VALUE ruby_mouse_x1_click(VALUE self) {
839
- SID_WINDOW_DATA *cData;
826
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
840
827
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
841
828
  HWND cHWnd = ruby___window_get_handle_code(self);
842
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
843
829
  cData->flats |= FLAT_MOUSE_X1;
844
830
  PostMessage(cHWnd, WM_XBUTTONDOWN, createMouseMessageWParam(cData) | XBUTTON1 << 16,
845
831
  createMouseMessageLParam(cData));
@@ -861,10 +847,9 @@ static VALUE ruby_mouse_x1_click(VALUE self) {
861
847
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646245.aspx Windows Dev Center - WM_XBUTTONDOWN function
862
848
  */
863
849
  static VALUE ruby_mouse_x1_down(VALUE self) {
864
- SID_WINDOW_DATA *cData;
850
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
865
851
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
866
852
  HWND cHWnd = ruby___window_get_handle_code(self);
867
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
868
853
  cData->flats |= FLAT_MOUSE_X1;
869
854
  PostMessage(cHWnd, WM_XBUTTONDOWN, createMouseMessageWParam(cData) | XBUTTON1 << 16,
870
855
  createMouseMessageLParam(cData));
@@ -883,9 +868,8 @@ static VALUE ruby_mouse_x1_down(VALUE self) {
883
868
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646246.aspx Windows Dev Center - WM_XBUTTONUP function
884
869
  */
885
870
  static VALUE ruby_mouse_x1_up(VALUE self) {
886
- SID_WINDOW_DATA *cData;
871
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
887
872
  HWND cHWnd = ruby___window_get_handle_code(self);
888
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
889
873
  cData->flats &= ~FLAT_MOUSE_X1;
890
874
  PostMessage(cHWnd, WM_XBUTTONUP, createMouseMessageWParam(cData) | XBUTTON1 << 16, createMouseMessageLParam(cData));
891
875
  return self;
@@ -901,10 +885,9 @@ static VALUE ruby_mouse_x1_up(VALUE self) {
901
885
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646246.aspx Windows Dev Center - WM_XBUTTONUP function
902
886
  */
903
887
  static VALUE ruby_mouse_x2_click(VALUE self) {
904
- SID_WINDOW_DATA *cData;
888
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
905
889
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
906
890
  HWND cHWnd = ruby___window_get_handle_code(self);
907
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
908
891
  cData->flats |= FLAT_MOUSE_X2;
909
892
  PostMessage(cHWnd, WM_XBUTTONDOWN, createMouseMessageWParam(cData) | XBUTTON2 << 16,
910
893
  createMouseMessageLParam(cData));
@@ -926,10 +909,9 @@ static VALUE ruby_mouse_x2_click(VALUE self) {
926
909
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646245.aspx Windows Dev Center - WM_XBUTTONDOWN function
927
910
  */
928
911
  static VALUE ruby_mouse_x2_down(VALUE self) {
929
- SID_WINDOW_DATA *cData;
912
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
930
913
  ULONGLONG cCurrentTime = getSystemTimeIdentifier();
931
914
  HWND cHWnd = ruby___window_get_handle_code(self);
932
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
933
915
  cData->flats |= FLAT_MOUSE_X2;
934
916
  PostMessage(cHWnd, WM_XBUTTONDOWN, createMouseMessageWParam(cData) | XBUTTON2 << 16,
935
917
  createMouseMessageLParam(cData));
@@ -948,9 +930,8 @@ static VALUE ruby_mouse_x2_down(VALUE self) {
948
930
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646246.aspx Windows Dev Center - WM_XBUTTONUP function
949
931
  */
950
932
  static VALUE ruby_mouse_x2_up(VALUE self) {
951
- SID_WINDOW_DATA *cData;
933
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
952
934
  HWND cHWnd = ruby___window_get_handle_code(self);
953
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
954
935
  cData->flats &= ~FLAT_MOUSE_X2;
955
936
  PostMessage(cHWnd, WM_XBUTTONUP, createMouseMessageWParam(cData) | XBUTTON2 << 16, createMouseMessageLParam(cData));
956
937
  return self;
@@ -968,9 +949,8 @@ static VALUE ruby_mouse_x2_up(VALUE self) {
968
949
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645617.aspx Windows Dev Center - WM_MOUSEWHEEL function
969
950
  */
970
951
  static VALUE ruby_mouse_scroll_wheel_backward(VALUE self) {
971
- SID_WINDOW_DATA *cData;
952
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
972
953
  HWND cHWnd = ruby___window_get_handle_code(self);
973
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
974
954
  PostMessage(cHWnd, WM_MOUSEWHEEL, createMouseMessageWParam(cData) | -WHEEL_DELTA << 16,
975
955
  createMouseMessageLParam(cData));
976
956
  return self;
@@ -984,9 +964,8 @@ static VALUE ruby_mouse_scroll_wheel_backward(VALUE self) {
984
964
  * @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms645617.aspx Windows Dev Center - WM_MOUSEWHEEL function
985
965
  */
986
966
  static VALUE ruby_mouse_scroll_wheel_forward(VALUE self) {
987
- SID_WINDOW_DATA *cData;
967
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
988
968
  HWND cHWnd = ruby___window_get_handle_code(self);
989
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
990
969
  PostMessage(cHWnd, WM_MOUSEWHEEL, createMouseMessageWParam(cData) | WHEEL_DELTA << 16,
991
970
  createMouseMessageLParam(cData));
992
971
  return self;
@@ -1001,9 +980,8 @@ static VALUE ruby_mouse_scroll_wheel_forward(VALUE self) {
1001
980
  */
1002
981
  static VALUE ruby_mouse_scroll_wheel_to_left(VALUE self) {
1003
982
  #ifdef MOUSEEVENTF_HWHEEL
1004
- SID_WINDOW_DATA *cData;
983
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
1005
984
  HWND cHWnd = getHandleCode(self);
1006
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
1007
985
  PostMessage(cHWnd, WM_MOUSEHWHEEL, createMouseMessageWParam(cData) | -WHEEL_DELTA << 16, createMouseMessageLParam(cData));
1008
986
  return self;
1009
987
  #else
@@ -1020,9 +998,8 @@ static VALUE ruby_mouse_scroll_wheel_to_left(VALUE self) {
1020
998
  */
1021
999
  static VALUE ruby_mouse_scroll_wheel_to_right(VALUE self) {
1022
1000
  #ifdef MOUSEEVENTF_HWHEEL
1023
- SID_WINDOW_DATA *cData;
1001
+ SID_WINDOW_DATA *cData = GET_SELF_DATA_OBJECT();
1024
1002
  HWND cHWnd = getHandleCode(self);
1025
- Data_Get_Struct(self, SID_WINDOW_DATA, cData);
1026
1003
  PostMessage(cHWnd, WM_MOUSEHWHEEL, createMouseMessageWParam(cData) | WHEEL_DELTA << 16, createMouseMessageLParam(cData));
1027
1004
  return self;
1028
1005
  #else
@@ -40,7 +40,6 @@ class SpecialInputDevice::Color
40
40
  # @param [Fixnum] green the level of green
41
41
  # @param [Fixnum] blue the level of blue
42
42
  # @param [Fixnum] alpha the level of alpha
43
- # @return [SpecialInputDevice::Color] a new instance of <code>Color</code>
44
43
  def initialize(red, green, blue, alpha = 255)
45
44
  self.red = red
46
45
  self.green = green
@@ -145,12 +144,12 @@ class SpecialInputDevice::Color
145
144
 
146
145
  # @!visibility private
147
146
  def inspect
148
- '#%02x%02x%02x%02X' % [alpha, red, green, blue]
147
+ '#%02X%02X%02X%02X' % [alpha, red, green, blue]
149
148
  end
150
149
 
151
150
  # @!visibility private
152
151
  def to_s
153
- '#%02x%02x%02x%02X' % [alpha, red, green, blue]
152
+ '#%02X%02X%02X%02X' % [alpha, red, green, blue]
154
153
  end
155
154
 
156
155
  end