Ruby windows API
2021/8/27 7:06:09
本文主要是介绍Ruby windows API,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Get cursor position with Win32API
result = "0"*8 # Eight bytes (enough for two longs) getCursorXY = Win32API.new("user32","GetCursorPos",["P"],"V") getCursorXY.call(result) x, y = result.unpack("LL") # Two longs
Use Win32API to get a pointer a function
require "Win32API" def system(cmd) sys = Win32API.new("crtdll", "system", ['P'], 'L') sys.Call(cmd) end system("dir") # cmd /c not needed!
Read from keyboard
require 'Win32API' def getch @getch ||= Win32API.new('crtdll', '_getch', [], 'L') @getch.call end while (c = getch) != ?\e puts "You typed #{c.chr.inspect}" end
Working with Microsoft Windows: open a dialog box:
require 'Win32API' title = "My Application" text = "Hello, world!" Win32API.new('user32', 'MessageBox', %w{L P P L}, 'I').call(0, text, title, 0)
Open a dialog and check the result
require 'Win32API' title = "My Application" text = "Hello, world!" dialog = Win32API.new('user32', 'MessageBox', 'LPPL', 'I') result = dialog.call(0, text, title, 1) case result when 1: puts "Clicked OK" when 2: puts "Clicked Cancel" else puts "Clicked something else!" end
这篇关于Ruby windows API的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南