|
You last visited: Today at 11:56
Advertisement
[Autoit]Help
Discussion on [Autoit]Help within the AutoIt forum part of the Coders Den category.
01/23/2016, 17:28
|
#1
|
elite*gold: 26
Join Date: Jan 2016
Posts: 47
Received Thanks: 234
|
[Autoit]Process Suspender Probleme
Can Someone help me on my process Suspender!?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\client\pictures\sus.kxf
$Form1_1 = GUICreate("", 331, 145, 329, 285, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GR OUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("Suspend S4Client", 120, 48, 99, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Resume S4Client", 120, 80, 99, 25, $WS_GROUP)
$process = GUICtrlCreateInput("Process Name!", 112, 16, 121, 21)
$Label1 = GUICtrlCreateLabel("Created By Dexinion", 96, 112, 148, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
Func _ProcessSuspend($process)
$processid2 = ProcessExists($process)
If $processid Then
$ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
$i_sucess = DllCall("ntdll.dll","int","NtSuspendProcess","int" ,$ai_Handle[0])
DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
If IsArray($i_sucess) Then
Return 1
Else
SetError(1)
Return 0
Endif
Else
SetError(2)
Return 0
Endif
EndFunc
Case $button2
Func _ProcessResume($process)
$processid1 = ProcessExists($process)
If $processid Then
$ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
$i_sucess = DllCall("ntdll.dll","int","NtResumeProcess","int", $ai_Handle[0])
DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
If IsArray($i_sucess) Then
Return 1
Else
SetError(1)
Return 0
Endif
Else
SetError(2)
Return 0
Endif
EndSwitch
WEnd
|
|
|
01/23/2016, 19:00
|
#2
|
elite*gold: 5
Join Date: Feb 2014
Posts: 654
Received Thanks: 1,857
|
First of all, it's not yours. It's just a simple source you copied.
Second, try reading the error line, it will help alot even if the solution or problem is **** simple.
|
|
|
01/23/2016, 20:36
|
#3
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Quote:
Originally Posted by Deverixz
First of all, it's not yours. It's just a simple source you copied.
Second, try reading the error line, it will help alot even if the solution or problem is **** simple.
|
^this and besides try using a better thread title. "Help" doesn't give any relevant information about your problem.
|
|
|
01/24/2016, 01:45
|
#4
|
elite*gold: 20
Join Date: Mar 2015
Posts: 2,206
Received Thanks: 759
|
ja ne. wenn man die funcs in die while donnert isset ja auch kein wunder das dein script nicht funkt. wenn du schon dir dein source zamm klaust dann mach es doch vernünftig.
isset eig noch erlaubt mit #request4ban oder so? wenn ja würde ich das machen. wenn nicht beachtet das einfach garnicht.
|
|
|
01/29/2016, 16:28
|
#5
|
elite*gold: LOCKED
Join Date: Oct 2014
Posts: 1,258
Received Thanks: 12,469
|
*** 1337 0815 hexz coder (c++,c# and autoit) pro coder who doesnt copy paste ****.
Mind checking the error line? *** ur being so pro at checking variables on the error line.
Edit : why the **** you are placing the udf inside while, looks lame.
|
|
|
01/29/2016, 18:05
|
#6
|
elite*gold: 0
Join Date: Dec 2015
Posts: 79
Received Thanks: 107
|
Code:
╚►C++/C#/Autoit[Coder]◄╝
Says alot..
|
|
|
01/30/2016, 11:24
|
#7
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
First of all when i puted this code in autoit i get few errors, then i try it it dont work, so here u go working one.
Btw for start process from windows itself u can do it with ShellExecute or Run commands, but in your case u need path to the game exe file so u can start it only with process name because its not in windows core.
Best solution will be to just add 1 more button so u can add path to exe file then write it in ini file or registry and save it when u exit program.
Then when u load program again make function to read registry or ini file where u saved path to game and u will be able to start game from button.
U can test with explorer.exe shut it down and turn back up with button.
Code:
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1_1 = GUICreate("", 331, 145, 329, 285)
$Button1 = GUICtrlCreateButton("Suspend S4Client", 120, 48, 99, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Resume S4Client", 120, 80, 99, 25, $WS_GROUP)
$process = GUICtrlCreateInput("Process Name!", 112, 16, 121, 21)
$Label1 = GUICtrlCreateLabel("Created By Dexinion", 96, 112, 148, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
_ProcessSuspend($process)
Case $button2
_ProcessResume($process)
EndSwitch
WEnd
Func _ProcessSuspend($process)
#cs
Error messages
Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 = OpenProcess failed
2 = AdjustTokenPrivileges Failed
3 = TerminateProcess Failed
4 = Cannot verify if process exists
@extended: sets to Windows API GetLastError()
#ce
$process_name = GUICtrlRead($process) ; read process name from input
; check if process exists
If ProcessExists($process_name) Then
; close process
ProcessClose($process_name)
Else
; if any error show message with error number ( if u made this for yourself only leave it as it is, if its for others put friendly user message )
MsgBox(0, "Info", "There was a error" & @CRLF & "Error " & @error & ", " & @extended)
EndIf
EndFunc
Func _ProcessResume($process)
$process_name = GUICtrlRead($process) ; read process name from input
ShellExecute($process_name)
EndFunc
If u make it for yourself only
Code:
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 285, 55, 192, 124)
$Button1 = GUICtrlCreateButton("Start S4 League ", 27, 16, 107, 25)
$Button2 = GUICtrlCreateButton("Close S4 League ", 151, 16, 107, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_ProcessResume()
Case $Button2
_ProcessSuspend()
EndSwitch
WEnd
Func _ProcessSuspend()
$process_name = "S4league.exe" ; change this to right one, i dont know process name
If ProcessExists($process_name) Then ProcessClose($process_name)
EndFunc
Func _ProcessResume()
$path_to_game = "C:\Program Files\S4league\S4league.exe" ; change this to yours game path
ShellExecute($path_to_game)
EndFunc
|
|
|
All times are GMT +1. The time now is 11:56.
|
|