Deutsches AutoHotkey Homepage AutoHotkey Community
Wir helfen uns gegenseitig aus der Patsche
 
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

IniRead
Gehe zu Seite 1, 2, 3  Weiter
 
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe!
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
dosenfleisch
Gast





BeitragVerfasst am: Fr Apr 14, 2006 2:23 pm    Titel: IniRead Antworten mit Zitat

Sorry, weiß keinen Titel!

Hallo,

ich brauche Deine Hilfe.
Folgenden Code habe ich geschrieben. Er arbeitet bisher fehlerfrei.
Leider will mir nicht einfallen, wie ich den Code dahingehend verändern muß, daß ich weitere Prog- und Win-Werte der ini-Datei hinzufügen kann (,welche dann auch ausgelesen werden). Section1 arbeitet wie gesagt korrekt.

[Section1]
Prog=MeinProg.exe
Win=WinTitel

[Sektion2]
Prog=
Win=

Code:

#persistent
settitlematchmode, 2

iniread, Prog1, ttt.ini, Section1, Prog
iniread, Win1, ttt.ini, Section1, Win

settimer, process, 1000
settimer, windows, 60000
settimer, linecount, 10000

process:
pass1 =
ifwinexist, %Win1%
{
winclose, %Win1%
InputBox, pass1, Password Entry, Enter password, hide , 130, 115, , , ,15
If pass1 = men
run, %Prog1%
sleep, 30000
winwait, close, %Win1%
}
return

windows:
ifwinexist, %Win1%
fileappend, `n%A_NOW%, %A_DD%.ttt
return


linecount:
FileRead File, %A_DD%.ttt
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe = 30
{
winclose, %Win1%
msgbox, ,Achtung , Die Zeit ist vorbei!, 30
}
return


Das Skript soll eine maximale Nutzungsdauer für bestimme Programme/Spiele/Fenster ermöglichen.
Nach oben
toralf



Anmeldedatum: 25.10.2005
Beiträge: 110
Wohnort: Stuttgart

BeitragVerfasst am: Sa Apr 15, 2006 7:34 pm    Titel: Antworten mit Zitat

Hi,

Ich habe mir den code nicht genau angeschaut, da Du ja geschrieben hast, dass er funktioniert. Daher nur zu Deiner Frage:

Du kannst z.B. mit einer Schleife (Loop) entweder die Sections hochzählen (bis ein Wert ERROR) zurückgibt. Oder auch einfach die keys hochzählen (z.B. Prog1, Prog2, Prog3, ...)
Code:
Loop {
  IniRead, Value, ttt.ini, Section%A_Index%, Prog
  ; oder
  ;IniRead, Value, ttt.ini, Section, Prog%A_Index%
  If Value = Error
      break
  Prog%A_index% = Value
  }
*not tested*

Gleiches gilt für IniWrite.
_________________
Ciao
toralf
Auto-Syntax-Tidy Icon Viewer EasyCopy AHK
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
dosenfleisch
Gast





BeitragVerfasst am: Mo Apr 17, 2006 11:41 am    Titel: Antworten mit Zitat

Danke, für die Hilfe.
Hier nun mein Script.
Leider ist es etwas langsam.
Das Script soll zukünftig verschiedene Passwörter erkennen und dann verschiedene "countdowns" auslösen.
Im Moment fällt mir nichts anderes ein, als für jedes Passwort ein eigenes Label zu haben.

So z.B.:
If pass=1.Passwort
goto linecountPasswort1
If pass=2.Passwort
goto linecountPasswort2

Und dann je eigene Dateien erstellen und auslesen.

Ich befürchte jedoch, daß das alles dann zu träge wird und nicht mehr sauber arbeitet.
Nun meine beiden Fragen:

1. Wo bremst sich das Script aus?
2. Welche Möglichkeit (Newbie-geeignet) gibt es noch für das Multi-Passwort-Script?


Code:

#persistent                       
settitlematchmode, 2             
#Singleinstance force            
Detecthiddenwindows on          
                           
settimer, process, 1000          
settimer, windows, 60000
settimer, linecount, 5000
;###################################################################
process:
Loop 
{                   
IniRead, Value, Progs.ini, Programme, Prog%A_Index%
If Value = Error
break
Prog%A_index% = Value
pass1 =                   
ifwinexist, %Value%          
gosub, linecount            
sleep, 1000
ifwinexist, %Value%         
winhide, %Value%          
InputBox, pass1, Passwort, Enter password, hide , 130, 115, , , ,15
If pass1 = men             
{                        
winshow, %Value%         
WinMaximize, %Value%
WinActivate, %Value%
sleep, 300
ifwinexist, %Value%
winwaitclose %Value%          
}
gosub close               
}
}
return
;###################################################################
windows:
ifwinexist, %Value%            
fileappend, `n%A_NOW%, %A_DD%%A_MM%.ttt    
return                   
;########################################################
linecount:
ifwinexist, %Value%               
{
FileRead File, %A_DD%%A_MM%.ttt    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 30             
{
gosub close               
sleep, 500
}
}
return
;###################################################################
close:                  
ifwinexist, %Value%
{
Settimer, Process, off
winclose, Passwort
Winshow, %Value%
winclose, %Value%
Winkill, %Value%
Soundbeep, 100, 400
}
Settimer, Process, on
exit
return
;###################################################################


Progs.ini
Code:

[Programme]
Prog1=Editor
Prog2=Notepad++
Prog3=Opera
Prog4=Media Player Classic
Prog5=SuperTux

(Kommentierung mußte ich herausnehmen, da sie sich sonst im Browser die Zeilen verschoben und unübersichtlich wurden.)
Nach oben
dosenfleisch
Gast





BeitragVerfasst am: Mi Apr 19, 2006 10:19 am    Titel: Antworten mit Zitat

hallo,
ich konnte meine "probleme" inzwischen selber lösen.
allerdings habe ich bei einigen spielen probleme, wenn das script das spiel starten will.

wenn die spiel.exe nicht aus demselben verzeichnis heraus gestartet wird, dann startet sie nicht oder mit fehlermeldung.
auch eine bat-datei funktioniert nicht, auch nicht eine spiel-ahk.exe im selben verzeichnis , die dann die spiel.exe aufruft.

nochmal, wenn mein script im spiele-ordner liegen würde, würde die spiel.exe starten. da es dort aber nicht liegt und auch nicht liegen solol, startet spiel.exe nicht.
ich hoffe, es war verständlich.

wie kann ich eine solche exe trotzdem starten?

dieses problem habe ich momentan bei drei spielen, andere funktionieren. das problem wird nicht direkt durch das script verursacht, sondern scheint von windows herzurühren. vielleicht sind die spiel.exe aber auch vor solchen aktionen intern geschützt.
Nach oben
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1893
Wohnort: Österreich

BeitragVerfasst am: Mi Apr 19, 2006 10:46 am    Titel: Antworten mit Zitat

Eventuell kannst du versuchen das WorkingDirectory des Scripts entsprechend zu setzen.
Da ich keine entsprechenden Spiele habe kann ichs nicht probieren...

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
dosenfleisch
Gast





BeitragVerfasst am: Mi Apr 19, 2006 2:14 pm    Titel: Antworten mit Zitat

ich poste mal das script, vielleicht siehst du ja die lösung.
setworkingdir müßte je nach programm oder spiel eine andere sein.

funktionsweise:
es wird nach programmen gesucht, die von d:\ gestartet werden und dann nach einem passwort gefragt.
je nach passwort wird ein anderes label aufgerufen.
das script ist (wie immer) nicht der reißer in sachen coden, hat mir aber auch so schon schlaflose nächte bereitet. Wink
98% sind übrigens aus dem engl. forum geklaut.

Code:

#persistent
;#notrayicon
settimer, password, 5000

password:
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
   
      If lname<>
      {                   
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {    
      lnamecon = %lname%
      sleep, 3000
      soundbeep, 70, 70
      gosub winkiller
      InputBox, pass1, Password Entry, Enter password, hide , 130, 115, , , ,10
         
         If pass1 = men
            {
            run, %lname%
            goto linereadmen
            }
         
         If pass1 = toll
            {
            run, %lname%
            goto linereadtoll
            }
         
         
         If pass1 = hell
            {
            run, %lname%
            goto linereadhell
            }
         
         
         
         If pass1 = ball
            {
            run, %lname%
            goto linereadball
            }
         
         else
         goto winkiller
        }
      
      }
}
return
 
linereadmen:
FileRead File, %A_DD%%A_MM%.men    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 10000
{                
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.men
      goto linereadmen
        }
      goto password
      goto winkiller
      }
      
      }
}
return

linereadtoll:
FileRead File, %A_DD%%A_MM%.toll    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 330 ; 35min
{                
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.toll
      goto linereadtoll
        }
      goto password
      goto winkiller
      }
      
      }
}
return

linereadhell:
FileRead File, %A_DD%%A_MM%.hell    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 66 ; 7min
{                
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.hell
      goto linereadhell
        }
      goto password
      goto winkiller
      }
      
      }
}
return


linereadball:
FileRead File, %A_DD%%A_MM%.ball    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 140 ; 15min
{                
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.ball
      goto linereadball
        }
      goto password
      goto winkiller
      }
      
      }
}
return



winkiller:
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
          WinClose, ahk_pid %A_LoopField%
          Process, WaitClose, %A_LoopField%, 4
        soundbeep, 100,1000
          If (ErrorLevel)
          {
            Process, Close, %A_LoopField%
            Process, WaitClose, %A_LoopField%, 4
            If (ErrorLevel)
              MsgBox, %lname% is not responding. `nPlease manually close this application
          }
        }
      }
}
return

EnumProcesses( byref r_pid_list )
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return, false
   }
   
   pid_list_size := 4*1000
   VarSetCapacity( pid_list, pid_list_size )
   
   status := DllCall( "psapi.dll\EnumProcesses", "uint", &pid_list, "uint", pid_list_size, "uint*", pid_list_actual )
   if ( ErrorLevel or !status )
      return, false
       
   total := pid_list_actual//4

   r_pid_list=
   address := &pid_list
   loop, %total%
   {
      r_pid_list := r_pid_list "|" ( *( address )+( *( address+1 ) << 8 )+( *( address+2 ) << 16 )+( *( address+3 ) << 24 ) )
      address += 4
   }
   
   StringTrimLeft, r_pid_list, r_pid_list, 1
   
   return, total
}

GetModuleFileNameEx( p_pid )
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return
   }

   h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid )
   if ( ErrorLevel or h_process = 0 )
      return
   
   name_size = 255
   VarSetCapacity( name, name_size )
   
   result := DllCall( "psapi.dll\GetModuleFileNameExA", "uint", h_process, "uint", 0, "str", name, "uint", name_size )
   
   DllCall( "CloseHandle", h_process )
   
   return, name
}
Nach oben
dosenfleisch
Gast





BeitragVerfasst am: Mi Apr 19, 2006 3:09 pm    Titel: Antworten mit Zitat

wenn ihr keine bessere idee habt, lasse ich es einfach so, daß nach passworteingabe das programm nicht neugestartet wird, sondern per hand angeklickt werden muß.

Code:

password:
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
   
      If lname<>
      {                   
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive
      
        ; close the program if drive matches:
        if Drive = %mydrive%
        {    
      lnamecon = %lname%
      sleep, 1000
      soundbeep, 70, 70
      gosub winkiller
      InputBox, pass1, Password Entry, Enter password, hide , 130, 115, , , ,10
         
         If pass1 = men
            {
            if lname = D:\spiele\Problemspiel1.exe
            goto linereadmen
            if lname = D:\spiele\Problemspiel2.exe
            goto linereadmen
            run, %lname%
            goto linereadmen
            }
         
         If pass1 = toll
            {
            if lname = D:\spiele\Problemspiel1.exe
            goto linereadmen
            if lname = D:\spiele\Problemspiel2.exe
            goto linereadtoll
            run, %lname%
            goto linereadtoll
            }
.
.
.
Nach oben
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1893
Wohnort: Österreich

BeitragVerfasst am: Mi Apr 19, 2006 4:02 pm    Titel: Antworten mit Zitat

Puh, das Script sieht arg verbesserungswürdig aus ^^

Aber hast du mal versucht den Pfad für "SetWorkingDir" direkt vor jedem Run-Befehl aus deinen bestehenden Infos zusammenzusetzen? Zur Not erst einmal für eine Beispiel-exe hardcoden um zu sehen ob es funktioniert und anschließend flexibel gestalten wie du es brauchst Wink

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
dosenfleisch
Gast





BeitragVerfasst am: Mi Apr 19, 2006 4:26 pm    Titel: Antworten mit Zitat

ja, so:

Code:

loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
   
      If lname<>
      {                   
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive
        SplitPath, ,ldir , , , ,  <-------------------
       
        ; close the program if drive matches:
     if Drive = %mydrive%
        {     
      lnamecon = %lname%
      sleep, 1000
      soundbeep, 70, 70
      gosub winkiller
      InputBox, pass1, Password Entry, Enter password, hide , 130, 115, , , ,10
         
If pass1 = men
            {
           SetWorkingDir, %ldir%   <------------------
            run, %lname%
            goto linereadmen
            }
.
.
.

     


ich konnte jedoch keine änderung feststellen, muß jedoch dazu sagen, daß ich diesen befehl nur in der theorie verstehe. wie er sich praktisch auswirken kann, bleibt mir verborgen Wink

ich habe im vorher geposteten script zum teil auf falsche labels verwiesen und korrigiert, verzichte aber aufs code-posten, sonst liest das hier keiner mehr Twisted Evil
Nach oben
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1893
Wohnort: Österreich

BeitragVerfasst am: Do Apr 20, 2006 7:11 am    Titel: Antworten mit Zitat

Falls du eine freie (und kleine) version einer solchen exe hast (ums zu testen) kann ich mal schauen ob ich etwas herausfinde.

Anders ists schwierig.

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
dosenfleisch
Gast





BeitragVerfasst am: Do Apr 20, 2006 8:01 am    Titel: Antworten mit Zitat

gezippt ist das kleinste programm knapp 200mb groß.
ich könnte es irgendwo hochladen oder hinschicken.
ohne dsl wäre das aber wohl etwas viel.

was denkst du?
Nach oben
dosenfleisch
Gast





BeitragVerfasst am: Do Apr 20, 2006 8:21 am    Titel: Antworten mit Zitat

auf www.trackmanianations.com gibt es ein freies spiel, daß sich nicht mit einer bat datei öffnen läßt, wenn diese sich auf dem desktop befindet.
das spiel ist freeware und etwa 150mb groß.
Nach oben
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1893
Wohnort: Österreich

BeitragVerfasst am: Do Apr 20, 2006 9:06 am    Titel: Antworten mit Zitat

Kommt drauf an wie flott die Server sind...
Unter guten Umständen hätt ichs in 20-30min herunten Wink

Mal sehn.. Schwieriger wirds noch Platz auf der HD zu finden Sad
Meine C:\ hat im Moment noch ~10 MB, auf der D:\ könnt nochwas frei sein..

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
dosenfleisch
Gast





BeitragVerfasst am: Do Apr 20, 2006 5:56 pm    Titel: Antworten mit Zitat

@Thalon

ich poste mal mein derzeitiges script, damit du damit testen kannst.

Code:

#persistent
#notrayicon
settimer, password, 5000

password:
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
   
      If lname<>
      {                   
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive
      
        ; close the program if drive matches:
        if Drive = %mydrive%
        {    
      lnamecon = %lname%
      sleep, 1000
      soundbeep, 70, 70
      gosub winkiller
      InputBox, pass1, Password Entry, Enter password, hide , 130, 115, , , ,10
         
         If pass1 = men
            {
            if lname = D:\spiele\Worms World Party\wwp.exe
            goto linereadmen
            if lname = D:\spiele\worms4\WORMS 4 MAYHEM.EXE
            goto linereadmen
            if lname = D:\spiele\Ice.Age.2\iceage2pc.exe
            goto linereadmen
            run, %lname%
            goto linereadmen
            }
         
         If pass1 = toll
            {
            if lname = D:\spiele\Worms World Party\wwp.exe
            goto linereadtoll
            if lname = D:\spiele\worms4\WORMS 4 MAYHEM.EXE
            goto linereadtoll      
            if lname = D:\spiele\Ice.Age.2\iceage2pc.exe
            goto linereadtoll
            run, %lname%
            goto linereadtoll
            }
         
         
         If pass1 = hell
            {
            if lname = D:\spiele\worms4\WORMS 4 MAYHEM.EXE
            goto linereadhell
            if lname = D:\spiele\Worms World Party\wwp.exe
            goto linereadhell
            if lname = D:\spiele\Ice.Age.2\iceage2pc.exe
            goto linereadhell
            run, %lname%
            goto linereadhell
            }
         
         
         
         If pass1 = ball
            {
            if lname = D:\spiele\worms4\WORMS 4 MAYHEM.EXE
            goto linereadball
            if lname = D:\spiele\Worms World Party\wwp.exe
            goto linereadball
            if lname = D:\spiele\Ice.Age.2\iceage2pc.exe
            goto linereadball
            run, %lname%
            goto linereadball
            }
         
         else
         goto winkiller
        }
      
      }
}
return
 
linereadmen:
FileRead File, %A_DD%%A_MM%.men    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 10000
{
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000               
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.men
      goto linereadmen
        }
      goto password
      goto winkiller
      }
      
      }
}
return

linereadtoll:
FileRead File, %A_DD%%A_MM%.toll    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 350 ; 35min
{
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000               
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.toll
      goto linereadtoll
        }
      goto password
      goto winkiller
      }
      
      }
}
return

linereadhell:
FileRead File, %A_DD%%A_MM%.hell    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 90 ; 7min
{
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000               
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.hell
      goto linereadhell
        }
      goto password
      goto winkiller
      }
      
      }
}
return


linereadball:
FileRead File, %A_DD%%A_MM%.ball    
StringReplace File, File, `n, `n, All UseErrorLevel
summe = %ErrorLevel%

if summe >= 160 ; 15min
{
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000
soundbeep 100,100
sleep, 10000               
goto winkiller
return
}

sleep, 10000
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
      if lname = %lnamecon%
   
      {
      
         fileappend, `n%A_NOW%---%lnamecon%, %A_DD%%A_MM%.ball
      goto linereadball
        }
      goto password
      goto winkiller
      }
      
      }
}
return



