Jump to content

Bilgisayar Kapanırken Işlem Yaptırma


mesale0077
 Share

Recommended Posts

OnAutoItExitRegister("_Shutdown")

Local $Form1 = GUICreate("Form1", 400, 200)
GUISetState(@SW_SHOW)
Do
	Sleep(50)
Until GUIGetMsg() = -3

Func _Shutdown()
	Switch @exitMethod
		Case 0
			MsgBox(64, "Info:", 'Natural closing.')
		Case 1
			MsgBox(64, "Info:", 'close by Exit function.')
		Case 2
			MsgBox(64, "Info:", 'close by clicking on exit of the systray.')
		Case 3
			MsgBox(64, "Info:", 'close by user logoff.')
		Case 4
			MsgBox(64, "Info:", 'close by Windows shutdown.')
	EndSwitch
EndFunc   ;==>_Shutdown

Kolay gelsin....
Link to comment
Share on other sites

pc kapattığımız da yada yeniden başlatırken işlem yaptıracağım ama işlem bitincede pc kapanması lazım

 

 

mesala

takılı usb oldugunu uyarması

temp klasörünü temizleme 

yada pc kapanma saat gibi logu tutma gibi işlemler yapmak istiyorum

bir örnek paylaşırmısın

uygun kodlardan hangisini önerirseniz

Edited by mesale0077
Link to comment
Share on other sites

Ikinci koda daha önce bakmıştım ve pc ayarlarını bozmaz... Neyse sana sade bir örnek vereyim, sen biraz kurcalarsın.
Benim kaçmam gerekiyor, kolay gelsin...

Global $ShutDown = False
_shutdown_block()

While 1
	Sleep(100)
	If $ShutDown = True Then
		MsgBox(64,"Blue_Test","Istediğin kodları ekleyip sonra autoit ile bilgisayarı kapatabilirsin. vs. vs.")
		Shutdown(5)
	EndIf
WEnd

Func _shutdown_block()
	Local $shgui = GUICreate("", 5, 5, -100, -100)
	If NOT _setprocessshutdownparameters(4095) Then
		If NOT _setprocessshutdownparameters(1279) Then
			_setprocessshutdownparameters(1023)
		EndIf
	EndIf
	GUIRegisterMsg(17, "Cancel_Shutdown")
	DllCall("User32.dll", "int", "ShutdownBlockReasonCreate", "int", $shgui, "wstr", "Blue Test...")
	DllCall("kernel32.dll", "int", "SetThreadExecutionState", "int", BitOR(-2147483648, 2, 1))
EndFunc

Func cancel_shutdown($hwndgui, $msgid, $wparam, $lparam)
	If $ShutDown = False Then
		$ShutDown = True
		Return False
	EndIf
	Return True
EndFunc

Func _setprocessshutdownparameters($dwlevel, $dwflags = 0)
	Local $aresult = DllCall("Kernel32.dll", "int", "SetProcessShutdownParameters", "dword", $dwlevel, "dword", $dwflags)
	If @error Then Return SetError(1, 0, 0)
	Return $aresult[0]
EndFunc

Link to comment
Share on other sites

Ikinci koda daha önce bakmıştım ve pc ayarlarını bozmaz... Neyse sana sade bir örnek vereyim, sen biraz kurcalarsın.
Benim kaçmam gerekiyor, kolay gelsin...

Global $ShutDown = False
_shutdown_block()

While 1
	Sleep(100)
	If $ShutDown = True Then
		MsgBox(64,"Blue_Test","Istediğin kodları ekleyip sonra autoit ile bilgisayarı kapatabilirsin. vs. vs.")
		Shutdown(5)
	EndIf
WEnd

Func _shutdown_block()
	Local $shgui = GUICreate("", 5, 5, -100, -100)
	If NOT _setprocessshutdownparameters(4095) Then
		If NOT _setprocessshutdownparameters(1279) Then
			_setprocessshutdownparameters(1023)
		EndIf
	EndIf
	GUIRegisterMsg(17, "Cancel_Shutdown")
	DllCall("User32.dll", "int", "ShutdownBlockReasonCreate", "int", $shgui, "wstr", "Blue Test...")
	DllCall("kernel32.dll", "int", "SetThreadExecutionState", "int", BitOR(-2147483648, 2, 1))
EndFunc

Func cancel_shutdown($hwndgui, $msgid, $wparam, $lparam)
	If $ShutDown = False Then
		$ShutDown = True
		Return False
	EndIf
	Return True
EndFunc

Func _setprocessshutdownparameters($dwlevel, $dwflags = 0)
	Local $aresult = DllCall("Kernel32.dll", "int", "SetProcessShutdownParameters", "dword", $dwlevel, "dword", $dwflags)
	If @error Then Return SetError(1, 0, 0)
	Return $aresult[0]
EndFunc

 

 

hocam izniniz olursa bu şekilde değiştirdim 

kodda küçük bir sorun oluşmuştu 

şu şekil yapınca düzeldi 

çok sağolun  yardımlarınız için

bu şekil sorunsuz bende çalışmaktadır 

 

Global $ShutDown = False
Local $shgui = GUICreate("", 5, 5, -100, -100)
GUISetSTate(@SW_HIDE)
_shutdown_block()
 
While 1
	Sleep(100)
	If $ShutDown = True Then
		MsgBox(64,"Blue_Test","Istediğin kodları ekleyip sonra autoit ile bilgisayarı kapatabilirsin. vs. vs.")
				_ShutdownBlockReasonDestroy($shgui)
		Shutdown(5)
		exit 
	EndIf
WEnd
 
Func _shutdown_block()
	
	If NOT _setprocessshutdownparameters(4095) Then
		If NOT _setprocessshutdownparameters(1279) Then
			_setprocessshutdownparameters(1023)
		EndIf
	EndIf
	GUIRegisterMsg(17, "Cancel_Shutdown")
	DllCall("User32.dll", "int", "ShutdownBlockReasonCreate", "int", $shgui, "wstr", "Blue Test...")
	DllCall("kernel32.dll", "int", "SetThreadExecutionState", "int", BitOR(-2147483648, 2, 1))
EndFunc
 
Func cancel_shutdown($hwndgui, $msgid, $wparam, $lparam)
	If $ShutDown = False Then
		$ShutDown = True
		Return False
	EndIf
	Return True
EndFunc
 
Func _setprocessshutdownparameters($dwlevel, $dwflags = 0)
	Local $aresult = DllCall("Kernel32.dll", "int", "SetProcessShutdownParameters", "dword", $dwlevel, "dword", $dwflags)
	If @error Then Return SetError(1, 0, 0)
	Return $aresult[0]
EndFunc

Func _ShutdownBlockReasonDestroy($hWnd)
	Local $aResult = DllCall("User32.dll", "int", "ShutdownBlockReasonDestroy", "hwnd", $hWnd)
	If @error Then Return SetError(1, 0, 0)
	Return $aResult[0]
EndFunc   ;==>_ShutdownBlockReasonDestroy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...