Advertisement
deseven

mcadm

Jul 1st, 2011
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Enumeration
  2.   #hk_ctrlm
  3.   #hk_ctrlg
  4.   #hk_ctrll
  5.   #hk_ctrls
  6.   #hk_ctrlk
  7.   #hk_ctrlu
  8.   #hk_ctrli
  9. EndEnumeration
  10.  
  11. Procedure.s GetActiveWindowText()
  12.   ActiveWindow.s = Space(999) : GetWindowText_(GetForegroundWindow_(),ActiveWindow,999)
  13.   ProcedureReturn ActiveWindow
  14. EndProcedure
  15.  
  16. Procedure SendInput(*txt)
  17.  
  18.   *idata = AllocateMemory(SizeOf(INPUT)*2)
  19.   Protected *inputdata.INPUT, onekey.INPUT
  20.  
  21.   *key.CHARACTER = *txt
  22.  
  23.   While *key\c
  24.    
  25.     ; Translate the character to its virtual key code
  26.     ; and see if it requires SHIFT to be pressed
  27.    
  28.     key.w = VkKeyScan_(*key\c)
  29.     keyvalue = key & $FF
  30.     shift    = key >> 8
  31.    
  32.     ; Press SHIFT if indicated
  33.    
  34.     If shift
  35.       RtlZeroMemory_(onekey,SizeOf(INPUT))
  36.       With onekey
  37.         \type   = #INPUT_KEYBOARD
  38.         \ki\wVk = #VK_SHIFT
  39.       EndWith
  40.       SendInput_(1, onekey, SizeOf(INPUT))
  41.     EndIf
  42.    
  43.     ; Press the character key down
  44.    
  45.     *inputdata = *idata
  46.     RtlZeroMemory_(*idata,SizeOf(INPUT)*2)
  47.    
  48.     With *inputdata
  49.       \type   = #INPUT_KEYBOARD
  50.       \ki\wVk = keyvalue
  51.     EndWith
  52.    
  53.     ; Release the character key
  54.    
  55.     *inputdata + SizeOf(INPUT)
  56.    
  57.     With *inputdata
  58.       \type       = #INPUT_KEYBOARD
  59.       \ki\wVk     = keyvalue
  60.       \ki\dwFlags = #KEYEVENTF_KEYUP
  61.     EndWith
  62.    
  63.     SendInput_(2, *idata, SizeOf(INPUT))
  64.  
  65.     ; Release the SHIFT key if we pressed it
  66.    
  67.     If shift
  68.       RtlZeroMemory_(onekey,SizeOf(INPUT))
  69.       With onekey
  70.         \type       = #INPUT_KEYBOARD
  71.         \ki\wVk     = #VK_SHIFT
  72.         \ki\dwFlags = #KEYEVENTF_KEYUP          
  73.       EndWith
  74.       SendInput_(1, onekey, SizeOf(INPUT))
  75.     EndIf
  76.    
  77.     ; Process next character if there is one
  78.    
  79.     *key+1
  80.   Wend      
  81. EndProcedure
  82.  
  83. LoadFont(1,"Terminal",12)
  84. OpenWindow(0,#PB_Ignore,#PB_Ignore,200,220,"mcadm b12",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  85. TextGadget(1,10,10,180,20,"god mode toggle...........CTRL-G",#PB_Text_Center)
  86. TextGadget(2,10,40,180,20,"more items................CTRL-M",#PB_Text_Center)
  87. TextGadget(3,10,70,180,20,"active players............CTRL-L",#PB_Text_Center)
  88. TextGadget(4,10,100,180,20,"mcMMO stats...............CTRL-S",#PB_Text_Center)
  89. TextGadget(5,10,130,180,20,"claim chunk...............CTRL-K",#PB_Text_Center)
  90. TextGadget(6,10,160,180,20,"unclaim chunk.............CTRL-U",#PB_Text_Center)
  91. TextGadget(7,10,190,180,20,"chunk info................CTRL-I",#PB_Text_Center)
  92. SetGadgetFont(1,FontID(1)) : SetGadgetFont(2,FontID(1)) : SetGadgetFont(3,FontID(1)) : SetGadgetFont(4,FontID(1)) : SetGadgetFont(5,FontID(1)) : SetGadgetFont(6,FontID(1)) : SetGadgetFont(7,FontID(1))
  93.  
  94. hk_ctrlm = RegisterHotKey_(WindowID(0),#hk_ctrlm,#MOD_CONTROL,#VK_M)
  95. hk_ctrlg = RegisterHotKey_(WindowID(0),#hk_ctrlg,#MOD_CONTROL,#VK_G)
  96. hk_ctrll = RegisterHotKey_(WindowID(0),#hk_ctrll,#MOD_CONTROL,#VK_L)
  97. hk_ctrls = RegisterHotKey_(WindowID(0),#hk_ctrls,#MOD_CONTROL,#VK_S)
  98. hk_ctrlk = RegisterHotKey_(WindowID(0),#hk_ctrlk,#MOD_CONTROL,#VK_K)
  99. hk_ctrlu = RegisterHotKey_(WindowID(0),#hk_ctrlu,#MOD_CONTROL,#VK_U)
  100. hk_ctrli = RegisterHotKey_(WindowID(0),#hk_ctrli,#MOD_CONTROL,#VK_I)
  101.  
  102. Repeat
  103.   ev = WaitWindowEvent()
  104.   If ev = #WM_HOTKEY And GetActiveWindowText() = "Minecraft"
  105.     Select EventwParam()
  106.       Case #hk_ctrlm
  107.         WindowHandle = GetForegroundWindow_()
  108.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  109.         Layout = GetKeyboardLayout_(ProcessId)
  110.         Debug " - - - "
  111.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  112.         If Not Layout = 67699721
  113.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  114.           Delay(1000)
  115.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  116.         EndIf
  117.         If GetKeyboardLayout_(ProcessId) = 67699721
  118.           ;Debug "sending"
  119.           keybd_event_(#VK_T,0,0,0)
  120.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  121.           Delay(500)
  122.           SendInput(@"/more")
  123.           ;Delay(50)
  124.           keybd_event_(#VK_RETURN,0,0,0)
  125.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  126.           Delay(1000)
  127.         EndIf
  128.         If Not Layout = 67699721
  129.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  130.           Delay(500)
  131.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  132.         EndIf
  133.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  134.        
  135.       Case #hk_ctrlg
  136.         WindowHandle = GetForegroundWindow_()
  137.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  138.         Layout = GetKeyboardLayout_(ProcessId)
  139.         Debug " - - - "
  140.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  141.         If Not Layout = 67699721
  142.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  143.           Delay(1000)
  144.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  145.         EndIf
  146.         If GetKeyboardLayout_(ProcessId) = 67699721
  147.           ;Debug "sending"
  148.           keybd_event_(#VK_T,0,0,0)
  149.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  150.           Delay(500)
  151.           SendInput(@"/god")
  152.           ;Delay(50)
  153.           keybd_event_(#VK_RETURN,0,0,0)
  154.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  155.           Delay(1000)
  156.         EndIf
  157.         If Not Layout = 67699721
  158.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  159.           Delay(500)
  160.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  161.         EndIf
  162.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  163.        
  164.       Case #hk_ctrll
  165.         WindowHandle = GetForegroundWindow_()
  166.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  167.         Layout = GetKeyboardLayout_(ProcessId)
  168.         Debug " - - - "
  169.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  170.         If Not Layout = 67699721
  171.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  172.           Delay(1000)
  173.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  174.         EndIf
  175.         If GetKeyboardLayout_(ProcessId) = 67699721
  176.           ;Debug "sending"
  177.           keybd_event_(#VK_T,0,0,0)
  178.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  179.           Delay(500)
  180.           SendInput(@"/list")
  181.           ;Delay(50)
  182.           keybd_event_(#VK_RETURN,0,0,0)
  183.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  184.           Delay(1000)
  185.         EndIf
  186.         If Not Layout = 67699721
  187.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  188.           Delay(500)
  189.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  190.         EndIf
  191.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  192.        
  193.       Case #hk_ctrls
  194.         WindowHandle = GetForegroundWindow_()
  195.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  196.         Layout = GetKeyboardLayout_(ProcessId)
  197.         Debug " - - - "
  198.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  199.         If Not Layout = 67699721
  200.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  201.           Delay(1000)
  202.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  203.         EndIf
  204.         If GetKeyboardLayout_(ProcessId) = 67699721
  205.           ;Debug "sending"
  206.           keybd_event_(#VK_T,0,0,0)
  207.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  208.           Delay(500)
  209.           SendInput(@"/stats")
  210.           ;Delay(50)
  211.           keybd_event_(#VK_RETURN,0,0,0)
  212.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  213.           Delay(1000)
  214.         EndIf
  215.         If Not Layout = 67699721
  216.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  217.           Delay(500)
  218.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  219.         EndIf
  220.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  221.        
  222.       Case #hk_ctrlk
  223.         WindowHandle = GetForegroundWindow_()
  224.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  225.         Layout = GetKeyboardLayout_(ProcessId)
  226.         Debug " - - - "
  227.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  228.         If Not Layout = 67699721
  229.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  230.           Delay(1000)
  231.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  232.         EndIf
  233.         If GetKeyboardLayout_(ProcessId) = 67699721
  234.           ;Debug "sending"
  235.           keybd_event_(#VK_T,0,0,0)
  236.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  237.           Delay(500)
  238.           SendInput(@"/arg claim")
  239.           ;Delay(50)
  240.           keybd_event_(#VK_RETURN,0,0,0)
  241.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  242.           Delay(1000)
  243.         EndIf
  244.         If Not Layout = 67699721
  245.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  246.           Delay(500)
  247.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  248.         EndIf
  249.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  250.        
  251.       Case #hk_ctrlu
  252.         WindowHandle = GetForegroundWindow_()
  253.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  254.         Layout = GetKeyboardLayout_(ProcessId)
  255.         Debug " - - - "
  256.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  257.         If Not Layout = 67699721
  258.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  259.           Delay(1000)
  260.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  261.         EndIf
  262.         If GetKeyboardLayout_(ProcessId) = 67699721
  263.           ;Debug "sending"
  264.           keybd_event_(#VK_T,0,0,0)
  265.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  266.           Delay(500)
  267.           SendInput(@"/arg unclaim")
  268.           ;Delay(50)
  269.           keybd_event_(#VK_RETURN,0,0,0)
  270.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  271.           Delay(1000)
  272.         EndIf
  273.         If Not Layout = 67699721
  274.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  275.           Delay(500)
  276.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  277.         EndIf
  278.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  279.        
  280.       Case #hk_ctrli
  281.         WindowHandle = GetForegroundWindow_()
  282.         ProcessId = GetWindowThreadProcessId_(WindowHandle,0) ; ИД процесса активного окна
  283.         Layout = GetKeyboardLayout_(ProcessId)
  284.         Debug " - - - "
  285.         Debug "Pre: " + Str(GetKeyboardLayout_(ProcessId))
  286.         If Not Layout = 67699721
  287.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,LoadKeyboardLayout_("67699721",#KLF_ACTIVATE))
  288.           Delay(1000)
  289.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))  
  290.         EndIf
  291.         If GetKeyboardLayout_(ProcessId) = 67699721
  292.           ;Debug "sending"
  293.           keybd_event_(#VK_T,0,0,0)
  294.           keybd_event_(#VK_T,0,#KEYEVENTF_KEYUP,0)
  295.           Delay(500)
  296.           SendInput(@"/arg info")
  297.           ;Delay(50)
  298.           keybd_event_(#VK_RETURN,0,0,0)
  299.           keybd_event_(#VK_RETURN,0,#KEYEVENTF_KEYUP,0)
  300.           Delay(1000)
  301.         EndIf
  302.         If Not Layout = 67699721
  303.           PostMessage_(WindowHandle,#WM_INPUTLANGCHANGEREQUEST,0,ActivateKeyboardLayout_(Str(Layout),#KLF_ACTIVATE))
  304.           Delay(500)
  305.           Debug "Changed to: " + Str(GetKeyboardLayout_(ProcessId))
  306.         EndIf
  307.         Debug "After: " + Str(GetKeyboardLayout_(ProcessId))
  308.        
  309.     EndSelect
  310.   EndIf
  311. Until ev = #PB_Event_CloseWindow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement