title: Converting Autoit to Python
body: <p>So I have this brilliant little AutoIt script that I've been using for the last couple years. Orginally built for Skype, it's used to reduce the memory usages of RAM hoging applications to the minimal they need (For Windows Only), and keeping them as low as possible, only giving them what they truly need. Here's what it looks like:</p>
  
  <pre><code>#include &lt;Misc.au3&gt;
  _Singleton("skype-memory-reducer")
  
  Opt("TrayMenuMode", 1)
  Opt("TrayOnEventMode", 1)
  
  TrayCreateItem("Quit")
  TrayItemSetOnEvent(-1, "Bye")
  TraySetState()
  
  Global Const $interval = 2000 ; interval at which the memory is freed, anything below this will almost certainly only slow down your system.
  
  ;here you can add any other process,
  ;but be carefull which process you choose,
  ;bacause in some cases this will slow down your application or even your PC
  Global $list = "skype.exe|skypePM.exe"
  Global $processlist = StringSplit($list, "|")
  
  While 1
      For $i = 1 To UBound($processlist) - 1
          $pid = ProcessExists($processlist[$i])
          If $pid Then _ReduceMemory($pid)
      Next
      _ReduceMemory(); also reduce the memory used by the script itself...
      Sleep($interval)
  WEnd
  
  Func Bye()
      Exit
  EndFunc   ;==&gt;Bye
  
  ;I don't remember who was the author of this UDF... (it's not me)
  Func _ReduceMemory($i_PID = -1)
      If $i_PID &lt;&gt; -1 Then
          Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
          Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
          DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
      Else
          Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
      EndIf
  
      Return $ai_Return[0]
  EndFunc   ;==&gt;_ReduceMemory 
  </code></pre>
  
  <p>Now, I'm looking for trying to pull off the same thing but stricly in Python. Either by something completely native in Python, or something that can run Autoit scripts within Python without the need for calling in another process.</p>
  
  <p>Any help is apprecieated, thanks!</p>
  
  <p>EDIT: Just incase, I'd like my application to be portable in the end. So I'm trying to avoid having to register any DLLs in Windows (incase someone was thinking of using the Win32 module) Thanks again!</p>