Hi I am using a function where it should when clicked on the hotkey enable but if it is enabled disable . My code desnt do this F1 hotkey enables only never disables and second hotkey F2 does only the oposit what F1 does just one time. Here is my use of code

Code:
HotKeySet('{F1}', "Function1")
$Function1=1
$Function1_OFFSET=1

Func Function1()
if $Function1=1 then
$PROCESS = _Process_Open("test.exe", $PROCESS_ALL_ACCESS, False)
$Function1 = _Process_WriteMemory($PROCESS, 0x00F93F59, $Function1_OFFSET, "byte")
$Label1 = GUICtrlCreateLabel("F1 Function1                                [ENABLED]", 16, 8, 264, 16)
GUICtrlSetColor(-1, 0xff0000)
MsgBox(6, "hhh", "enabled")
_Process_Close($PROCESS)
ElseIf $Function1=0 Then
$PROCESS = _Process_Open("test.exe", $PROCESS_ALL_ACCESS, False)
$Function1 = _Process_WriteMemory($PROCESS, 0x00F93F59, $Function1_OFFSET2, "byte")
$Label1 = GUICtrlCreateLabel("F1 Function1                                [DISABLED]", 16, 8, 264, 16)
MsgBox(6, "hhh", "disabled")
GUICtrlSetColor(-1, 0x008080)
_Process_Close($PROCESS)
EndIf
EndFunc