Followers

Wednesday, 31 May 2017

Some problems with Win32API in Ruby

Source: stackoverflow.com --- Tuesday, May 30, 2017
first i don't know english very well but i'll do my best thanks for reading! I'm trying to play with Win32API, so everything I've tried to do is just to learn! and i'm on Windows 32 bits Getting cursor's position: require 'Win32API' STD_OUTPUT_HANDLE = -11 GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', 'L', 'L') SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', ['L', 'P'], 'L') GetLastError = Win32API.new('kernel32', 'GetLastError', [], 'L') dwSize = [0, 0].pack('LL') dwCursorPosition = [0, 0].pack('LL') wAttributes = 0 srWindow = [0, 0, 0, 0].pack('LLLL') dwMaximumWindowSize = [0, 0].pack('LL') csbi = [dwSize, dwCursorPosition, wAttributes, srWindow, dwMaximumWindowSize].pack('PPLPP') p GetConsoleScreenBufferInfo.call(GetStdHandle.call(STD_OUTPUT_HANDLE), csbi) #=> 1 p GetLastError.call #=> 158 # About error #158: # ERROR_NOT_LOCKED # 158 (0x9E) # The segment is already unlocked. csbi.unpack('PPLPP') #=> ERROR: `unpack': non associated pointer (ArgumentError) Setting cursor's position: require 'Win32API' STD_OUTPUT_HANDLE = -11 GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', 'L', 'L') SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', ['L', 'P'], 'L') GetLastError = Win32API.new('kernel32', 'GetLastError', [], 'L') coords = [20, 20].pack('LL') # [x, y] p SetConsoleCursorPosition.call(GetStdHandle.call(STD_OUTPUT_HANDLE), coords) #=> 0 p GetLastError.cal ...



from Windows http://ift.tt/2sjfjXj

No comments:

Post a Comment