Page 1 of 2
Controller Xbox360
Posted: Fri Jul 05, 2013 11:55 am
by Almeida
Hi,
I would like programming xbox controller with code like AHK (AutohotKey)
but i'm not used to code with Ruby. Can u help me to assign Button A to F1 function ?
If you have any documentation about programming controller, i will appreciate it !
Many thx !
Re: Controller Xbox360
Posted: Fri Jul 05, 2013 4:57 pm
by MyCo
Here are two modules that send key status messages to the current active window. It uses win32Api, which is a little bit hard to read. Check the FS user guide (page 198-201)
Re: Controller Xbox360
Posted: Fri Jul 05, 2013 6:55 pm
by Almeida
working great. Thanks.
Re: Controller Xbox360
Posted: Fri Jul 05, 2013 7:00 pm
by MyCo
0x70 is just hexadecimal, you can use the windows calculator to convert it into decimal, or just use an online converter like this:
http://www.rapidtables.com/convert/numb ... ecimal.htmOr you can use FS "hex to dec" primitive
Edit: Looks like you found your answer already

Re: Controller Xbox360
Posted: Fri Jul 05, 2013 7:10 pm
by Almeida
yes i found it finally but can help other ! thx
Re: Controller Xbox360
Posted: Fri Jul 05, 2013 9:47 pm
by Almeida
i have some code in AHK which move window at some position X,Y on the screen when i push Right on my keyboard
Right::
WinGetActiveTitle, Title1
WinMove, %Title1%,, 938, 10
then do you think it' s possible to do the same with Flowstone?
Cause have already link Right of 360xbox to send "Right" but its not read by AHK when both are open ( AHK & Flowstone)
Re: Controller Xbox360
Posted: Fri Jul 05, 2013 9:56 pm
by MyCo
It can be done with 2 other WinApi functions (GetActiveWindow and SetWindowPos). I'll have a look at this tomorrow, or maybe someone else is faster than me

Re: Controller Xbox360
Posted: Sat Jul 06, 2013 1:02 am
by digitalwhitebyte
this is an example of code to define the size and position of the window.
Code: Select all
require 'Win32API'
def event i
# winapi GetSystemMetrics
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx
# get current windows size
screen_width = Win32API.new("User32.dll","GetSystemMetrics",["L"],"L").call(0)
screen_height = Win32API.new("User32.dll","GetSystemMetrics",["L"],"L").call(1)
# winapi FindWindow
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
findWindow = Win32API.new('user32', 'FindWindow', ['P','P'], 'L')
# define your windows name here
windows_name = 'FlowStone - [Schematic1*]'
hWnd = findWindow.call(0, windows_name)
# winapi SetWindowPos
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
setWindowPos = Win32API.new("user32.dll", "SetWindowPos", ['I','I','I','I','I','I','I'], 'I')
# Struct SetWindowPos
# set windows size when moved (this is one of many options)
cx = 1024
cy = 768
posX = (screen_width/2)-(cx/2)
posY = (screen_height/2)-(cy/2)
# see uFlag option
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
uFlags = 16384
#Call SetWindowPos
return_SetWindowPos = setWindowPos.call(hWnd, -2, posX, posY, cx, cy, uFlags)
watch 'hWnd', hWnd
watch 'returned value from SetWindowPos call (If the function succeeds, the return value is nonzero.)', return_SetWindowPos
end
Re: Controller Xbox360
Posted: Tue Jul 23, 2013 4:42 pm
by Almeida
This code works fine when i use it in Flowstone but i would like to do this in the current window. I saw someone talk about enumwindows function (
http://msdn.microsoft.com/en-us/library ... 85%29.aspx). I didn't find the way to implement it. Can u help me to do this?
Re: Controller Xbox360
Posted: Tue Jul 23, 2013 5:12 pm
by digitalwhitebyte
# define your windows name here
windows_name = 'FlowStone - [Schematic1*]'
in my code you have modify the red contents of this variable to match your app name windows
P.S.
EnumWindows work in conbination of EnumWindowsProc, the current Win32API not support callback.