winkiller:
listres = D:
mydrive := listres
total := EnumProcesses( pid_list )
loop, parse, pid_list, |
{
      lname := GetModuleFileNameEx( A_LoopField )
      If lname<>
      {                 
        ; use splitpath to obtain drive letter of each app:     
        SplitPath, lname, , , , , Drive

        ; close the program if drive matches:
        if Drive = %mydrive%
        {
      
          WinClose, ahk_pid %A_LoopField%
          Process, WaitClose, %A_LoopField%, 4
        soundbeep, 100,1000
          If (ErrorLevel)
          {
            Process, Close, %A_LoopField%
            Process, WaitClose, %A_LoopField%, 4
            If (ErrorLevel)
              MsgBox, %lname% is not responding. `nPlease manually close this application
          }
        }
      }
}
return

EnumProcesses( byref r_pid_list )
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return, false
   }
   
   pid_list_size := 4*1000
   VarSetCapacity( pid_list, pid_list_size )
   
   status := DllCall( "psapi.dll\EnumProcesses", "uint", &pid_list, "uint", pid_list_size, "uint*", pid_list_actual )
   if ( ErrorLevel or !status )
      return, false
       
   total := pid_list_actual//4

   r_pid_list=
   address := &pid_list
   loop, %total%
   {
      r_pid_list := r_pid_list "|" ( *( address )+( *( address+1 ) << 8 )+( *( address+2 ) << 16 )+( *( address+3 ) << 24 ) )
      address += 4
   }
   
   StringTrimLeft, r_pid_list, r_pid_list, 1
   
   return, total
}

GetModuleFileNameEx( p_pid )
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return
   }

   h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid )
   if ( ErrorLevel or h_process = 0 )
      return
   
   name_size = 255
   VarSetCapacity( name, name_size )
   
   result := DllCall( "psapi.dll\GetModuleFileNameExA", "uint", h_process, "uint", 0, "str", name, "uint", name_size )
   
   DllCall( "CloseHandle", h_process )
   
   return, name
}
Nach oben
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1893
Wohnort: Österreich

BeitragVerfasst am: Do Apr 27, 2006 5:13 am    Titel: Antworten mit Zitat

Ich hab mir das Game bereits geladen.
Bin aber noch nicht dazu gekommen das Script zu testen.
Ich habs aber nicht vergessen Wink

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe! Alle Zeiten sind GMT
Gehe zu Seite 1, 2, 3  Weiter
Seite 1 von 3

 
Gehe zu:  
Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.


Powered by phpBB © 2001, 2005 phpBB Group
Deutsche Übersetzung von phpBB.de