2011-06-27 218 views
0

我正在學python,這是我感興趣的那種project。我不知道腳本是用什麼語言編寫的(lisp或autohotkey可能?),但我想將它轉換爲python。請你指點我正確的方向,並告訴我將代碼轉換爲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 

回答

2

毫無疑問,這是AutoHotKey。你需要將其轉換爲:

  1. 足夠了解AutoHotKey以瞭解程序的功能。
  2. 足夠了解Python能夠重新創建程序的功能。

你應該注意AutoHotKey和Python是很不一樣。 AutoHotKey是一款用於自動化鼠標和鍵盤的軟件,用於控制其他程序。這對Python來說當然是可行的,但是你會這樣做的方式取決於環境。如果沒有外部庫來幫助你,你可能無法做到這一點,因爲Python是一種你主要編寫程序的語言,而不是用來控制現有程序的語言。

所以我懷疑你的轉換工作是否值得。