将代码转换为Python
我现在正在学习Python,这是一种 我感兴趣的项目。我不知道脚本是用什么语言编写的(可能是 lisp 或 autohotkey?),但我想将其转换为 python。您能指出正确的方向并告诉我
- 使用什么语言吗?
- 我需要学习什么来转换它?
谢谢!
; Thois TableOpener for PokerStars v1.05
; Opens new cash game tables from the lobby every x seconds (if there are less tables opened than your predefined settings). A great tool for multi-tablers.
; Customize the variables below (between the lines)
; 'Thois' on PS for donations
; Customizable variables (between the lines)
;------------------------------------------
rowheight := 13 ;In the PokerStars lobby go to View > Text Size: For Medium & smaller:13, For smallest:12, For Larger:15, For Largest:17
recheck := 50 ;How often the script should open up new tables (if needed), 50=10seconds, 25=5seconds etc... Try not to set this too low for CPU performance issues
;------------------------------------------
Gui, Font, s8, Arial
Gui, Add, Text,, Number Of Tables:
Gui, Add, Edit
Gui, Add, UpDown, vnumberoftablestokeepopen Range1-24, 12
Gui, Add, Checkbox, venabledisable, Run!
Gui, Show,, Thois TableOpener for PokerStars v1.00
Gui, Submit, NoHide
numberofloopinstances := recheck - 1
Loop
{
Gui, Submit, NoHide
SendMessage, 0x115, 0, 0, PokerStarsListClass1, PokerStars Lobby
numberofloopinstances := numberofloopinstances + 1
if (numberofloopinstances = recheck)
{
numberofloopinstances := 0
WinGet, numberofwindows, Count, ahk_class PokerStarsTableFrameClass,,Lobby
beffen := numberoftablestokeepopen - numberofwindows
if (beffen > 0 AND enabledisable = 1)
{
Loop
{
ControlGet, tablesinthelobby, Hwnd, , PokerStarsListClass1, PokerStars Lobby
yclick := 1 + (rowheight * A_Index) - rowheight
PostLeftClick(1, yclick, tablesinthelobby)
ControlClick, PokerStarsButtonClass10, PokerStars Lobby
Sleep, 500
WinGet, numberofwindows, Count, ahk_class PokerStarsTableFrameClass,,Lobby
beffen := numberoftablestokeepopen - numberofwindows
if (beffen = 0)
{
break
}
}
}
}
Sleep, 200
}
; Hotkeys (disabled)
;~Xbutton1:: ;Endlessly cycles between all tables in the stack the cursor is pointing at (brings the front table to the back), disabled (remove ; marks to enable)
;MouseGetPos,,,tableID
;WinGetClass, classoftableid, ahk_id %tableID%
;if (classoftableid = "PokerStarsTableFrameClass")
; {
; WinSet, Bottom,, ahk_id %tableID%
; }
;return
;~Xbutton2:: ;Closes the table the mouse is pointing at (also clicks the OK warning button), disabled (remove ; marks to enable)
;MouseGetPos,,,tableID
;WinGetClass, classoftableid, ahk_id %tableID%
;if (classoftableid = "PokerStarsTableFrameClass");
; {
; WinClose, ahk_id %tableID%
; Sleep,20
; ControlClick, Button1, Table, OK
; }
;return
;Juks rocks - I deactivated WinActivate so that the Lobby doesnt steal focus
PostLeftClick(x, y, table_id, activate=1) {
; ### JUK: Send the down left click, then the mouse-up messages.
; NOTE: This is relative to the top left of the client area and NOT the top left of the
; window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!).
If activate
; WinActivate, ahk_id%table_id%
PostMessage, 0x201, 0x0001, ((y<<16)^x), , ahk_id%table_id%
PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id%
}
GuiClose:
ExitApp
I am learning python at the moment, and this is the kind of project that interests me. I don't know what language the script is written (lisp or autohotkey probably?), but I would like to convert it to python. Can you please point me in the right direction and tell me
- what language was used for this?
- what do i need to learn convert it?
Thanks!
; Thois TableOpener for PokerStars v1.05
; Opens new cash game tables from the lobby every x seconds (if there are less tables opened than your predefined settings). A great tool for multi-tablers.
; Customize the variables below (between the lines)
; 'Thois' on PS for donations
; Customizable variables (between the lines)
;------------------------------------------
rowheight := 13 ;In the PokerStars lobby go to View > Text Size: For Medium & smaller:13, For smallest:12, For Larger:15, For Largest:17
recheck := 50 ;How often the script should open up new tables (if needed), 50=10seconds, 25=5seconds etc... Try not to set this too low for CPU performance issues
;------------------------------------------
Gui, Font, s8, Arial
Gui, Add, Text,, Number Of Tables:
Gui, Add, Edit
Gui, Add, UpDown, vnumberoftablestokeepopen Range1-24, 12
Gui, Add, Checkbox, venabledisable, Run!
Gui, Show,, Thois TableOpener for PokerStars v1.00
Gui, Submit, NoHide
numberofloopinstances := recheck - 1
Loop
{
Gui, Submit, NoHide
SendMessage, 0x115, 0, 0, PokerStarsListClass1, PokerStars Lobby
numberofloopinstances := numberofloopinstances + 1
if (numberofloopinstances = recheck)
{
numberofloopinstances := 0
WinGet, numberofwindows, Count, ahk_class PokerStarsTableFrameClass,,Lobby
beffen := numberoftablestokeepopen - numberofwindows
if (beffen > 0 AND enabledisable = 1)
{
Loop
{
ControlGet, tablesinthelobby, Hwnd, , PokerStarsListClass1, PokerStars Lobby
yclick := 1 + (rowheight * A_Index) - rowheight
PostLeftClick(1, yclick, tablesinthelobby)
ControlClick, PokerStarsButtonClass10, PokerStars Lobby
Sleep, 500
WinGet, numberofwindows, Count, ahk_class PokerStarsTableFrameClass,,Lobby
beffen := numberoftablestokeepopen - numberofwindows
if (beffen = 0)
{
break
}
}
}
}
Sleep, 200
}
; Hotkeys (disabled)
;~Xbutton1:: ;Endlessly cycles between all tables in the stack the cursor is pointing at (brings the front table to the back), disabled (remove ; marks to enable)
;MouseGetPos,,,tableID
;WinGetClass, classoftableid, ahk_id %tableID%
;if (classoftableid = "PokerStarsTableFrameClass")
; {
; WinSet, Bottom,, ahk_id %tableID%
; }
;return
;~Xbutton2:: ;Closes the table the mouse is pointing at (also clicks the OK warning button), disabled (remove ; marks to enable)
;MouseGetPos,,,tableID
;WinGetClass, classoftableid, ahk_id %tableID%
;if (classoftableid = "PokerStarsTableFrameClass");
; {
; WinClose, ahk_id %tableID%
; Sleep,20
; ControlClick, Button1, Table, OK
; }
;return
;Juks rocks - I deactivated WinActivate so that the Lobby doesnt steal focus
PostLeftClick(x, y, table_id, activate=1) {
; ### JUK: Send the down left click, then the mouse-up messages.
; NOTE: This is relative to the top left of the client area and NOT the top left of the
; window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!).
If activate
; WinActivate, ahk_id%table_id%
PostMessage, 0x201, 0x0001, ((y<<16)^x), , ahk_id%table_id%
PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id%
}
GuiClose:
ExitApp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
毫无疑问,这就是 AutoHotKey。你需要转换的是:
您应该注意到 AutoHotKey 和 Python 非常不同。 AutoHotKey 是一款用于自动化鼠标和键盘以控制其他程序的软件。这对于 Python 来说当然是可行的,但具体的实现方式取决于环境。如果没有外部库的帮助,您可能无法做到这一点,因为 Python 是您主要用来编写程序的语言,而不是用于控制现有程序的语言。
所以我怀疑你的转换努力是否值得。
That is without a doubt AutoHotKey. What you need to convert this is:
You should note that AutoHotKey and Python are very different. AutoHotKey is a software for automating Mouse and Keyboard, to control other programs. That is certainly doable with Python but the way you would do it depends on the environment. You probably can't do it without external libraries to help you, because Python is a language you mostly write programs in, not a language you use to control existing programs.
So I doubt that your conversion effort will be worth it.