Results 1 to 17 of 17

Thread: Userinit replacement for Win7...

  1. #1
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526

    Userinit replacement for Win7...

    This script is src for autohotkey.
    You "need the compiled exe" for this to work as a replacement for userinit.exe.
    The ahk script that this code is, won't work in the src form at that stage of bootup.
    You can copy the exe anywhere, but to use it you should change this:

    Code:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
    "Userinit"="C:\\Windows\\system32\\userinit.exe,"
    Update 3, 01/29/11:
    Added notrayincon and fixed loading of uxsms.
    I used winwait on the uxsms loading part to ensure it was done correctly on every boot on diff systems.
    I may have to do the same for some of the reg key's later, programs like network indicator monitor don't work right unless explorer has been loaded up 100% before it loads up.

    This program does not stay resident, and bootup speed has been increased from ver2.

    Update 4, 02/02/11:
    Fixed up loading file types for the programs\startup folder.
    Now it only loads up: com, exe, bat, vbs, js and ahk files.
    (Before it would load anything other then the desktop.ini file)

    I still have to do the same for the other startup sections.
    And add some sort of delay for loading these sections, it's still to fast and screws up "some" programs at startup (my network monitor in the post below and "network indicator monitor")

    Update 5x..., 04/23/11
    Been a while, I updated this along time ago, I figured I'de post the new code.
    Can't remember what I changed though, probably some win2k3 fixes and such.

    Code:
    #NoTrayIcon
    #SingleInstance, Force
    #MaxMem 1
    #MaxThreads 3
    
    if A_OSVersion = WIN_7
    {
    	Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    
    	Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    
    	Run "%windir%\explorer.exe"
    	;Sleep, 1000
    
    	;Fix for bypassing Stock Userinit...
    	RunWait %ComSpec% /C "net stop UxSms",, Hide
    	Run %ComSpec% /C "net start UxSms",, Hide
    
    	Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    
    	Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    
    	Loop, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    
    
    	FileList =
    	Loop, %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.*
    	{
    		FileList = %FileList%%A_LoopFileName%`n
    		Sort, FileList, R
    		Loop, parse, FileList, `n
    		{
    			if (A_LoopFileExt = "EXE" || A_LoopFileExt = "COM" || A_LoopFileExt = "BAT" || A_LoopFileExt = "VBS" || A_LoopFileExt = "JS" || A_LoopFileExt = "AHK")
    			{
    ;				MsgBox "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\%A_LoopField%"
    				Run "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\%A_LoopField%"
    			}
    			break
    		}
    	}
    
    	Loop, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\RunOnce, 0, 0
    	{
    		if A_LoopRegType = REG_SZ
    		{
    			RegRead, OutputVar
    			Run "%OutputVar%",, UseErrorLevel
    			if ErrorLevel = ERROR
    			{
    			}
    		}
    	}
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe off 16", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    }
    else if A_OSVersion = WIN_2003
    {
    	;win2k3 doesn't need extra code to parse startup stuffs, except for the extra file ext's...
    
    	Run "%windir%\explorer.exe"
    	;Sleep, 1000
    
    	;odd issue..., the loop file ext thingy is not working for some unknown reason...
    	;so for now, screw it, run all ext's
    	FileList =
    	Loop, %USERPROFILE%\Start Menu\Programs\Startup\*.*
    	{
    		FileList = %FileList%%A_LoopFileName%`n
    		Sort, FileList, R
    		Loop, parse, FileList, `n
    		{
    ;			if (A_LoopFileExt = "EXE" || A_LoopFileExt = "COM" || A_LoopFileExt = "BAT" || A_LoopFileExt = "VBS" || A_LoopFileExt = "JS" || A_LoopFileExt = "AHK")
    			if (A_LoopFileExt = "AHK")
    			{
    ;				MsgBox "%USERPROFILE%\Start Menu\Programs\Startup\%A_LoopField%"
    				Run "%USERPROFILE%\Start Menu\Programs\Startup\%A_LoopField%"
    			}
    			break
    		}
    	}
    
    	;Issue with win2k3, access denide error if I run the code below before this...
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe off 16", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    	RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
    
    	;; installing deamontools doesn't work I dn which caused it
    
    	RunWait %ComSpec% /C "pskill smss.exe",, UseErrorLevel
    	if ErrorLevel = ERROR
    	{
    	}
    
    	;; Now is my chance to kill RpcSs
    	;; Find the PID for RpcSs and kill it
    	;; note this screws up paste, no longer works, greyed out
    	;; if I can redo the menu entry and remove this current one..., then maybe I can ungrey it
    	;tlst-mod|FINDSTR "^5.. svchost.exe$" > %TEMP%\PID-TEMP.txt
    	;SET /P PID_Temp=<%TEMP%\PID-TEMP.txt
    	;pskill %PID_Temp%
    
    	;; Print screen still works and so does paste in paint
    	;; the only thing that doesn't work is paste with files
    	;; because copy/paste in text files with text works fine
    	;; note also that delete files doesn't work ^^
    	;; but the cmd ver of del does work...
    	;; possible to replace, but...
    	;; I need to change the whatever it is that sets the generic cmds file each file type...
    	;; that might be alot of files, I dn how many it affects
    	;; but i think it might affect all ^^
    	;; then again, the right click context menu ver has allways been crappy compared to the cmd line ver anyways with certain files.
    	;; if I replaced it it would fix 2 things at once :)
    
    	;; how to do I use a var from multible batches and have it still work :\ ?
    	;; I guess the only way is with a temp file like the temp pid thing is right now unfortunately
    	;; so...
    	;; copy =
    	;; ECHO %1 > %TEMP%\Temp.txt 
    	;; paste =
    	;; copy < %TEMP%\Temp.txt %D
    	;;copy = get var1 in batch
    	;;paste = copy var1 in current folder like cmd from here or something
    
    	;; Causes you to need to use Ctrl_Alt_Del to Restart (Shutdown and logoff cmd line cmd's works but restart doesn't)
    	;; Bitspirit also complains that it's not able to auto shutdown
    	;; this also seems to remove my rights for shutting down certain key system services from the taskmgr and such
    
    	RunWait %ComSpec% /C "pskill lsass.exe",, UseErrorLevel
    	if ErrorLevel = ERROR
    	{
    	}
    
    	Sleep, 1000
    
    	;prevent shutdown from the above work...
    	Run %ComSpec% /C "shutdown.exe /a",, UseErrorLevel
    	if ErrorLevel = ERROR
    	{
    	}
    }
    Last edited by NEOAethyr; 04-23-2011 at 03:51 PM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  2. #2
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    A network status monitor tray icon thingy...

    Update 3, 01/29/11:
    Added tray icon tooltip.
    Added port viewer via tcpviewer (hard set location for now).
    Added change ip command.

    Added F12 hotkey function, hide taskbar -> unhide taskbar.

    Next steps:
    Add ini support.
    Add change gateway support.
    Add more menu options.
    Fix up/down rate and total value to be 100% correct, close enough for now but not 100%.
    Fix tooltip display of chnaging ip status, sometimes doesn't show up when changing ip.

    Integrate userinit replacement support and add options to enable and disable that mode, etc etc.

    Plus alot more.
    Once I'm 100% satisfied, I'll try to convert to asm.


    Update 4, 01/29/2011:
    Got ini file read support, some tray icon context menu stuffs.
    Etc etc...
    Oh and the start menu/toolbar mod thing works alot better not but still isn't quite 100%.

    Update 5, 01/30,2011:
    Greatly reduced latency of the network status monitor.
    It's now much faster then even the "network indicator monitor" program.
    Improved the taskbar toolbar mod, it's more responsive and no longer gives you probs with the ctrl key getting stuck on, at least as far as I can tell.
    Added new mod, disable aero peek, which of course is setable from the tray context menu.
    Added network connections link to the tray context menu.

    I have a few more things to do with it.
    And afterwards it's convert to asm time, soons...

    Update 6, 02/02/11:
    Added keyboard led network status support, selectable from context menu.
    Fixed giant mem leak, ended up being the internal variable %A_IPAddress%, so for now my program can't get your ip addy.
    I will work on that, but I will not be using the autohotkey internal variable for that anymore, not that one.
    Added double left click default to tray icon, opens port monitor program.
    Cleaned up some of the syntax of the code.
    Some more speed ups and less mem usage, well it is getting bigger as I add more things but I reduced the code a bit for some things and fixed that mem leak.

    Update 7x... 04/23/11
    I redid the code along time ago, today I comment a part out of it so I could test some stuff to the side too.
    Did some tweaking for win2k3 and some speedups.
    Might of taken the win2k3 code out of it though, not sure.

    Update 8, 04/26/11.
    Some code cleanups, and some improvements.
    Re-enable ip address stuff and so on, and minimized mem leaked associated with that.
    Also redid opera and firefix titlebar mod for single column and double column sized taskbar.
    Added taskbar single column sized mod (right or left side of screen).
    Etc etc.

    Update 9, 05/14/11.
    Added new setting called "User Timer QSR Max".
    I didn't add every value that it could be set to as of yet , soon though.
    When ran the program auto sets to 0.5ms, I'lll have it parse the ini for info on it later instead of just setting it to what I want on startup.
    I have a few more ideas to integrate into this program so expect a few more ver's to come .

    The src inspiration for the network monitor code here is from: (2nd code box...)
    http://www.autohotkey.com/forum/topi...8e795b11584371

    The src inspiration for the taskbar hide/show code is from here (last code box on 1st page):
    http://www.autohotkey.com/forum/topi...69d56ffd7b8793

    Src inspiration for keyboard led code form here (1st post):
    http://www.autohotkey.com/forum/topic10532.html

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; NEO_nTray (NEO's Network Tray Tool)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;; Notes:
    ;
    ; %A_IPAddress1% Leaks massive amounts of memory, DO NOT use it!!!
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    ;Sleep 1000
    ;ElapsedTime_ms := (A_TickCount - StartTime)
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, %ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Entry Point
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    #Persistent
    #SingleInstance, Force
    #MaxMem 1
    #MaxThreads 3
    SetBatchLines -1
    Process, Priority,, BelowNormal
    Menu, Tray, NoStandard						;Disable Standard AHK Menu Entries
    SetTitleMatchMode, 2
    
    GoSub Init
    
    StartTime := A_TickCount					;Internal Var, MS Timer
    ElapsedTime_ms := (A_TickCount - StartTime)
    
    SetTimer, Burn_Cycle, %Main_Loop_Timing%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Functions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    Set_User_Timer_QSR_05:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    return
    
    Set_User_Timer_QSR_1:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    return
    
    Set_User_Timer_QSR_10:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    return
    
    Set_User_Timer_QSR_156:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    return
    
    
    Set_Tray_Icons_Default:
    Network_Icons_Use_Default = Enable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    return
    
    Set_Tray_Icons_Custom:
    Network_Icons_Use_Default = Disable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    return
    
    
    Set_Network_Use_Keyboard_Leds_Disable:
    Network_Use_Keyboard_Leds = Disable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    GetKeyState, KeyState, ScrollLock, T	;Bug fix for threading issues, so non of the leds end up getting stuck on...
    if KeyState = U
    {
    	KeyboardLED(1, "Off")
    }
    GetKeyState, KeyState, CapsLock, T
    if KeyState = U
    {
    	KeyboardLED(4, "Off")
    }
    ;GetKeyState, KeyState, NumLock, T
    ;if KeyState = U
    ;{
    ;	KeyboardLED(2, "Off")
    ;}
    return
    
    Set_Network_Use_Keyboard_Leds_Enable:
    Network_Use_Keyboard_Leds = Enable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_QuickLaunch_Mod_Disable:
    QuickLaunch_Mod = Disable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    return
    
    Set_QuickLaunch_Mod_Enable:
    QuickLaunch_Mod = Enable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_Aero_Peek_Disable:
    Aero_Peek = Disable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    Control, Disable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    Set_Aero_Peek_Enable:
    Aero_Peek = Enable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    Control, Enable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    
    Win7_Taskbar_Mod:
    RunWait %ComSpec% /C "net stop UxSms",, Hide			;Stop UxSms
    DetectHiddenWindows, On						;Enable Taskbar Autohide
    VarSetCapacity(APPBARDATA, 36, 0)				;Var mem limit
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    WinHide ahk_class Shell_TrayWnd
    RunWait %ComSpec% /C "net start UxSms",, Hide			;Restart UxSms
    NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")	;Disable Taskbar Autohide
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    WinShow ahk_class Shell_TrayWnd
    Reload								;Needed to refresh the desktop width var...
    return
    
    
    ;;; Network Monitor Functions:
    
    GetIfTable(ByRef tb, Border = True)
    {
    	nSize := 4 + 860 * GetNumberOfInterfaces() + 8	;Var mem limit calc
    	VarSetCapacity(tb, nSize)			;Var mem limit
    	Return DllCall("iphlpapi\GetIfTable", "Uint", &tb, "UintP", nSize, "int", Border)
    }
    
    GetNumberOfInterfaces()
    {
    	DllCall("iphlpapi\GetNumberOfInterfaces", "UintP", nIf)
    	Return nIf
    }
    
    DecodeInteger(ptr)
    {
    	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    }
    
    
    ;notes:
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;
    ;  DWORD dwInUcastPkts;
    ;  DWORD dwInNUcastPkts;
    ;  DWORD dwInDiscards;
    ;  DWORD dwInErrors;
    ;  DWORD dwInUnknownProtos;
    ;  DWORD dwOutOctets;
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    
    ;;; Keyboard LED Functions:
    
    KeyboardLED(LEDvalue, Cmd)	;LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4, Cmd = On / Off
    {
    	Static h_device
    	If ! h_device		;initialise
    	{
    		device =\Device\KeyBoardClass0
    		SetUnicodeStr(fn, device)
    		h_device := NtCreateFile(fn, 0 + 0x00000100 + 0x00000080 + 0x00100000, 1, 1, 0x00000040 + 0x00000020, 0)
    	}
    
    	VarSetCapacity(output_actual, 4, 0)
    	input_size = 4
    	VarSetCapacity(input, input_size, 0)
    
    	If Cmd = On		;forces all choosen LED's to ON (LEDvalue = 0 -> LED's according to keystate)
    	{
    		KeyLED := LEDvalue | (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	If Cmd = Off		;forces all choosen LED's to OFF (LEDvalue = 0 -> LED's according to keystate)
    	{
    		LEDvalue := LEDvalue ^ 7
    		KeyLED := LEDvalue & (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	;EncodeInteger(KeyLED, 1, &input, 2)	;input bit pattern (KeyLED): bit 0 = scrolllock, bit 1 = numlock, bit 2 = capslock
    	input := Chr(1) Chr(1) Chr(KeyLED)
    	input := Chr(1)
    	success := DllCall("DeviceIoControl", "uint", h_device, "uint", CTL_CODE(0x0000000B, 2, 0, 0), "uint", &input, "uint", input_size, "uint", 0, "uint", 0, "uint", &output_actual, "uint", 0)
    }
    
    CTL_CODE(p_device_type, p_function, p_method, p_access)
    {
    	Return, (p_device_type << 16) | (p_access << 14) | (p_function << 2) | p_method
    }
    
    NtCreateFile(ByRef wfilename, desiredaccess, sharemode, createdist, flags, fattribs)
    {
    	VarSetCapacity(fh, 4, 0)
    	VarSetCapacity(objattrib, 24, 0)
    	VarSetCapacity(io, 8, 0)
    	VarSetCapacity(pus, 8)
    	uslen := DllCall("lstrlenW", "str", wfilename) * 2
    	InsertInteger(uslen, pus, 0, 2)
    	InsertInteger(uslen, pus, 2, 2)
    	InsertInteger(&wfilename, pus, 4)
    	InsertInteger(24, objattrib, 0)
    	InsertInteger(&pus, objattrib, 8)
    	status := DllCall("ntdll\ZwCreateFile", "str", fh, "UInt", desiredaccess, "str", objattrib, "str", io, "UInt", 0, "UInt", fattribs, "UInt", sharemode, "UInt", createdist, "UInt", flags, "UInt", 0, "UInt", 0, "UInt")
    	return % ExtractInteger(fh)
    }
    
    SetUnicodeStr(ByRef out, str_)
    {
    	VarSetCapacity(st1, 8, 0)
    	InsertInteger(0x530025, st1)
    	VarSetCapacity(out, (StrLen(str_) + 1) * 2, 0)
    	DllCall("wsprintfW", "str", out, "str", st1, "str", str_, "Cdecl UInt")
    }
    
    ;pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
    ;The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
    ;pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
    ;pSource must be ByRef to avoid corruption during the formal-to-actual copying process
    ;(since pSource might contain valid data beyond its first binary zero).
    ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
    {
    	Loop %pSize%								;Build the integer by adding up its bytes.
    	result += *(&pSource + pOffset + A_Index - 1) << 8 * (A_Index - 1)
    	if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
    	return result								;Signed vs. unsigned doesn't matter in these cases.
    	return -(0xFFFFFFFF - result + 1)					;Otherwise, convert the value (now known to be 32-bit) to its signed counterpart
    }
    
    ;The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest, 
    ;only pSize number of bytes starting at pOffset are altered in it. 
    InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
    {
    	Loop %pSize%								;Copy each byte in the integer into the structure as raw binary data.
    	DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8 * (A_Index - 1) & 0xFF)
    }
    
    
    ;;; Hotkeys
    
    F12::		;Show / Hide Taskbar
    {
    	If TaskBar_State = Hidden
    	{
    		NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinShow ahk_class Shell_TrayWnd
    		TaskBar_State = Visable
    	}
    	else
    	{
    		DetectHiddenWindows, On
    		VarSetCapacity(APPBARDATA, 36, 0)	;var mem limit
    		NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinHide ahk_class Shell_TrayWnd
    		TaskBar_State = Hidden
    	}
    }
    
    ;Disable for now
    ;#t::		;Show / Hide Active Toolbar
    ;{
    ;	WinSet, Style, ^0xC00000, A
    ;}
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Burn_Cycle
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Burn_Cycle:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    
    if IP_Change = 0		;cludge for multi threading
    {
    	GoSub Network_Monitor
    }
    
    if QuickLaunch_Mod = Enable
    {
    	GoSub QuickLaunch_Mod
    }
    
    ;Opera title bar remover mod
    IfWinActive, - Opera
    {
    	WinSet, Style, -0xC00000, - Opera
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Opera,, -3, -3, %Desktop_Width%, %Desktop_Height%,,	;Slowdown Part..
    	}
    }
    
    ;Firefox title bar remover mod
    IfWinActive, - Mozilla Firefox
    {
    	WinSet, Style, -0xC00000, - Mozilla Firefox
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Mozilla Firefox,, -3, -3, %Desktop_Width%, %Desktop_Height%,,
    	}
    }
    
    ;Download_Rate_Secs := Round(Download_Rate * (((A_TickCount - StartTime) / 1000), 1))
    ;Upload_Rate_Secs := Round(Upload_Rate * (((A_TickCount - StartTime) / 1000), 1))
    
    ;needs null check...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	Menu, Tray, Tip, Disconnected
    }
    else
    {
    	Menu, Tray, Tip, IP: %IP_Address%`nDownload Rate: %Download_Rate% K`nUpload Rate: %Upload_Rate% K`nDownloaded Total: %Downloaded_Total% K`nUploaded Total: %Uploaded_Total% K
    }
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, Burn_Cycle:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Read_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Read_Cfg:
    
    IniRead, Main_Loop_Timing, %A_ScriptDir%\NEO_nTray.ini, Main, Main_Loop_Timing
    
    IniRead, Aero_Peek, %A_ScriptDir%\NEO_nTray.ini, Extra, Aero_Peek
    IniRead, QuickLaunch_Mod, %A_ScriptDir%\NEO_nTray.ini, Extra, QuickLaunch_Mod
    IniRead, TaskBar_State, %A_ScriptDir%\NEO_nTray.ini, Extra, TaskBar_State
    
    IniRead, Port_Viewer, %A_ScriptDir%\NEO_nTray.ini, App_Locations, Port_Viewer
    
    IniRead, Network_Icons_Use_Default, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Use_Default
    IniRead, Network_Icons_Custom_1, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_1
    IniRead, Network_Icons_Custom_2, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_2
    IniRead, Network_Icons_Custom_3, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_3
    IniRead, Network_Icons_Custom_4, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_4
    IniRead, Network_Icons_Custom_5, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_5
    IniRead, Network_Use_Keyboard_Leds, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Use_Keyboard_Leds
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main Menu
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu:
    
    Menu, Menu_Settings_Tray_Icon, add, Default, Set_Tray_Icons_Default
    Menu, Menu_Settings_Tray_Icon, add, Custom, Set_Tray_Icons_Custom
    Menu, Menu_Settings, add, Tray Icon, :Menu_Settings_Tray_Icon
    Menu, Menu_Settings, Icon, Tray Icon, shell32.dll, 303				;not good in win2k3
    
    Menu, Menu_Settings_Keyboard_Leds, add, Disable, Set_Network_Use_Keyboard_Leds_Disable
    Menu, Menu_Settings_Keyboard_Leds, add, Enable, Set_Network_Use_Keyboard_Leds_Enable
    Menu, Menu_Settings, add, Keyboard LEDs, :Menu_Settings_Keyboard_Leds
    Menu, Menu_Settings, Icon, Keyboard LEDs, main.cpl, 6
    
    Menu, Menu_Settings, add
    
    Menu, Menu_Settings_QuickLaunch_Mod, add, Disable, Set_QuickLaunch_Mod_Disable
    Menu, Menu_Settings_QuickLaunch_Mod, add, Enable, Set_QuickLaunch_Mod_Enable
    Menu, Menu_Settings, add, QuickLaunch Mod, :Menu_Settings_QuickLaunch_Mod
    Menu, Menu_Settings, Icon, QuickLaunch Mod, shell32.dll, 40
    
    Menu, Menu_Settings_Aero_Peek, add, Disable, Set_Aero_Peek_Disable
    Menu, Menu_Settings_Aero_Peek, add, Enable, Set_Aero_Peek_Enable
    Menu, Menu_Settings, add, Aero Peek, :Menu_Settings_Aero_Peek
    Menu, Menu_Settings, Icon, Aero Peek, shell32.dll, 40
    
    Menu, Menu_Settings, add, Win7 Taskbar Mod, Win7_Taskbar_Mod
    Menu, Menu_Settings, Icon, Win7 Taskbar Mod, shell32.dll, 40
    
    Menu, Menu_Settings, add
    
    ;I woud prefer to have ahk's built in help function right here, but I can't figuer out the code for it
    
    Menu, User_Timer_QSR, add, 0.5 ms, Set_User_Timer_QSR_05
    Menu, User_Timer_QSR, Icon, 0.5 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 1 ms, Set_User_Timer_QSR_1
    Menu, User_Timer_QSR, Icon, 1 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 10 ms, Set_User_Timer_QSR_10
    Menu, User_Timer_QSR, Icon, 10 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 15.6 ms, Set_User_Timer_QSR_156
    Menu, User_Timer_QSR, Icon, 15.6 ms, shell32.dll, 13
    Menu, Menu_Settings, add, User Timer QSR Max, :User_Timer_QSR
    Menu, Menu_Settings, Icon, User Timer QSR Max, shell32.dll, 13
    
    Menu, Menu_Settings_Dev, add, Edit Script, Edit					;This should only be valid in script form, not in compiled form, I need to figuer that out...
    Menu, Menu_Settings_Dev, Icon, Edit Script, shell32.dll, 71
    Menu, Menu_Settings, add, Dev, :Menu_Settings_Dev
    Menu, Menu_Settings, Icon, Dev, shell32.dll, 161
    
    Menu, Tray, add, Port Viewer, Port_View
    Menu, Tray, Icon, Port Viewer, shell32.dll, 172
    
    Menu, Tray, add, Change IP, Change_IP
    Menu, Tray, Icon, Change IP, shell32.dll, 19
    
    Menu, Tray, add, Network Connections, Network_Connections
    Menu, Tray, Icon, Network Connections, shell32.dll, 89
    
    Menu, Tray, add
    
    Menu, Tray, Add, Settings, :Menu_Settings
    Menu, Tray, Icon, Settings, shell32.dll, 13
    
    Menu, Tray, add
    
    Menu, Tray, add, Reload, Reload
    Menu, Tray, Icon, Reload, shell32.dll, 239
    
    Menu, Tray, add, Pause, Pause			;This needs a better pause icon, and needs a play icon or whatever once paused
    Menu, Tray, Icon, Pause, shell32.dll, 110
    
    Menu, Tray, add
    
    Menu, Tray, add, Exit, Exit
    Menu, Tray, Icon, Exit, shell32.dll, 28
    
    Menu, Tray, Default, Port Viewer		;Default Entry to run on double click
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main_Menu_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu_Cfg:
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    }
    if Network_Icons_Use_Default = Disable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    }
    if Network_Use_Keyboard_Leds = Disable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    }
    
    
    if QuickLaunch_Mod = Disable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    }
    if QuickLaunch_Mod = Enable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    }
    
    if Aero_Peek = Disable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    }
    if Aero_Peek = Enable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    }
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Monitor:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    
    ;Needs null check too...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_5%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		GetKeyState, KeyState, ScrollLock, T
    		if KeyState = U
    		{
    			KeyboardLED(1, "Off")
    		}
    		GetKeyState, KeyState, CapsLock, T
    		if KeyState = U
    		{
    			KeyboardLED(4, "Off")
    		}
    		GetKeyState, KeyState, NumLock, T
    		if KeyState = U
    		{
    			KeyboardLED(2, "Off")
    		}
    	}
    
    	return
    }
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    
    GetIfTable(tb)
    
    ;notes:
    ;	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;		552?
    ;  DWORD dwInUcastPkts;		556?
    ;  DWORD dwInNUcastPkts;	560?
    ;  DWORD dwInDiscards;		564?
    ;  DWORD dwInErrors;		568?
    ;  DWORD dwInUnknownProtos;	572?
    ;  DWORD dwOutOctets;		576?
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    ;;Include this codes to exclude the loopback interface.
    ;;If DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 516) = 24
    ;;Continue
    Loop, % DecodeInteger(&tb)
    {
    	Download_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 552)	;Total Incoming Octets
    	Upload_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 576)	;Total Outgoing Octets
    }
    
    ;Needs odd colon char thingy to work...
    Download_Rate := Round(((Download_Rate_New - Download_Rate_Old) / 48), 1)		;Download rate calculation
    Upload_Rate := Round(((Upload_Rate_New - Upload_Rate_Old) / 48), 1)		;Upload rate calculation
    
    ;Offline Testing...
    ;if DL_Old = %Download_Rate%
    ;{
    ;	Download_Rate := Round((120.5 / 1024), 1)
    ;}
    ;if UP_Old = %Upload_Rate%
    ;{
    ;	Upload_Rate := Round((120.5 / 1024), 1)
    ;}
    ;DL_Old = %Download_Rate%
    ;UP_Old = %Upload_Rate%
    
    
    ;Needs odd syntax
    ;Needs a few microsecs of latency before lighting up the keyboard leds
    
    if (Download_Rate = 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 69, 1	;193, 0dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_1%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "Off")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 68, 1	;192, +dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_2%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    if (Download_Rate = 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 67, 1	;191, 0dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_3%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		Sleep, 1
    		KeyboardLED(1, "Off")
    		KeyboardLED(4, "On")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 66, 1	;190, +dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_4%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "On")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    
    
    ;Needs odd colon char to work...
    Downloaded_Total := Round(Download_Rate_New / 48)
    Uploaded_Total := Round(Upload_Rate_New / 48)
    
    Download_Rate_Old = %Download_Rate_New%
    Upload_Rate_Old = %Upload_Rate_New%
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    
    ;ToolTip, Network_Monitor:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    Return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; QuickLaunch_Mod
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    QuickLaunch_Mod:
    
    Mouse_State_LButton_Old = %Mouse_State_LButton%
    
    MouseGetPos,,,, Win32_Control
    GetKeyState, Mouse_State_LButton, LButton
    
    ;small issue with timing and mod, if I was previously over the toolbar and now on the taskbar with the sam etoolbar name, it takes a little while to reg to get rid of the ctrl key
    
    if A_OSVersion = WIN_7
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    else if A_OSVersion = WIN_2003
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    ;	if ((Win32_Control = "ToolbarWindow322") && Mouse_State_LButton = "D" || (Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    
    ;324...
    ;323 is the issue on win2k3 slim, taskbar becomes the other toolbar.
    ;323 is the one that works in win7
    ;322 is the one that works in win2k3
    
    ;I can either scan for the os or I can patch it out correctly
    ;1st one is the issue
    
    ;ToolbarWindow322	Win2k3 single col
    ;causes issues on win2k3, crtl gets stuck on the taskbar
    
    ;ToolbarWindow323	Win7 double col
    
    ;This code needs work, works great in win7, but it needs to be worked on in xp and win2k3
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Port_View
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Port_View:
    ;MsgBox, %Port_Viewer%
    Run %Port_Viewer%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Connections
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Connections:
    
    ;check to see if netman is enabled via reg, if so then don't run the special code below.
    ;If it is disabled at runtime, then run the special code below
    ;Would like to see a sub menu with net connections...
    
    ;Big prob, the thign creates a new proccess which I can't seem to track yet.
    ;So my script stops the netman service before exiting, or it keeps it in mem, both are not cool
    
    ;RunWait %ComSpec% /C "sc config netman start= demand",, Hide
    ;RunWait %ComSpec% /C "net start netman",, Hide
    
    Run ::{7007acc7-3202-11d1-aad2-00805fc1270e},,, Win32_PID
    ;WinWaitClose ahk_pid %Win32_PID%				;Doesn't actually work...
    
    ;RunWait %ComSpec% /C "net stop netman",, Hide
    ;RunWait %ComSpec% /C "sc config netman start= disabled",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Change_IP
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Change_IP:
    
    ;issue here if ip was originally null
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	return
    }
    
    IP_Old = %IP_Address%
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    Download_Rate_Old = 0
    Upload_Rate_Old = 0
    Downloaded_Total = 0
    Uploaded_Total = 0
    
    TrayTip, NEO_nTray, Changing IP...,, 16
    Menu, Tray, Tip, Changing IP...
    
    IP_Change = 1		;cludge for multi threading
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    }
    else
    {
    	Menu, Tray, Icon, %Network_Icons_Custom_5%
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    IP_Change_Count = 0
    
    
    
    While (A_IPAddress1 = IP_OLD)
    {
    	IP_Change_Count += 1
    
    	if IP_Change_Count = 10
    	{
    		TrayTip, NEO_nTray, I tried to change your IP but after %IP_Change_Count% attempts I gave up...,, 16
    		Sleep 3000	;Give the user 3 secs to read the msg...
    		Reload
    		return
    	}
    	else
    	{
    		RunWait %ComSpec% /C "IPCONFIG /RELEASE",, Hide
    		Sleep (1000 * %IP_Change_Count%)	;increase idle by 1sec per loop
    		RunWait %ComSpec% /C "IPCONFIG /RENEW",, Hide
    	}
    }
    
    
    
    TrayTip, NEO_nTray, Old IP Address: %IP_Old%`nNew IP Address: %A_IPAddress1%,, 16
    IP_Change = 0		;Cludge for multi-threading
    Sleep 3000		;Give the user 3 secs to read the msg...
    
    Reload			;Cludge for mem leak on A_IPAddress1, reload the whole darn program after getting a new ip, init should pick up the new ip
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Init
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Init:
    
    IP_Change = 0		;cludge for multi threading
    
    ;Try to reduce the mem leak as much as possible, and only call this once on init and not in the main loop, it won't beable to auto detect the ip at any given time but it should be good enough
    VarSetCapacity(IP_Address, 15, 0)				;Var mem limit
    VarSetCapacity(A_IP_Address, 15, 0)				;Var mem limit
    IP_Address = %A_IPAddress1%
    
    ;Hides the everything on the taskbar including it's self, but leaves the start button
    ;WinHide ahk_class Shell_TrayWnd
    
    GoSub Read_Cfg
    GoSub Main_Menu
    GoSub Main_Menu_Cfg
    
    if Aero_Peek = Enable
    {
    	GoSub Set_Aero_Peek_Enable
    }
    else
    {
    	GoSub Set_Aero_Peek_Disable
    }
    
    SysGet, Desktop_Width, 61
    SysGet, Desktop_Height, 62
    EnvSub, Desktop_Width, 2
    EnvSub, Desktop_Height, 2
    
    SysGet, Monitor_Width, 0
    SysGet, Monitor_Height, 1
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Edit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Edit:
    
    Edit
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Reload
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Reload:
    
    Reload
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Pause
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Pause:
    
    Pause
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Exit:
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    ExitApp
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Last edited by NEOAethyr; 05-14-2011 at 12:12 PM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  3. #3
    Xtreme Member danielkza's Avatar
    Join Date
    May 2009
    Location
    São Paulo, Brazil
    Posts
    315
    "That's why I'm using it, it lets me skip a file at bootup."

    How exactly? If your script does everything userinit.exe does and it's bigger, what are the advantages?

  4. #4
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Yes indeed the userinit replacement is bigger with this type of coding style.
    The reason for me was to fix the startup stuff in the reg and startup folder.

    It exits before you can run the taskmgr, so the system settles down quicker.
    Instead of waiting for userinit.exe to exit, which normally take a min, now it's not there when I start up.

    Other reasons were to improve on the functionality.
    Like having options to parse each reg run key, or the startup folder one by one.
    You could unselect which ones you didn't want to run, future wise.

    It's not something I have much use for.
    But if it were used on a clients system...
    You could one day goto work on it, check to see why it's so slow and unselect all those run entry types.
    And see if the system has issues with no startup programs or not without del'ing stuff out of the reg.

    Or a user could decide they don't want any type of startup programs running.
    And unselect all of the diff types.
    Or change the ini which in case of the user.ini non-stay resident ver, that would be the way to go.

    My plan is to integrate it with my new network monitoring tray program.
    So I have all the options in front of me in the tray menu.

    Of course it would have an option to stay resident or not...
    Giving it multiple uses.
    For some, a userinit replacement.
    For others, a network status program.
    And for certain peeps like me, both.

    Still gets rid of 1 exe for me, the network indicator program.
    And userinit is no longer in my list of processes waiting to exit after starting up.

    I'll keep working on it to bring up the functionality of the thing.
    Then once it's all done and tweaked out for performance as much as possible (multi threaded maybe, and not using a bunch of extra cycles for my net-mon prog).
    Then I'll work on duplicating the code in fasm.

    In which case, a stand alone userinit replacement done in asm would would be smaller then the original.

    This is to test functionality though for now.
    As a stand alone replacement for userinit I have use for it and I'm using it already.
    Since it's essentually only a script that doesn't hang out in mem for a min or 2.

    I'll work on the timing and everything else as time goes on.


    The main reason why I posted it.
    I think in the future it would have some merit with overclocking.
    If I can add flush to disk or free mem functionality I could get windows to act right on startup.
    Which you could bsod and not worry about trashing the os.

    Right now I use aida64, the benchmark in it to do that same thing.
    If I can skip that step when overclock stability testing, that would rock I think.
    And it could save alot of people's os'es from getting trashed if it is done right.


    The userinit code has a timing issue with net start and net stop at the end of the code, for the uxsms service.
    Ticks me off a little because sometimes uxsms don't get started back up.
    I have to fix it.
    Last edited by NEOAethyr; 01-28-2011 at 07:53 PM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  5. #5
    Xtreme Member danielkza's Avatar
    Join Date
    May 2009
    Location
    São Paulo, Brazil
    Posts
    315
    You write too much. I don't usually complain about that, but I just couldn't bear reading all that. You could've just said 'because I'd like to disable startup programs selectively' and be done with it. And do you have any evidence that userinit is what is actually delaying the boot?

    And I see no reason whatsoever for your network monitor to replace userinit.exe. Just make it a service, that's what they're meant for.

  6. #6
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Yeah I had a hard time reading through it when I was fixing typos lol.

    Userinit doesn't delay the bootup really.
    But it sticks around after bootup for a good min in win7.

    In win2k3 I think it stuck around for good if I remember right.

    As for the service comment, thought about that already .
    Would be nice to integrate into a set of services with svchost.
    Would be down yet another process on my setup.


    I got a tray tooltip working, shows:
    Download rate
    Upload rate
    Download total
    Upload total

    Next I'm gonna mod the context menu.
    Adding support for launching tcpviewer, and single click changing ip addresses and gateways.

    I know it sounds odd to replace userinit with some network status tray thing.
    It's just some ideas I'm playing with .

    Edit:
    Updated the above codes.
    I'm done messing with it tonight .
    Last edited by NEOAethyr; 01-29-2011 at 12:23 AM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  7. #7
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    My network monitor is now better then the alternatives, yay lol (kinda, it's faster but uses a bit more cycles and 3x the mem :O..., that won't be an issue once converted to a different format).

    Needs more work.
    Now I'm looking forward to converting this code to a better format.
    I want to get a few more things done with this and get this tweaked out.
    Then I'll work on converting it to asm to compile in a modded ver of fasm.

    If anyone here actually knows what autohotkey is and how to use it, check out my script please.
    Tell me what you think.

    I think it's getting there .
    I better get back to work on the userinit code though and finish that off...

    Edit:
    Mmm there's a mem leak in the network monitor code.
    In the actual network status part of it, I commented it out and have been testing, seems ok.

    I'll figure that out tonight.
    Seems that there's certain things in autohotkey that can cause mem leaks.

    The taskbar toolbar mod code is working great though.
    I haven't had a single prob so far.
    It's very nice to not have to hold the ctrl key down to bring a drop down menu from your quicklaunch...

    I also noticed that I have to calc the download/update rate baised on the polling rate that I'm using.
    Before the code was to slow so I had to make adjustments for that, now it's super fast and it says I'm getting around 25k instead of a 100k lol.
    I have to sit down and figure out what these tables of net params really look like and how to parse them 100% correctly, and then adjust for polling rate dynamically.

    I have a ?, does anyone here know how to achieve the same functionality as start killer?
    I want that in my network monitor and the ability to change transparencies in windows or the taskbar(I want to make the taskbar 100% transparent).
    Oh and the ability to totally remove the aeropeek button, and perhaps a mod for custom titlebars in windows, and maybe a few other small things like mouse hover activate window or something.
    Gahh... and an internal ver of the port monitor, can't forget that.
    Last edited by NEOAethyr; 01-31-2011 at 09:31 AM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  8. #8
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    News ver's, updated both userinit ad net monitor code.
    Decided against integrating them together.
    Fixed mem leak in net monitor prog.
    Added some more goodies, had to remove ip display ability (also no longer ensures you get a diff ip each time you use the change ip command ).

    I should beable to get the userinit code 100% done in a few days, whenever I feal like messing with it again.
    I'm kinda interested in the system's cache working set value though, I want to check some things...


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  9. #9
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    I did alot of work on both programs yesterday.
    It'll be a few days though until I post them.

    I have some speed issues to deal with .

    Things that have been done or I'm working on ->

    Opera mod, firefox mod:
    Removes the titlebar and moves/resizes the window into a specific location.
    This is done.

    Working on a proxomitron mod.
    1st hide main window (done).
    2nd hide programs tray icon (done).
    3rd init log window (not done).
    Hide log and make it toggle with a menu in my netmon's tray (done).
    Add diff modes, making proxomitron switch it's cfg files for diff things (not doing until last).

    Afterwards, make a mem hacking program to hack firefox and opera to change proxy config on the fly.
    When you select proxy logger enabled in my netmon's tray menu, it'll enable the proxy config for all browsers.
    When disabling the proxy, exiting it, it'll disable the proxy config for all browsers.
    I don't need this but maybe it's a good idea I don't know yet.

    Plan is to integrate proxomitron into my netmon program's tray menu.
    Make proxomitron half way usable again, right now it's to annoying to bother with it so I came up with this idea, been wanting a stand alone like http header log window for along time now.


    I plan on making a simple ver and an all out ver, depends on what all I can do.

    I'm also gonna try my hand at using the dll ver of ahk in asm.
    Should net some nice speedups.

    I already added timing code to time the cpu cycle's used in the main loop so I can figure out how to speed it up more.


    Other ideas ->

    I have working html support now, uses ie to render whatever html I want into a window, doesn't open ie it's self and uses less mem then both ie and the sidebar.
    My idea, make a replacement sidebar that uses less mem and isn't an "extra" proccess (it's possible now).

    I have working tray icon code that can take the icon's, there status and there tray tooltip's and place them into a new window.
    The code is slow right now.
    And it doesn't support the icon menu's or button events.
    Perhaps this could be remade into something decent that is actually able to replace the tray.
    I'm thinking of a tab like interface for the tasks and processes.
    Perhaps even done in html+js and ahk if it's possible.
    I'de also like to replace explorer so I can just get rid of it completely, I need to work on folder tree code stuffs.

    Thinking of integrating google earth plugin along with other sat img db's to setup a side bar like thing for sat stuffs.
    Integrated with the new sidebar replacement, so you can add your own html baised commands for it on the desktop/menu thing.

    Thinking of making a port mon of my own.
    Making it integratable with the above idea of sat stuff on the desktop.

    A mem hacking program too would be nice.

    A debug mode that lets you add remove control's, buttons and etc to any gui in real time (will work on soon, I need it to find out how to remove the start button).
    This is one of my next steps and I have code that has half of the work done I guess.
    Last edited by NEOAethyr; 02-06-2011 at 10:12 PM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  10. #10
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    @Mods.
    Can you change the name of this thread to say -> "NEO's Random code thread...".
    Or something similar , thanks.


    Yesterday I got me a new copy of easybcd, the latest beta allow you to add floppy images (ima) directly to the win7's boot menu.

    So I added a copy of win95's floppy image and added the memtest86+ dos exe to it.

    I also have some bits of code you can compile to add to your own floppy image/s.
    As com files, you'll need fasm to compile.
    (once I get a few more programs made out I suppose I can pre-compile them for you...)

    I'll start off with some basic ones and get some more advanced stuff as time goes on.
    For example, a replacement for phenom msr tweaker, a mem tweaker, cmos dumper/programmer, etc etc, whatever that can be thought up and figured out.


    Here goes:

    tCLK.com changes the master pic timing, for irq's/int's.
    The hd controller timings use this timer as a ref, so to fast and things get wack, drives fail to show, floppy's fail, etc.
    1.5x was the fastest setting without issues so far, I previously used 3x.
    A handful of peeps helped test values for me in the past in some of my modded bios'es.
    This is the 1st mod I'm putting up at the moment, I'm using it as I type this.

    INT19.com
    This is a small program that you run after tCLK.com and etc.
    Say for example, you hacked one of your timings in dos with a little bit of programming but you need a way of getting into windows with it, well this is what you need right here.
    It will load the last bootstrap.
    Example, win7's bootmgr, or the bios'es boot menu, etc.
    So you load dos, run a mod or 2, then run int19.com, which will direct you to say win7's bootmgr without reseting your pc and it's config.

    Reset.com
    Just a demo I put together a month ago or 2 for someone here on the forum to test there board.
    If for some reason you want to do a complete reset of your pc without pressing ctrl-alt-del then this will do just that.


    tCLK.asm
    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; tCLK / 8253...
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ; Notes:
    ; 1.5x was the latest safe value...
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Entry Ptr
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    org 0x100
    
    jmp Init
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Defines
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    CLK_8253_CH0 EQU 0x40
    CLK_8253_CH1 EQU 0x41
    CLK_8253_CH2 EQU 0x42
    CLK_8253_Control EQU 0x43
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Functions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Set_tCLK_1X:			;Reset tCLK, Result is 0x36 tCLK-CTL, and 0x0000 tCLK
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x00			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_1125X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xF0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_125X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xE0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_1375X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xD0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_15X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xC0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_1625X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xB0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_175X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0xA0			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_1875X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x90			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_2X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x80			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_25X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x70			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_3X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x60			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_35X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x50			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    Set_tCLK_4X:
    cli				;Disable IRQ's
    mov al, 0x34			;00110100B, Control (tCLK) LSB
    out CLK_8253_Control, al	;out 0x43, al
    mov al, 0x00			;LSB
    out CLK_8253_CH0, al		;out 0x40, al
    mov al, 0x40			;MSB
    out CLK_8253_CH0, al		;out 0x40, al
    sti				;Enable IRQ's
    ret
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Init
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Init:
    
    ;call Set_tCLK_1X
    ;call Set_tCLK_1125X
    ;call Set_tCLK_125X
    ;call Set_tCLK_1375X
    call Set_tCLK_15X
    ;call Set_tCLK_1625X
    ;call Set_tCLK_175X
    ;call Set_tCLK_1875X
    ;call Set_tCLK_2X
    ;call Set_tCLK_25X
    ;call Set_tCLK_3X
    ;call Set_tCLK_35X
    ;call Set_tCLK_4X
    
    jmp Exit
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Exit:
    
    ret
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    INT19.asm
    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; INT19
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Entry Ptr
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    org 0x100
    
    jmp Init
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Init
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Init:
    
    jmp Exit
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Exit:
    
    dw 0x19CD	;Exit To Boot Device
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Reset.asm
    Code:
    org 0x100
    
    push 0xF000
    push 0xFFF0
    retf
    
    ;jmp 0xF000:0xFFF0
    ;jmp 0xF000:0xE05B
    
    ;just incase...
    ret

    If anyone has any ideas of some mods then do tell.
    I'll do what I can to make it happen .

    However, complicated stuff like mem controller changes, not right this sec ok .
    You can ask, but I'm really to lazy to do that at the moment, it's specific per board..., well it doesn't have to be with some more work, but it would still be specific per cpu model...

    But if it's a simple msr change or if you know the exact pci reg to change and it's current offset, etc etc, then I can do that with a quickness.
    Last edited by NEOAethyr; 03-30-2011 at 02:20 AM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  11. #11
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    This ahk code hasn't been tested in this form yet.
    I have manually tested it and in theory it will work.
    But it might need some timing tweaking.

    I found that this taskbar autohide code that was oringally in my network monitor program worked as an alternative to the real autohide, when you want to use the half sized taskbar exploit bug.

    So it's possible to have this apply the bug automatically on startup.
    I will test tonight, right now I'm busy dl'ing these cod 5 waw updates...

    Code:
    ;Stop UxSms
    RunWait %ComSpec% /C "net stop UxSms",, Hide
    
    ;Enable Taskbar Autohide
    DetectHiddenWindows, On
    VarSetCapacity(APPBARDATA, 36, 0)	;var mem limit
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    WinHide ahk_class Shell_TrayWnd
    
    ;Restart UxSms
    RunWait %ComSpec% /C "net start UxSms",, Hide
    
    ;Disable Taskbar Autohide
    NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    WinShow ahk_class Shell_TrayWnd
    Example outcome of the above code:


    Note how the taskbar is half the size compared to the norm.

    I've got a million diff projects to get back on.
    One thing I need to do though is make a replacement mouse driver for dos, because in vmware the ms mouse and tiny mouse drivers don't work .
    I need mouse support for generic dos programs...

    I think my 1st project will be a max latency tweaker and idle cycle limit tweaker for the amd x6's, for dos...
    I just got done verifying the last of my mem timings last night so I need to move on to stuff that isn't in the bios.

    Edit:
    Also posted latest network monitor and userinit codes in the above posts.

    One more edit:
    Tested script above and it indeed works.
    I will have to continue testing to make sure there isn't timing issues.
    Last edited by NEOAethyr; 04-23-2011 at 08:20 PM.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  12. #12
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Updated network monitor code above.
    I need to work on getting the download/upload rate display stuff right...


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  13. #13
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Updated network monitor code again, added the setting User Timer QSR max.
    Which is in fact the NtSetTimerResolution setting.
    I've got a handful of ideas for this program later on and I'll work on it as time goes on.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  14. #14
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    I will update the network monitor program thing in a few days.
    There's an issue with the taskbar slim mod on win7 x64 embedded.
    I can get it to work but auto-hide must be enabled before running the current code, then disabled afterwards.
    I'll fix that so it works on x64 embedded pretty soon, it's going to be my main os (using it right now).

    I might end up posting another low level program here to change cpu-id's as well depending on how it effects certain benchs..., IF it does..., otherwise not sure what the point would be but whatever I guess .


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  15. #15
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    I was playing with the code a min ago and found out that if I install a 32bit ver of ahk instead of the 64bit it works fine.
    So I tried to figuer it out for the 64bit ver but got no where.

    The code:
    Code:
    Win7_Taskbar_Mod:
    
    RunWait %ComSpec% /C "net stop UxSms",, Hide			;Stop UxSms
    
    DetectHiddenWindows, On						;Enable Taskbar Autohide
    VarSetCapacity(APPBARDATA, 36, 0)				;Var mem limit
    
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0x0A), "UInt", &APPBARDATA)
    
    WinHide ahk_class Shell_TrayWnd
    RunWait %ComSpec% /C "net start UxSms",, Hide			;Restart UxSms
    
    NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")	;Disable Taskbar Autohide
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    
    WinShow ahk_class Shell_TrayWnd
    Reload								;Needed to refresh the desktop width var...
    return
    The issue:
    Code:
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0x0A), "UInt", &APPBARDATA)
    This never toggles the autohide.
    I'll have to reg on the ahk forum to figuer it out probably.


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  16. #16
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Posting this, probably no one cares but I feel I should at least keep the code up to date somewhat.
    It's been updated for windows 8 and a few other misc things.

    NEO_nTray.ahk / .exe

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; NEO_nTray (NEO's Network Tray Tool)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;; Notes:
    
    ;ctrl left click also works for the taskbar as well, restoring the last window
    ;so I may want to redo the code to include it
    
    ;
    ; %A_IPAddress1% Leaks massive amounts of memory, DO NOT use it!!!
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    ;Sleep 1000
    ;ElapsedTime_ms := (A_TickCount - StartTime)
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, %ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms
    
    ;This thing has gotten slower over the last rev or so...
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Entry Point
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    #Persistent
    #SingleInstance, Force
    #MaxMem 1
    #MaxThreads 3
    SetBatchLines -1
    Process, Priority,, BelowNormal
    Menu, Tray, NoStandard						;Disable Standard AHK Menu Entries
    SetTitleMatchMode, 2
    DetectHiddenWindows, On		;Needed to detect proxomitron while minimized
    
    GoSub Init
    
    StartTime := A_TickCount					;Internal Var, MS Timer
    ElapsedTime_ms := (A_TickCount - StartTime)
    
    SetTimer, Burn_Cycle, %Main_Loop_Timing%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Functions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    EmptyMem(PIDtoEmpty)
    {
    	h:= DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", PIDtoEmpty)
    	DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
    	DllCall("CloseHandle", "Int", h)
    }
    
    
    
    GetTrayBar()
    {
    	ControlGet, hParent, hWnd,, TrayNotifyWnd1  , ahk_class Shell_TrayWnd
    	ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
    	Loop
    	{
    		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
    		If  Not	hWnd
    			Break
    		Else If	hWnd = %hChild%
    		{
    			idxTB := A_Index
    			Break
    		}
    	}
    	Return	idxTB
    }
    
    
    TrayIcons(sExeName = "Proxomitron-MOD.exe")
    {
    	WinGet,	pidTaskbar, PID, ahk_class Shell_TrayWnd
    	hProc:=	DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
    	pProc:=	DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
    	idxTB:=	GetTrayBar()
    		SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT
    	Loop,	%ErrorLevel%
    	{
    		SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETBUTTON
    		VarSetCapacity(btn,32,0), VarSetCapacity(nfo,32,0)
    		DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
    			iBitmap	:= NumGet(btn, 0)
    			idn	:= NumGet(btn, 4)
    			Statyle := NumGet(btn, 8)
    		If	dwData	:= NumGet(btn,12)
    			iString	:= NumGet(btn,16)
    		Else	dwData	:= NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
    		DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 32, "Uint", 0)
    		If	NumGet(btn,12)
    			hWnd	:= NumGet(nfo, 0)
    		,	uID	:= NumGet(nfo, 4)
    		,	nMsg	:= NumGet(nfo, 8)
    		,	hIcon	:= NumGet(nfo,20)
    		Else	hWnd	:= NumGet(nfo, 0,"int64"), uID:=NumGet(nfo, 8), nMsg:=NumGet(nfo,12)
    		WinGet, pid, PID,              ahk_id %hWnd%
    		WinGet, sProcess, ProcessName, ahk_id %hWnd%
    		WinGetClass, sClass,           ahk_id %hWnd%
    		If !sExeName || (sExeName = sProcess) || (sExeName = pid)
    			VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
    		,	DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
    		,	DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
    ;		,	sTrayIcons .= "idx: " . A_Index-1 . " | idn: " . idn . " | Pid: " . pid . " | uID: " . uID . " | MessageID: " . nMsg . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
    		,	sTrayIcons .= "" . hWnd . ""
    	}
    	DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
    	DllCall("CloseHandle", "Uint", hProc)
    	Return	sTrayIcons
    }
    
    
    
    
    RemoveTrayIcon(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
    {
    	NumPut(VarSetCapacity(ni,444,0), ni)
    	NumPut(hWnd , ni, 4)
    	NumPut(uID  , ni, 8)
    	NumPut(1|2|4, ni,12)
    	NumPut(nMsg , ni,16)
    	NumPut(hIcon, ni,20)
    	Return	DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
    }
    
    
    
    
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    Set_User_Timer_QSR_Min:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 1)		;0.500 ms
    return
    
    Set_User_Timer_QSR_Max:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 999999)		;0.500 ms
    return
    
    Set_User_Timer_QSR_05:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    return
    
    Set_User_Timer_QSR_1:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    return
    
    Set_User_Timer_QSR_10:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    return
    
    Set_User_Timer_QSR_156:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    return
    
    
    Set_Tray_Icons_Default:
    Network_Icons_Use_Default = Enable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    return
    
    Set_Tray_Icons_Custom:
    Network_Icons_Use_Default = Disable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    return
    
    
    Set_Network_Use_Keyboard_Leds_Disable:
    Network_Use_Keyboard_Leds = Disable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    GetKeyState, KeyState, ScrollLock, T	;Bug fix for threading issues, so non of the leds end up getting stuck on...
    if KeyState = U		;this one gets stuck on anyways every time it seems
    {
    	KeyboardLED(1, "Off")
    }
    GetKeyState, KeyState, CapsLock, T
    if KeyState = U
    {
    	KeyboardLED(4, "Off")
    }
    GetKeyState, KeyState, NumLock, T
    if KeyState = U
    {
    	KeyboardLED(2, "Off")
    }
    return
    
    Set_Network_Use_Keyboard_Leds_Enable:
    Network_Use_Keyboard_Leds = Enable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_QuickLaunch_Mod_Disable:
    QuickLaunch_Mod = Disable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    return
    
    Set_QuickLaunch_Mod_Enable:
    QuickLaunch_Mod = Enable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_Aero_Peek_Disable:
    Aero_Peek = Disable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    Control, Disable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    Set_Aero_Peek_Enable:
    Aero_Peek = Enable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    Control, Enable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    
    Win7_Taskbar_Mod:
    
    RunWait %ComSpec% /C "net stop UxSms",, Hide			;Stop UxSms
    
    DetectHiddenWindows, On						;Enable Taskbar Autohide
    VarSetCapacity(APPBARDATA, 36, 0)				;Var mem limit
    
    RunWait %ComSpec% /C "taskkill /im dwm.exe /f",, Hide		;Restart DWM (Windows 8)
    
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0x0A), "UInt", &APPBARDATA)
    
    WinHide ahk_class Shell_TrayWnd
    RunWait %ComSpec% /C "net start UxSms",, Hide			;Restart UxSms
    
    NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")	;Disable Taskbar Autohide
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    
    WinShow ahk_class Shell_TrayWnd
    Reload								;Needed to refresh the desktop width var...
    return
    
    
    ;;; Network Monitor Functions:
    
    GetIfTable(ByRef tb, Border = True)
    {
    	nSize := 4 + 860 * GetNumberOfInterfaces() + 8	;Var mem limit calc
    	VarSetCapacity(tb, nSize)			;Var mem limit
    	Return DllCall("iphlpapi\GetIfTable", "Uint", &tb, "UintP", nSize, "int", Border)
    }
    
    GetNumberOfInterfaces()
    {
    	DllCall("iphlpapi\GetNumberOfInterfaces", "UintP", nIf)
    	Return nIf
    }
    
    DecodeInteger(ptr)
    {
    	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    }
    
    
    ;notes:
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;
    ;  DWORD dwInUcastPkts;
    ;  DWORD dwInNUcastPkts;
    ;  DWORD dwInDiscards;
    ;  DWORD dwInErrors;
    ;  DWORD dwInUnknownProtos;
    ;  DWORD dwOutOctets;
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    
    ;;; Keyboard LED Functions:
    
    KeyboardLED(LEDvalue, Cmd)	;LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4, Cmd = On / Off
    {
    	Static h_device
    	If ! h_device		;initialise
    	{
    		device =\Device\KeyBoardClass0
    		SetUnicodeStr(fn, device)
    		h_device := NtCreateFile(fn, 0 + 0x00000100 + 0x00000080 + 0x00100000, 1, 1, 0x00000040 + 0x00000020, 0)
    	}
    
    	VarSetCapacity(output_actual, 4, 0)
    	input_size = 4
    	VarSetCapacity(input, input_size, 0)
    
    	If Cmd = On		;forces all choosen LED's to ON (LEDvalue = 0 -> LED's according to keystate)
    	{
    		KeyLED := LEDvalue | (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	If Cmd = Off		;forces all choosen LED's to OFF (LEDvalue = 0 -> LED's according to keystate)
    	{
    		LEDvalue := LEDvalue ^ 7
    		KeyLED := LEDvalue & (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	;EncodeInteger(KeyLED, 1, &input, 2)	;input bit pattern (KeyLED): bit 0 = scrolllock, bit 1 = numlock, bit 2 = capslock
    	input := Chr(1) Chr(1) Chr(KeyLED)
    	input := Chr(1)
    	success := DllCall("DeviceIoControl", "uint", h_device, "uint", CTL_CODE(0x0000000B, 2, 0, 0), "uint", &input, "uint", input_size, "uint", 0, "uint", 0, "uint", &output_actual, "uint", 0)
    }
    
    CTL_CODE(p_device_type, p_function, p_method, p_access)
    {
    	Return, (p_device_type << 16) | (p_access << 14) | (p_function << 2) | p_method
    }
    
    NtCreateFile(ByRef wfilename, desiredaccess, sharemode, createdist, flags, fattribs)
    {
    	VarSetCapacity(fh, 4, 0)
    	VarSetCapacity(objattrib, 24, 0)
    	VarSetCapacity(io, 8, 0)
    	VarSetCapacity(pus, 8)
    	uslen := DllCall("lstrlenW", "str", wfilename) * 2
    	InsertInteger(uslen, pus, 0, 2)
    	InsertInteger(uslen, pus, 2, 2)
    	InsertInteger(&wfilename, pus, 4)
    	InsertInteger(24, objattrib, 0)
    	InsertInteger(&pus, objattrib, 8)
    	status := DllCall("ntdll\ZwCreateFile", "str", fh, "UInt", desiredaccess, "str", objattrib, "str", io, "UInt", 0, "UInt", fattribs, "UInt", sharemode, "UInt", createdist, "UInt", flags, "UInt", 0, "UInt", 0, "UInt")
    	return % ExtractInteger(fh)
    }
    
    SetUnicodeStr(ByRef out, str_)
    {
    	VarSetCapacity(st1, 8, 0)
    	InsertInteger(0x530025, st1)
    	VarSetCapacity(out, (StrLen(str_) + 1) * 2, 0)
    	DllCall("wsprintfW", "str", out, "str", st1, "str", str_, "Cdecl UInt")
    }
    
    ;pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
    ;The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
    ;pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
    ;pSource must be ByRef to avoid corruption during the formal-to-actual copying process
    ;(since pSource might contain valid data beyond its first binary zero).
    ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
    {
    	Loop %pSize%								;Build the integer by adding up its bytes.
    	result += *(&pSource + pOffset + A_Index - 1) << 8 * (A_Index - 1)
    	if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
    	return result								;Signed vs. unsigned doesn't matter in these cases.
    	return -(0xFFFFFFFF - result + 1)					;Otherwise, convert the value (now known to be 32-bit) to its signed counterpart
    }
    
    ;The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest, 
    ;only pSize number of bytes starting at pOffset are altered in it. 
    InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
    {
    	Loop %pSize%								;Copy each byte in the integer into the structure as raw binary data.
    	DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8 * (A_Index - 1) & 0xFF)
    }
    
    
    ;;; Hotkeys
    
    F12::		;Show / Hide Taskbar
    {
    	If TaskBar_State = Hidden
    	{
    		NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinShow ahk_class Shell_TrayWnd
    		TaskBar_State = Visable
    	}
    	else
    	{
    		DetectHiddenWindows, On
    		VarSetCapacity(APPBARDATA, 36, 0)	;var mem limit
    		NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinHide ahk_class Shell_TrayWnd
    		TaskBar_State = Hidden
    	}
    }
    
    ;Disable for now
    ;#t::		;Show / Hide Active Toolbar
    ;{
    ;	WinSet, Style, ^0xC00000, A
    ;}
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Burn_Cycle
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Burn_Cycle:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    
    if IP_Change = 0		;cludge for multi threading
    {
    	GoSub Network_Monitor
    }
    
    if QuickLaunch_Mod = Enable
    {
    	GoSub QuickLaunch_Mod
    }
    
    ;Opera title bar remover mod
    IfWinActive, - Opera
    {
    	WinSet, Style, -0xC00000, - Opera
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Opera,, -3, -3, %Desktop_Width%, %Desktop_Height%,,	;Slowdown Part..
    ;		WinMove, - Opera,, -3, -3, 1922, %Desktop_Height%,,	;Slowdown Part..
    	}
    }
    
    ;Firefox title bar remover mod
    IfWinActive, - Mozilla Firefox
    {
    	WinSet, Style, -0xC00000, - Mozilla Firefox
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Mozilla Firefox,, -3, -3, %Desktop_Width%, %Desktop_Height%,,
    	}
    }
    
    ;Download_Rate_Secs := Round(Download_Rate * (((A_TickCount - StartTime) / 1000), 1))
    ;Upload_Rate_Secs := Round(Upload_Rate * (((A_TickCount - StartTime) / 1000), 1))
    
    ;needs null check...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	Menu, Tray, Tip, Disconnected
    }
    else
    {
    	Menu, Tray, Tip, IP: %IP_Address%`nDownload Rate: %Download_Rate% K`nUpload Rate: %Upload_Rate% K`nDownloaded Total: %Downloaded_Total% K`nUploaded Total: %Uploaded_Total% K
    }
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, Burn_Cycle:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Read_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Read_Cfg:
    
    IniRead, Main_Loop_Timing, %A_ScriptDir%\NEO_nTray.ini, Main, Main_Loop_Timing
    
    IniRead, Aero_Peek, %A_ScriptDir%\NEO_nTray.ini, Extra, Aero_Peek
    IniRead, QuickLaunch_Mod, %A_ScriptDir%\NEO_nTray.ini, Extra, QuickLaunch_Mod
    IniRead, TaskBar_State, %A_ScriptDir%\NEO_nTray.ini, Extra, TaskBar_State
    
    IniRead, Port_Viewer, %A_ScriptDir%\NEO_nTray.ini, App_Locations, Port_Viewer
    
    IniRead, Network_Icons_Use_Default, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Use_Default
    IniRead, Network_Icons_Custom_1, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_1
    IniRead, Network_Icons_Custom_2, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_2
    IniRead, Network_Icons_Custom_3, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_3
    IniRead, Network_Icons_Custom_4, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_4
    IniRead, Network_Icons_Custom_5, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_5
    IniRead, Network_Use_Keyboard_Leds, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Use_Keyboard_Leds
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main Menu
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu:
    
    Menu, Menu_Settings_Tray_Icon, add, Default, Set_Tray_Icons_Default
    Menu, Menu_Settings_Tray_Icon, add, Custom, Set_Tray_Icons_Custom
    Menu, Menu_Settings, add, Tray Icon, :Menu_Settings_Tray_Icon
    Menu, Menu_Settings, Icon, Tray Icon, shell32.dll, 303				;not good in win2k3
    
    Menu, Menu_Settings_Keyboard_Leds, add, Disable, Set_Network_Use_Keyboard_Leds_Disable
    Menu, Menu_Settings_Keyboard_Leds, add, Enable, Set_Network_Use_Keyboard_Leds_Enable
    Menu, Menu_Settings, add, Keyboard LEDs, :Menu_Settings_Keyboard_Leds
    Menu, Menu_Settings, Icon, Keyboard LEDs, main.cpl, 6
    
    Menu, Menu_Settings, add
    
    Menu, Menu_Settings_QuickLaunch_Mod, add, Disable, Set_QuickLaunch_Mod_Disable
    Menu, Menu_Settings_QuickLaunch_Mod, add, Enable, Set_QuickLaunch_Mod_Enable
    Menu, Menu_Settings, add, QuickLaunch Mod, :Menu_Settings_QuickLaunch_Mod
    Menu, Menu_Settings, Icon, QuickLaunch Mod, shell32.dll, 40
    
    Menu, Menu_Settings_Aero_Peek, add, Disable, Set_Aero_Peek_Disable
    Menu, Menu_Settings_Aero_Peek, add, Enable, Set_Aero_Peek_Enable
    Menu, Menu_Settings, add, Aero Peek, :Menu_Settings_Aero_Peek
    Menu, Menu_Settings, Icon, Aero Peek, shell32.dll, 40
    
    Menu, Menu_Settings, add, Win7 Taskbar Mod, Win7_Taskbar_Mod
    Menu, Menu_Settings, Icon, Win7 Taskbar Mod, shell32.dll, 40
    
    Menu, Menu_Settings, add
    
    ;I woud prefer to have ahk's built in help function right here, but I can't figuer out the code for it
    
    Menu, User_Timer_QSR, add, Min, Set_User_Timer_QSR_Min
    Menu, User_Timer_QSR, Icon, Min, shell32.dll, 13
    Menu, User_Timer_QSR, add, Max, Set_User_Timer_QSR_Max
    Menu, User_Timer_QSR, Icon, Max, shell32.dll, 13
    Menu, User_Timer_QSR, add, 0.5 ms, Set_User_Timer_QSR_05
    Menu, User_Timer_QSR, Icon, 0.5 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 1 ms, Set_User_Timer_QSR_1
    Menu, User_Timer_QSR, Icon, 1 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 10 ms, Set_User_Timer_QSR_10
    Menu, User_Timer_QSR, Icon, 10 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 15.6 ms, Set_User_Timer_QSR_156
    Menu, User_Timer_QSR, Icon, 15.6 ms, shell32.dll, 13
    Menu, Menu_Settings, add, User Timer QSR Max, :User_Timer_QSR
    Menu, Menu_Settings, Icon, User Timer QSR Max, shell32.dll, 13
    
    Menu, Menu_Settings_Dev, add, Edit Script, Edit					;This should only be valid in script form, not in compiled form, I need to figuer that out...
    Menu, Menu_Settings_Dev, Icon, Edit Script, shell32.dll, 71
    Menu, Menu_Settings, add, Dev, :Menu_Settings_Dev
    Menu, Menu_Settings, Icon, Dev, shell32.dll, 161
    
    Menu, Tray, add, Port Viewer, Port_View
    Menu, Tray, Icon, Port Viewer, shell32.dll, 172
    
    Menu, Tray, add, Log Viewer, Log_View
    Menu, Tray, Icon, Log Viewer, shell32.dll, 172
    
    Menu, Tray, add, Abort Connections, Abort_Connections
    Menu, Tray, Icon, Abort Connections, shell32.dll, 172
    
    Menu, Tray, add, Change IP, Change_IP
    Menu, Tray, Icon, Change IP, shell32.dll, 19
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, add, Disconnect, Disconnect
    	Menu, Tray, Icon, Disconnect, netshell.dll, 71, 1	;Disconnected
    }
    else
    {
    	Menu, Tray, add, Disconnect, Disconnect
    	Menu, Tray, Icon, Disconnect, %Network_Icons_Custom_5%
    }
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, add, Connect, Connect
    	Menu, Tray, Icon, Connect, netshell.dll, 69, 1	;193, 0dn 0up
    }
    else
    {
    	Menu, Tray, add, Connect, Connect
    	Menu, Tray, Icon, Connect, %Network_Icons_Custom_1%
    }
    
    Menu, Tray, add, Network Connections, Network_Connections
    Menu, Tray, Icon, Network Connections, shell32.dll, 89
    
    Menu, Tray, add
    
    Menu, Tray, Add, Settings, :Menu_Settings
    Menu, Tray, Icon, Settings, shell32.dll, 13
    
    Menu, Tray, add
    
    Menu, Tray, add, Reload, Reload
    Menu, Tray, Icon, Reload, shell32.dll, 239
    
    Menu, Tray, add, Pause, Pause			;This needs a better pause icon, and needs a play icon or whatever once paused
    Menu, Tray, Icon, Pause, shell32.dll, 110
    
    Menu, Tray, add
    
    Menu, Tray, add, Exit, Exit
    Menu, Tray, Icon, Exit, shell32.dll, 28
    
    Menu, Tray, Click, 1				;Change from double left click to single left click
    Menu, Tray, Default, Port Viewer		;Default Entry to run on double click
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main_Menu_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu_Cfg:
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    }
    if Network_Icons_Use_Default = Disable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    }
    if Network_Use_Keyboard_Leds = Disable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    }
    
    
    if QuickLaunch_Mod = Disable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    }
    if QuickLaunch_Mod = Enable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    }
    
    if Aero_Peek = Disable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    }
    if Aero_Peek = Enable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    }
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Monitor:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    
    ;Needs null check too...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_5%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		GetKeyState, KeyState, ScrollLock, T
    		if KeyState = U
    		{
    			KeyboardLED(1, "Off")
    		}
    		GetKeyState, KeyState, CapsLock, T
    		if KeyState = U
    		{
    			KeyboardLED(4, "Off")
    		}
    		GetKeyState, KeyState, NumLock, T
    		if KeyState = U
    		{
    			KeyboardLED(2, "Off")
    		}
    	}
    
    	return
    }
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    
    GetIfTable(tb)
    
    ;notes:
    ;	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;		552?
    ;  DWORD dwInUcastPkts;		556?
    ;  DWORD dwInNUcastPkts;	560?
    ;  DWORD dwInDiscards;		564?
    ;  DWORD dwInErrors;		568?
    ;  DWORD dwInUnknownProtos;	572?
    ;  DWORD dwOutOctets;		576?
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    ;;Include this codes to exclude the loopback interface.
    ;;If DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 516) = 24
    ;;Continue
    Loop, % DecodeInteger(&tb)
    {
    	Download_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 552)	;Total Incoming Octets
    	Upload_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 576)	;Total Outgoing Octets
    }
    
    ;Needs odd colon char thingy to work...
    Download_Rate := Round(((Download_Rate_New - Download_Rate_Old) / 48), 1)		;Download rate calculation
    Upload_Rate := Round(((Upload_Rate_New - Upload_Rate_Old) / 48), 1)		;Upload rate calculation
    
    ;Offline Testing...
    ;if DL_Old = %Download_Rate%
    ;{
    ;	Download_Rate := Round((120.5 / 1024), 1)
    ;}
    ;if UP_Old = %Upload_Rate%
    ;{
    ;	Upload_Rate := Round((120.5 / 1024), 1)
    ;}
    ;DL_Old = %Download_Rate%
    ;UP_Old = %Upload_Rate%
    
    
    ;Needs odd syntax
    ;Needs a few microsecs of latency before lighting up the keyboard leds
    
    if (Download_Rate = 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 69, 1	;193, 0dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_1%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "Off")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 68, 1	;192, +dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_2%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    if (Download_Rate = 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 67, 1	;191, 0dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_3%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		Sleep, 1
    		KeyboardLED(1, "Off")
    		KeyboardLED(4, "On")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 66, 1	;190, +dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_4%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "On")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    
    
    ;Needs odd colon char to work...
    Downloaded_Total := Round(Download_Rate_New / 48)
    Uploaded_Total := Round(Upload_Rate_New / 48)
    
    Download_Rate_Old = %Download_Rate_New%
    Upload_Rate_Old = %Upload_Rate_New%
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    
    ;ToolTip, Network_Monitor:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    Return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; QuickLaunch_Mod
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    QuickLaunch_Mod:
    
    Mouse_State_LButton_Old = %Mouse_State_LButton%
    
    MouseGetPos,,,, Win32_Control
    GetKeyState, Mouse_State_LButton, LButton
    
    ;small issue with timing and mod, if I was previously over the toolbar and now on the taskbar with the same toolbar name, it takes a little while to reg to get rid of the ctrl key
    
    ;issue with mod to taskbar part, new
    ;after windows is already open it continues to use the ctrl mod, which doesn't work to well afterwards
    
    if A_OSVersion = WIN_7
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    ;	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D" || (Win32_Control = "MSTaskListWClass1") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    else if A_OSVersion = WIN_2003
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    ;	if ((Win32_Control = "ToolbarWindow322") && Mouse_State_LButton = "D" || (Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    
    ;324...
    ;323 is the issue on win2k3 slim, taskbar becomes the other toolbar.
    ;323 is the one that works in win7
    ;322 is the one that works in win2k3
    
    ;MSTaskListWClass1 = taskbar
    
    
    ;I can either scan for the os or I can patch it out correctly
    ;1st one is the issue
    
    ;ToolbarWindow322	Win2k3 single col
    ;causes issues on win2k3, crtl gets stuck on the taskbar
    
    ;ToolbarWindow323	Win7 double col
    
    ;This code needs work, works great in win7, but it needs to be worked on in xp and win2k3
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Port_View
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Port_View:
    ;MsgBox, %Port_Viewer%
    Run %Port_Viewer%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Log_View
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Log_View:
    ;MsgBox, %Log_Viewer%
    ;Run %Log_Viewer%
    
    ;Proxomitron Log Window
    PostMessage, 0x111, 0x3F5, 0,, ahk_class PrxTronCls
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Abort_Connections
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Abort_Connections:
    
    ;Proxomitron Abort Connections
    PostMessage, 0x111, 0x3F0, 0,, ahk_class PrxTronCls
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Connections
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Connections:
    
    ;check to see if netman is enabled via reg, if so then don't run the special code below.
    ;If it is disabled at runtime, then run the special code below
    ;Would like to see a sub menu with net connections...
    
    ;Big prob, the thign creates a new proccess which I can't seem to track yet.
    ;So my script stops the netman service before exiting, or it keeps it in mem, both are not cool
    
    ;RunWait %ComSpec% /C "sc config netman start= demand",, Hide
    ;RunWait %ComSpec% /C "net start netman",, Hide
    
    Run ::{7007acc7-3202-11d1-aad2-00805fc1270e},,, Win32_PID
    ;WinWaitClose ahk_pid %Win32_PID%				;Doesn't actually work...
    
    ;RunWait %ComSpec% /C "net stop netman",, Hide
    ;RunWait %ComSpec% /C "sc config netman start= disabled",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Change_IP
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Change_IP:
    
    ;issue here if ip was originally null
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	return
    }
    
    IP_Old = %IP_Address%
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    Download_Rate_Old = 0
    Upload_Rate_Old = 0
    Downloaded_Total = 0
    Uploaded_Total = 0
    
    TrayTip, NEO_nTray, Changing IP...,, 16
    Menu, Tray, Tip, Changing IP...
    
    IP_Change = 1		;cludge for multi threading
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    }
    else
    {
    	Menu, Tray, Icon, %Network_Icons_Custom_5%
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    IP_Change_Count = 0
    
    
    
    While (A_IPAddress1 = IP_OLD)
    {
    	IP_Change_Count += 1
    
    	if IP_Change_Count = 10
    	{
    		TrayTip, NEO_nTray, I tried to change your IP but after %IP_Change_Count% attempts I gave up...,, 16
    		Sleep 3000	;Give the user 3 secs to read the msg...
    		Reload
    		return
    	}
    	else
    	{
    		RunWait %ComSpec% /C "IPCONFIG /RELEASE",, Hide
    		Sleep (1000 * %IP_Change_Count%)	;increase idle by 1sec per loop
    		RunWait %ComSpec% /C "IPCONFIG /RENEW",, Hide
    	}
    }
    
    
    
    TrayTip, NEO_nTray, Old IP Address: %IP_Old%`nNew IP Address: %A_IPAddress1%,, 16
    IP_Change = 0		;Cludge for multi-threading
    Sleep 3000		;Give the user 3 secs to read the msg...
    
    Reload			;Cludge for mem leak on A_IPAddress1, reload the whole darn program after getting a new ip, init should pick up the new ip
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Disconnect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Disconnect:
    
    RunWait %ComSpec% /C "IPCONFIG /RELEASE",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Connect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Connect:
    
    RunWait %ComSpec% /C "IPCONFIG /RENEW",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Init
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Init:
    
    IP_Change = 0		;cludge for multi threading
    
    ;Try to reduce the mem leak as much as possible, and only call this once on init and not in the main loop, it won't beable to auto detect the ip at any given time but it should be good enough
    VarSetCapacity(IP_Address, 15, 0)				;Var mem limit
    VarSetCapacity(A_IP_Address, 15, 0)				;Var mem limit
    IP_Address = %A_IPAddress1%
    
    ;Hides the everything on the taskbar including it's self, but leaves the start button
    ;WinHide ahk_class Shell_TrayWnd
    
    GoSub Read_Cfg
    GoSub Main_Menu
    GoSub Main_Menu_Cfg
    
    if Aero_Peek = Enable
    {
    	GoSub Set_Aero_Peek_Enable
    }
    else
    {
    	GoSub Set_Aero_Peek_Disable
    }
    
    SysGet, Desktop_Width, 61
    SysGet, Desktop_Height, 62
    EnvSub, Desktop_Width, 2
    EnvSub, Desktop_Height, 2
    
    SysGet, Monitor_Width, 0
    SysGet, Monitor_Height, 1
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 1)		;Min
    
    
    ;Run "H:\Program Files\Proxomitron\Proxomitron-MOD.exe"
    ;Sleep, 250
    ;bypass
    ;PostMessage, 0x111, 0x3EF, 0,, ahk_class PrxTronCls
    ;Tray_Icon_hWnd = % TrayIcons()
    ;RemoveTrayIcon(Tray_Icon_hWnd, 1, 2)
    
    ;Reduce Mem Usage
    Process, wait, AutoHotKey.exe	;Find the process
    NewPID = %ErrorLevel%		;Save the PID
    EmptyMem(NewPID)
    
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Edit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Edit:
    
    Edit
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Reload
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Reload:
    
    Reload
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Pause
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Pause:
    
    Pause
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Exit:
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    ExitApp
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    NEO_nTray.ini

    Code:
    [Main]
    
    ;Main loop timing in (ms)
    Main_Loop_Timing=20
    
    
    [App_Locations]
    
    ;External port viewer program location
    Port_Viewer="H:\Program Files\TCPIP View\Tcpview.exe"
    ;Port_Viewer="NETSTAT -a -b -n 100"
    
    
    [Network]
    
    ;Use the built in default windows icons for the network status
    ;Network_Icons_Use_Default=Enable
    Network_Icons_Use_Default=Disable
    
    ;Custom network status icon locations
    ;Network_Icons_Custom_1="%APPDATA%\Microsoft\Windows\Start Menu\Programs\15.ico"
    ;Network_Icons_Custom_2="%APPDATA%\Microsoft\Windows\Start Menu\Programs\16.ico"
    ;Network_Icons_Custom_3="%APPDATA%\Microsoft\Windows\Start Menu\Programs\17.ico"
    ;Network_Icons_Custom_4="%APPDATA%\Microsoft\Windows\Start Menu\Programs\14.ico"
    ;Network_Icons_Custom_5="%APPDATA%\Microsoft\Windows\Start Menu\Programs\13.ico"
    
    Network_Icons_Custom_1="H:\15.ico"
    Network_Icons_Custom_2="H:\16.ico"
    Network_Icons_Custom_3="H:\17.ico"
    Network_Icons_Custom_4="H:\14.ico"
    Network_Icons_Custom_5="H:\13.ico"
    
    Network_Use_Keyboard_Leds=Disable
    ;Network_Use_Keyboard_Leds=Enable
    
    
    [Extra]
    
    ;QuickLaunch_Mod=Disable
    QuickLaunch_Mod=Enable
    
    Aero_Peek=Disable
    ;Aero_Peek=Enable
    
    TaskBar_State=Visable
    ;TaskBar_State=Hidden


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


  17. #17
    Xtreme Addict NEOAethyr's Avatar
    Join Date
    Sep 2010
    Location
    US, MI (Muskegon)
    Posts
    1,526
    Tiny update, after modding win8 up a bit I found that dwm.exe is run from winlogon.exe from then on.
    So microsoft's taskkill program wasn't up for that anymore...
    I replaced the line with pskill instead and that works, doesn't come with windows though..., not hard to find howevers...

    NEO_nTray.ahk / .exe
    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; NEO_nTray (NEO's Network Tray Tool)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;; Notes:
    
    ;ctrl left click also works for th etaskbar as well, restoring the last window
    ;so I may want to redo the code to include it
    
    ;
    ; %A_IPAddress1% Leaks massive amounts of memory, DO NOT use it!!!
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    ;Sleep 1000
    ;ElapsedTime_ms := (A_TickCount - StartTime)
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, %ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms
    
    ;This thing has gotten slower over the last rev or so...
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Entry Point
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    #Persistent
    #SingleInstance, Force
    #MaxMem 1
    #MaxThreads 3
    SetBatchLines -1
    Process, Priority,, BelowNormal
    Menu, Tray, NoStandard						;Disable Standard AHK Menu Entries
    SetTitleMatchMode, 2
    DetectHiddenWindows, On		;Needed to detect proxomitron while minimized
    
    GoSub Init
    
    StartTime := A_TickCount					;Internal Var, MS Timer
    ElapsedTime_ms := (A_TickCount - StartTime)
    
    SetTimer, Burn_Cycle, %Main_Loop_Timing%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Functions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    EmptyMem(PIDtoEmpty)
    {
    	h:= DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", PIDtoEmpty)
    	DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
    	DllCall("CloseHandle", "Int", h)
    }
    
    
    
    GetTrayBar()
    {
    	ControlGet, hParent, hWnd,, TrayNotifyWnd1  , ahk_class Shell_TrayWnd
    	ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
    	Loop
    	{
    		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
    		If  Not	hWnd
    			Break
    		Else If	hWnd = %hChild%
    		{
    			idxTB := A_Index
    			Break
    		}
    	}
    	Return	idxTB
    }
    
    
    TrayIcons(sExeName = "Proxomitron-MOD.exe")
    {
    	WinGet,	pidTaskbar, PID, ahk_class Shell_TrayWnd
    	hProc:=	DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
    	pProc:=	DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
    	idxTB:=	GetTrayBar()
    		SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT
    	Loop,	%ErrorLevel%
    	{
    		SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETBUTTON
    		VarSetCapacity(btn,32,0), VarSetCapacity(nfo,32,0)
    		DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
    			iBitmap	:= NumGet(btn, 0)
    			idn	:= NumGet(btn, 4)
    			Statyle := NumGet(btn, 8)
    		If	dwData	:= NumGet(btn,12)
    			iString	:= NumGet(btn,16)
    		Else	dwData	:= NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
    		DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 32, "Uint", 0)
    		If	NumGet(btn,12)
    			hWnd	:= NumGet(nfo, 0)
    		,	uID	:= NumGet(nfo, 4)
    		,	nMsg	:= NumGet(nfo, 8)
    		,	hIcon	:= NumGet(nfo,20)
    		Else	hWnd	:= NumGet(nfo, 0,"int64"), uID:=NumGet(nfo, 8), nMsg:=NumGet(nfo,12)
    		WinGet, pid, PID,              ahk_id %hWnd%
    		WinGet, sProcess, ProcessName, ahk_id %hWnd%
    		WinGetClass, sClass,           ahk_id %hWnd%
    		If !sExeName || (sExeName = sProcess) || (sExeName = pid)
    			VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
    		,	DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
    		,	DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
    ;		,	sTrayIcons .= "idx: " . A_Index-1 . " | idn: " . idn . " | Pid: " . pid . " | uID: " . uID . " | MessageID: " . nMsg . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
    		,	sTrayIcons .= "" . hWnd . ""
    	}
    	DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
    	DllCall("CloseHandle", "Uint", hProc)
    	Return	sTrayIcons
    }
    
    
    
    
    RemoveTrayIcon(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
    {
    	NumPut(VarSetCapacity(ni,444,0), ni)
    	NumPut(hWnd , ni, 4)
    	NumPut(uID  , ni, 8)
    	NumPut(1|2|4, ni,12)
    	NumPut(nMsg , ni,16)
    	NumPut(hIcon, ni,20)
    	Return	DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
    }
    
    
    
    
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    Set_User_Timer_QSR_Min:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 1)		;0.500 ms
    return
    
    Set_User_Timer_QSR_Max:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 999999)		;0.500 ms
    return
    
    Set_User_Timer_QSR_05:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    return
    
    Set_User_Timer_QSR_1:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    return
    
    Set_User_Timer_QSR_10:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    return
    
    Set_User_Timer_QSR_156:
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    return
    
    
    Set_Tray_Icons_Default:
    Network_Icons_Use_Default = Enable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    return
    
    Set_Tray_Icons_Custom:
    Network_Icons_Use_Default = Disable
    Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    return
    
    
    Set_Network_Use_Keyboard_Leds_Disable:
    Network_Use_Keyboard_Leds = Disable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    GetKeyState, KeyState, ScrollLock, T	;Bug fix for threading issues, so non of the leds end up getting stuck on...
    if KeyState = U		;this one gets stuck on anyways every time it seems
    {
    	KeyboardLED(1, "Off")
    }
    GetKeyState, KeyState, CapsLock, T
    if KeyState = U
    {
    	KeyboardLED(4, "Off")
    }
    GetKeyState, KeyState, NumLock, T
    if KeyState = U
    {
    	KeyboardLED(2, "Off")
    }
    return
    
    Set_Network_Use_Keyboard_Leds_Enable:
    Network_Use_Keyboard_Leds = Enable
    Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_QuickLaunch_Mod_Disable:
    QuickLaunch_Mod = Disable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    return
    
    Set_QuickLaunch_Mod_Enable:
    QuickLaunch_Mod = Enable
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    return
    
    
    Set_Aero_Peek_Disable:
    Aero_Peek = Disable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    Control, Disable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    Set_Aero_Peek_Enable:
    Aero_Peek = Enable
    Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    Control, Enable,, TrayShowDesktopButtonWClass1, ahk_class Shell_TrayWnd
    return
    
    
    Win7_Taskbar_Mod:
    
    RunWait %ComSpec% /C "net stop UxSms",, Hide			;Stop UxSms
    
    DetectHiddenWindows, On						;Enable Taskbar Autohide
    VarSetCapacity(APPBARDATA, 36, 0)				;Var mem limit
    
    ;After modding win8 a bit winlogon exe's dwm.exe and taskkill cannot find it, so pskill does the trick for now
    ;RunWait %ComSpec% /C "taskkill /im dwm.exe /f",, Hide		;Restart DWM (Windows 8)
    RunWait %ComSpec% /C "pskill dwm.exe",, Hide			;Restart DWM (Windows 8)
    
    NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0x0A), "UInt", &APPBARDATA)
    
    WinHide ahk_class Shell_TrayWnd
    RunWait %ComSpec% /C "net start UxSms",, Hide			;Restart UxSms
    
    NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")	;Disable Taskbar Autohide
    DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    
    WinShow ahk_class Shell_TrayWnd
    Reload								;Needed to refresh the desktop width var...
    return
    
    
    ;;; Network Monitor Functions:
    
    GetIfTable(ByRef tb, Border = True)
    {
    	nSize := 4 + 860 * GetNumberOfInterfaces() + 8	;Var mem limit calc
    	VarSetCapacity(tb, nSize)			;Var mem limit
    	Return DllCall("iphlpapi\GetIfTable", "Uint", &tb, "UintP", nSize, "int", Border)
    }
    
    GetNumberOfInterfaces()
    {
    	DllCall("iphlpapi\GetNumberOfInterfaces", "UintP", nIf)
    	Return nIf
    }
    
    DecodeInteger(ptr)
    {
    	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    }
    
    
    ;notes:
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;
    ;  DWORD dwInUcastPkts;
    ;  DWORD dwInNUcastPkts;
    ;  DWORD dwInDiscards;
    ;  DWORD dwInErrors;
    ;  DWORD dwInUnknownProtos;
    ;  DWORD dwOutOctets;
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    
    ;;; Keyboard LED Functions:
    
    KeyboardLED(LEDvalue, Cmd)	;LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4, Cmd = On / Off
    {
    	Static h_device
    	If ! h_device		;initialise
    	{
    		device =\Device\KeyBoardClass0
    		SetUnicodeStr(fn, device)
    		h_device := NtCreateFile(fn, 0 + 0x00000100 + 0x00000080 + 0x00100000, 1, 1, 0x00000040 + 0x00000020, 0)
    	}
    
    	VarSetCapacity(output_actual, 4, 0)
    	input_size = 4
    	VarSetCapacity(input, input_size, 0)
    
    	If Cmd = On		;forces all choosen LED's to ON (LEDvalue = 0 -> LED's according to keystate)
    	{
    		KeyLED := LEDvalue | (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	If Cmd = Off		;forces all choosen LED's to OFF (LEDvalue = 0 -> LED's according to keystate)
    	{
    		LEDvalue := LEDvalue ^ 7
    		KeyLED := LEDvalue & (GetKeyState("ScrollLock", "T") + 2 * GetKeyState("NumLock", "T") + 4 * GetKeyState("CapsLock", "T"))
    	}
    	;EncodeInteger(KeyLED, 1, &input, 2)	;input bit pattern (KeyLED): bit 0 = scrolllock, bit 1 = numlock, bit 2 = capslock
    	input := Chr(1) Chr(1) Chr(KeyLED)
    	input := Chr(1)
    	success := DllCall("DeviceIoControl", "uint", h_device, "uint", CTL_CODE(0x0000000B, 2, 0, 0), "uint", &input, "uint", input_size, "uint", 0, "uint", 0, "uint", &output_actual, "uint", 0)
    }
    
    CTL_CODE(p_device_type, p_function, p_method, p_access)
    {
    	Return, (p_device_type << 16) | (p_access << 14) | (p_function << 2) | p_method
    }
    
    NtCreateFile(ByRef wfilename, desiredaccess, sharemode, createdist, flags, fattribs)
    {
    	VarSetCapacity(fh, 4, 0)
    	VarSetCapacity(objattrib, 24, 0)
    	VarSetCapacity(io, 8, 0)
    	VarSetCapacity(pus, 8)
    	uslen := DllCall("lstrlenW", "str", wfilename) * 2
    	InsertInteger(uslen, pus, 0, 2)
    	InsertInteger(uslen, pus, 2, 2)
    	InsertInteger(&wfilename, pus, 4)
    	InsertInteger(24, objattrib, 0)
    	InsertInteger(&pus, objattrib, 8)
    	status := DllCall("ntdll\ZwCreateFile", "str", fh, "UInt", desiredaccess, "str", objattrib, "str", io, "UInt", 0, "UInt", fattribs, "UInt", sharemode, "UInt", createdist, "UInt", flags, "UInt", 0, "UInt", 0, "UInt")
    	return % ExtractInteger(fh)
    }
    
    SetUnicodeStr(ByRef out, str_)
    {
    	VarSetCapacity(st1, 8, 0)
    	InsertInteger(0x530025, st1)
    	VarSetCapacity(out, (StrLen(str_) + 1) * 2, 0)
    	DllCall("wsprintfW", "str", out, "str", st1, "str", str_, "Cdecl UInt")
    }
    
    ;pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
    ;The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
    ;pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
    ;pSource must be ByRef to avoid corruption during the formal-to-actual copying process
    ;(since pSource might contain valid data beyond its first binary zero).
    ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
    {
    	Loop %pSize%								;Build the integer by adding up its bytes.
    	result += *(&pSource + pOffset + A_Index - 1) << 8 * (A_Index - 1)
    	if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
    	return result								;Signed vs. unsigned doesn't matter in these cases.
    	return -(0xFFFFFFFF - result + 1)					;Otherwise, convert the value (now known to be 32-bit) to its signed counterpart
    }
    
    ;The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest, 
    ;only pSize number of bytes starting at pOffset are altered in it. 
    InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
    {
    	Loop %pSize%								;Copy each byte in the integer into the structure as raw binary data.
    	DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8 * (A_Index - 1) & 0xFF)
    }
    
    
    ;;; Hotkeys
    
    F12::		;Show / Hide Taskbar
    {
    	If TaskBar_State = Hidden
    	{
    		NumPut((ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinShow ahk_class Shell_TrayWnd
    		TaskBar_State = Visable
    	}
    	else
    	{
    		DetectHiddenWindows, On
    		VarSetCapacity(APPBARDATA, 36, 0)	;var mem limit
    		NumPut((ABS_ALWAYSONTOP := 0x2) | (ABS_AUTOHIDE := 0x1), APPBARDATA, 32, "UInt")
    		DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETSTATE := 0xA), "UInt", &APPBARDATA)
    		WinHide ahk_class Shell_TrayWnd
    		TaskBar_State = Hidden
    	}
    }
    
    ;Disable for now
    ;#t::		;Show / Hide Active Toolbar
    ;{
    ;	WinSet, Style, ^0xC00000, A
    ;}
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Burn_Cycle
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Burn_Cycle:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    ;StartTime := A_TickCount					;Internal Var, MS Timer
    
    if IP_Change = 0		;cludge for multi threading
    {
    	GoSub Network_Monitor
    }
    
    if QuickLaunch_Mod = Enable
    {
    	GoSub QuickLaunch_Mod
    }
    
    ;Opera title bar remover mod
    IfWinActive, - Opera
    {
    	WinSet, Style, -0xC00000, - Opera
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Opera,, -3, -3, %Desktop_Width%, %Desktop_Height%,,	;Slowdown Part..
    ;		WinMove, - Opera,, -3, -3, 1922, %Desktop_Height%,,	;Slowdown Part..
    	}
    }
    
    ;Firefox title bar remover mod
    IfWinActive, - Mozilla Firefox
    {
    	WinSet, Style, -0xC00000, - Mozilla Firefox
    
    	WinGetPos,,, Var_Width, A,,,
    	if (Var_Width > Desktop_Width)		;Seems ok, but the script needs reloading baised on the taskbar width otherwise the desktop width var is not refreshed :(
    	{
    		WinMove, - Mozilla Firefox,, -3, -3, %Desktop_Width%, %Desktop_Height%,,
    	}
    }
    
    ;Download_Rate_Secs := Round(Download_Rate * (((A_TickCount - StartTime) / 1000), 1))
    ;Upload_Rate_Secs := Round(Upload_Rate * (((A_TickCount - StartTime) / 1000), 1))
    
    ;needs null check...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	Menu, Tray, Tip, Disconnected
    }
    else
    {
    	Menu, Tray, Tip, IP: %IP_Address%`nDownload Rate: %Download_Rate% K`nUpload Rate: %Upload_Rate% K`nDownloaded Total: %Downloaded_Total% K`nUploaded Total: %Uploaded_Total% K
    }
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    ;ToolTip, Burn_Cycle:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Read_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Read_Cfg:
    
    IniRead, Main_Loop_Timing, %A_ScriptDir%\NEO_nTray.ini, Main, Main_Loop_Timing
    
    IniRead, Aero_Peek, %A_ScriptDir%\NEO_nTray.ini, Extra, Aero_Peek
    IniRead, QuickLaunch_Mod, %A_ScriptDir%\NEO_nTray.ini, Extra, QuickLaunch_Mod
    IniRead, TaskBar_State, %A_ScriptDir%\NEO_nTray.ini, Extra, TaskBar_State
    
    IniRead, Port_Viewer, %A_ScriptDir%\NEO_nTray.ini, App_Locations, Port_Viewer
    
    IniRead, Network_Icons_Use_Default, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Use_Default
    IniRead, Network_Icons_Custom_1, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_1
    IniRead, Network_Icons_Custom_2, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_2
    IniRead, Network_Icons_Custom_3, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_3
    IniRead, Network_Icons_Custom_4, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_4
    IniRead, Network_Icons_Custom_5, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Icons_Custom_5
    IniRead, Network_Use_Keyboard_Leds, %A_ScriptDir%\NEO_nTray.ini, Network, Network_Use_Keyboard_Leds
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main Menu
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu:
    
    Menu, Menu_Settings_Tray_Icon, add, Default, Set_Tray_Icons_Default
    Menu, Menu_Settings_Tray_Icon, add, Custom, Set_Tray_Icons_Custom
    Menu, Menu_Settings, add, Tray Icon, :Menu_Settings_Tray_Icon
    Menu, Menu_Settings, Icon, Tray Icon, shell32.dll, 303				;not good in win2k3
    
    Menu, Menu_Settings_Keyboard_Leds, add, Disable, Set_Network_Use_Keyboard_Leds_Disable
    Menu, Menu_Settings_Keyboard_Leds, add, Enable, Set_Network_Use_Keyboard_Leds_Enable
    Menu, Menu_Settings, add, Keyboard LEDs, :Menu_Settings_Keyboard_Leds
    Menu, Menu_Settings, Icon, Keyboard LEDs, main.cpl, 6
    
    Menu, Menu_Settings, add
    
    Menu, Menu_Settings_QuickLaunch_Mod, add, Disable, Set_QuickLaunch_Mod_Disable
    Menu, Menu_Settings_QuickLaunch_Mod, add, Enable, Set_QuickLaunch_Mod_Enable
    Menu, Menu_Settings, add, QuickLaunch Mod, :Menu_Settings_QuickLaunch_Mod
    Menu, Menu_Settings, Icon, QuickLaunch Mod, shell32.dll, 40
    
    Menu, Menu_Settings_Aero_Peek, add, Disable, Set_Aero_Peek_Disable
    Menu, Menu_Settings_Aero_Peek, add, Enable, Set_Aero_Peek_Enable
    Menu, Menu_Settings, add, Aero Peek, :Menu_Settings_Aero_Peek
    Menu, Menu_Settings, Icon, Aero Peek, shell32.dll, 40
    
    Menu, Menu_Settings, add, Win7 Taskbar Mod, Win7_Taskbar_Mod
    Menu, Menu_Settings, Icon, Win7 Taskbar Mod, shell32.dll, 40
    
    Menu, Menu_Settings, add
    
    ;I woud prefer to have ahk's built in help function right here, but I can't figuer out the code for it
    
    Menu, User_Timer_QSR, add, Min, Set_User_Timer_QSR_Min
    Menu, User_Timer_QSR, Icon, Min, shell32.dll, 13
    Menu, User_Timer_QSR, add, Max, Set_User_Timer_QSR_Max
    Menu, User_Timer_QSR, Icon, Max, shell32.dll, 13
    Menu, User_Timer_QSR, add, 0.5 ms, Set_User_Timer_QSR_05
    Menu, User_Timer_QSR, Icon, 0.5 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 1 ms, Set_User_Timer_QSR_1
    Menu, User_Timer_QSR, Icon, 1 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 10 ms, Set_User_Timer_QSR_10
    Menu, User_Timer_QSR, Icon, 10 ms, shell32.dll, 13
    Menu, User_Timer_QSR, add, 15.6 ms, Set_User_Timer_QSR_156
    Menu, User_Timer_QSR, Icon, 15.6 ms, shell32.dll, 13
    Menu, Menu_Settings, add, User Timer QSR Max, :User_Timer_QSR
    Menu, Menu_Settings, Icon, User Timer QSR Max, shell32.dll, 13
    
    Menu, Menu_Settings_Dev, add, Edit Script, Edit					;This should only be valid in script form, not in compiled form, I need to figuer that out...
    Menu, Menu_Settings_Dev, Icon, Edit Script, shell32.dll, 71
    Menu, Menu_Settings, add, Dev, :Menu_Settings_Dev
    Menu, Menu_Settings, Icon, Dev, shell32.dll, 161
    
    Menu, Tray, add, Port Viewer, Port_View
    Menu, Tray, Icon, Port Viewer, shell32.dll, 172
    
    Menu, Tray, add, Log Viewer, Log_View
    Menu, Tray, Icon, Log Viewer, shell32.dll, 172
    
    Menu, Tray, add, Abort Connections, Abort_Connections
    Menu, Tray, Icon, Abort Connections, shell32.dll, 172
    
    Menu, Tray, add, Change IP, Change_IP
    Menu, Tray, Icon, Change IP, shell32.dll, 19
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, add, Disconnect, Disconnect
    	Menu, Tray, Icon, Disconnect, netshell.dll, 71, 1	;Disconnected
    }
    else
    {
    	Menu, Tray, add, Disconnect, Disconnect
    	Menu, Tray, Icon, Disconnect, %Network_Icons_Custom_5%
    }
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, add, Connect, Connect
    	Menu, Tray, Icon, Connect, netshell.dll, 69, 1	;193, 0dn 0up
    }
    else
    {
    	Menu, Tray, add, Connect, Connect
    	Menu, Tray, Icon, Connect, %Network_Icons_Custom_1%
    }
    
    Menu, Tray, add, Network Connections, Network_Connections
    Menu, Tray, Icon, Network Connections, shell32.dll, 89
    
    Menu, Tray, add
    
    Menu, Tray, Add, Settings, :Menu_Settings
    Menu, Tray, Icon, Settings, shell32.dll, 13
    
    Menu, Tray, add
    
    Menu, Tray, add, Reload, Reload
    Menu, Tray, Icon, Reload, shell32.dll, 239
    
    Menu, Tray, add, Pause, Pause			;This needs a better pause icon, and needs a play icon or whatever once paused
    Menu, Tray, Icon, Pause, shell32.dll, 110
    
    Menu, Tray, add
    
    Menu, Tray, add, Exit, Exit
    Menu, Tray, Icon, Exit, shell32.dll, 28
    
    Menu, Tray, Click, 1				;Change from double left click to single left click
    Menu, Tray, Default, Port Viewer		;Default Entry to run on double click
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Main_Menu_Cfg
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Main_Menu_Cfg:
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 145
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 132
    }
    if Network_Icons_Use_Default = Disable
    {
    	Menu, Menu_Settings_Tray_Icon, Icon, Default, shell32.dll, 132
    	Menu, Menu_Settings_Tray_Icon, Icon, Custom, shell32.dll, 145
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 145
    }
    if Network_Use_Keyboard_Leds = Disable
    {
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Keyboard_Leds, Icon, Enable, shell32.dll, 132
    }
    
    
    if QuickLaunch_Mod = Disable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 132
    }
    if QuickLaunch_Mod = Enable
    {
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_QuickLaunch_Mod, Icon, Enable, shell32.dll, 145
    }
    
    if Aero_Peek = Disable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 145
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 132
    }
    if Aero_Peek = Enable
    {
    	Menu, Menu_Settings_Aero_Peek, Icon, Disable, shell32.dll, 132
    	Menu, Menu_Settings_Aero_Peek, Icon, Enable, shell32.dll, 145
    }
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Monitor:
    
    ;Code Timer for Debugging...
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)	;External Var, CPU Tick Timer
    
    ;Needs null check too...
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_5%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		GetKeyState, KeyState, ScrollLock, T
    		if KeyState = U
    		{
    			KeyboardLED(1, "Off")
    		}
    		GetKeyState, KeyState, CapsLock, T
    		if KeyState = U
    		{
    			KeyboardLED(4, "Off")
    		}
    		GetKeyState, KeyState, NumLock, T
    		if KeyState = U
    		{
    			KeyboardLED(2, "Off")
    		}
    	}
    
    	return
    }
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    
    GetIfTable(tb)
    
    ;notes:
    ;	Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
    ;typedef struct _MIB_IFROW {
    ;  WCHAR wszName[MAX_INTERFACE_NAME_LEN];
    ;  DWORD dwIndex;
    ;  DWORD dwType;
    ;  DWORD dwMtu;
    ;  DWORD dwSpeed;
    ;  DWORD dwPhysAddrLen;
    ;  BYTE  bPhysAddr[MAXLEN_PHYSADDR];
    ;  DWORD dwAdminStatus;
    ;  DWORD dwOperStatus;
    ;  DWORD dwLastChange;
    ;  DWORD dwInOctets;		552?
    ;  DWORD dwInUcastPkts;		556?
    ;  DWORD dwInNUcastPkts;	560?
    ;  DWORD dwInDiscards;		564?
    ;  DWORD dwInErrors;		568?
    ;  DWORD dwInUnknownProtos;	572?
    ;  DWORD dwOutOctets;		576?
    ;  DWORD dwOutUcastPkts;
    ;  DWORD dwOutNUcastPkts;
    ;  DWORD dwOutDiscards;
    ;  DWORD dwOutErrors;
    ;  DWORD dwOutQLen;
    ;  DWORD dwDescrLen;
    ;  BYTE  bDescr[MAXLEN_IFDESCR];
    ;} MIB_IFROW, *PMIB_IFROW;
    
    ;;Include this codes to exclude the loopback interface.
    ;;If DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 516) = 24
    ;;Continue
    Loop, % DecodeInteger(&tb)
    {
    	Download_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 552)	;Total Incoming Octets
    	Upload_Rate_New += DecodeInteger(&tb + 4 + 860 * (A_Index - 1) + 576)	;Total Outgoing Octets
    }
    
    ;Needs odd colon char thingy to work...
    Download_Rate := Round(((Download_Rate_New - Download_Rate_Old) / 48), 1)		;Download rate calculation
    Upload_Rate := Round(((Upload_Rate_New - Upload_Rate_Old) / 48), 1)		;Upload rate calculation
    
    ;Offline Testing...
    ;if DL_Old = %Download_Rate%
    ;{
    ;	Download_Rate := Round((120.5 / 1024), 1)
    ;}
    ;if UP_Old = %Upload_Rate%
    ;{
    ;	Upload_Rate := Round((120.5 / 1024), 1)
    ;}
    ;DL_Old = %Download_Rate%
    ;UP_Old = %Upload_Rate%
    
    
    ;Needs odd syntax
    ;Needs a few microsecs of latency before lighting up the keyboard leds
    
    if (Download_Rate = 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 69, 1	;193, 0dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_1%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "Off")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate = 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 68, 1	;192, +dn 0up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_2%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "Off")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    if (Download_Rate = 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 67, 1	;191, 0dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_3%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		Sleep, 1
    		KeyboardLED(1, "Off")
    		KeyboardLED(4, "On")
    	}
    }
    if (Download_Rate > 0 && Upload_Rate > 0)
    {
    	if Network_Icons_Use_Default = Enable
    	{
    		Menu, Tray, Icon, netshell.dll, 66, 1	;190, +dn +up
    	}
    	else
    	{
    		Menu, Tray, Icon, %Network_Icons_Custom_4%
    	}
    	if Network_Use_Keyboard_Leds = Enable
    	{
    		KeyboardLED(4, "On")
    		Sleep, 1
    		KeyboardLED(1, "On")
    	}
    }
    
    
    ;Needs odd colon char to work...
    Downloaded_Total := Round(Download_Rate_New / 48)
    Uploaded_Total := Round(Upload_Rate_New / 48)
    
    Download_Rate_Old = %Download_Rate_New%
    Upload_Rate_Old = %Upload_Rate_New%
    
    ;DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
    ;ElapsedTime_pc := (CounterAfter - CounterBefore)
    
    ;ToolTip, Network_Monitor:`n%ElapsedTime_pc% Ticks`n%ElapsedTime_ms% ms, 0, 0
    
    Return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; QuickLaunch_Mod
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    QuickLaunch_Mod:
    
    Mouse_State_LButton_Old = %Mouse_State_LButton%
    
    MouseGetPos,,,, Win32_Control
    GetKeyState, Mouse_State_LButton, LButton
    
    ;small issue with timing and mod, if I was previously over the toolbar and now on the taskbar with the same toolbar name, it takes a little while to reg to get rid of the ctrl key
    
    ;issue with mod to taskbar part, new
    ;after windows is already open it continues to use the ctrl mod, which doesn't work to well afterwards
    
    if A_OSVersion = WIN_7
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    ;	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D" || (Win32_Control = "MSTaskListWClass1") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    else if A_OSVersion = WIN_2003
    {
    	if ((Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    ;	if ((Win32_Control = "ToolbarWindow322") && Mouse_State_LButton = "D" || (Win32_Control = "ToolbarWindow323") && Mouse_State_LButton = "D")
    	{
    		Send, {Control down}
    	}
    	else if (Mouse_State_LButton_Old = "D" && Mouse_State_LButton = "U")	;cheap hack
    	{
    		Send, {Control up}
    	}
    }
    
    ;324...
    ;323 is the issue on win2k3 slim, taskbar becomes the other toolbar.
    ;323 is the one that works in win7
    ;322 is the one that works in win2k3
    
    ;MSTaskListWClass1 = taskbar
    
    
    ;I can either scan for the os or I can patch it out correctly
    ;1st one is the issue
    
    ;ToolbarWindow322	Win2k3 single col
    ;causes issues on win2k3, crtl gets stuck on the taskbar
    
    ;ToolbarWindow323	Win7 double col
    
    ;This code needs work, works great in win7, but it needs to be worked on in xp and win2k3
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Port_View
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Port_View:
    ;MsgBox, %Port_Viewer%
    Run %Port_Viewer%
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Log_View
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Log_View:
    ;MsgBox, %Log_Viewer%
    ;Run %Log_Viewer%
    
    ;Proxomitron Log Window
    PostMessage, 0x111, 0x3F5, 0,, ahk_class PrxTronCls
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Abort_Connections
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Abort_Connections:
    
    ;Proxomitron Abort Connections
    PostMessage, 0x111, 0x3F0, 0,, ahk_class PrxTronCls
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Network_Connections
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Network_Connections:
    
    ;check to see if netman is enabled via reg, if so then don't run the special code below.
    ;If it is disabled at runtime, then run the special code below
    ;Would like to see a sub menu with net connections...
    
    ;Big prob, the thign creates a new proccess which I can't seem to track yet.
    ;So my script stops the netman service before exiting, or it keeps it in mem, both are not cool
    
    ;RunWait %ComSpec% /C "sc config netman start= demand",, Hide
    ;RunWait %ComSpec% /C "net start netman",, Hide
    
    Run ::{7007acc7-3202-11d1-aad2-00805fc1270e},,, Win32_PID
    ;WinWaitClose ahk_pid %Win32_PID%				;Doesn't actually work...
    
    ;RunWait %ComSpec% /C "net stop netman",, Hide
    ;RunWait %ComSpec% /C "sc config netman start= disabled",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Change_IP
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Change_IP:
    
    ;issue here if ip was originally null
    if (IP_Address = "127.0.0.1" || IP_Address = "0.0.0.0")
    {
    	return
    }
    
    IP_Old = %IP_Address%
    
    Download_Rate_New = 0
    Upload_Rate_New = 0
    Download_Rate_Old = 0
    Upload_Rate_Old = 0
    Downloaded_Total = 0
    Uploaded_Total = 0
    
    TrayTip, NEO_nTray, Changing IP...,, 16
    Menu, Tray, Tip, Changing IP...
    
    IP_Change = 1		;cludge for multi threading
    
    if Network_Icons_Use_Default = Enable
    {
    	Menu, Tray, Icon, netshell.dll, 71, 1	;Disconnected
    }
    else
    {
    	Menu, Tray, Icon, %Network_Icons_Custom_5%
    }
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    IP_Change_Count = 0
    
    
    
    While (A_IPAddress1 = IP_OLD)
    {
    	IP_Change_Count += 1
    
    	if IP_Change_Count = 10
    	{
    		TrayTip, NEO_nTray, I tried to change your IP but after %IP_Change_Count% attempts I gave up...,, 16
    		Sleep 3000	;Give the user 3 secs to read the msg...
    		Reload
    		return
    	}
    	else
    	{
    		RunWait %ComSpec% /C "IPCONFIG /RELEASE",, Hide
    		Sleep (1000 * %IP_Change_Count%)	;increase idle by 1sec per loop
    		RunWait %ComSpec% /C "IPCONFIG /RENEW",, Hide
    	}
    }
    
    
    
    TrayTip, NEO_nTray, Old IP Address: %IP_Old%`nNew IP Address: %A_IPAddress1%,, 16
    IP_Change = 0		;Cludge for multi-threading
    Sleep 3000		;Give the user 3 secs to read the msg...
    
    Reload			;Cludge for mem leak on A_IPAddress1, reload the whole darn program after getting a new ip, init should pick up the new ip
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Disconnect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Disconnect:
    
    RunWait %ComSpec% /C "IPCONFIG /RELEASE",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Connect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Connect:
    
    RunWait %ComSpec% /C "IPCONFIG /RENEW",, Hide
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Init
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Init:
    
    IP_Change = 0		;cludge for multi threading
    
    ;Try to reduce the mem leak as much as possible, and only call this once on init and not in the main loop, it won't beable to auto detect the ip at any given time but it should be good enough
    VarSetCapacity(IP_Address, 15, 0)				;Var mem limit
    VarSetCapacity(A_IP_Address, 15, 0)				;Var mem limit
    IP_Address = %A_IPAddress1%
    
    ;Hides the everything on the taskbar including it's self, but leaves the start button
    ;WinHide ahk_class Shell_TrayWnd
    
    GoSub Read_Cfg
    GoSub Main_Menu
    GoSub Main_Menu_Cfg
    
    if Aero_Peek = Enable
    {
    	GoSub Set_Aero_Peek_Enable
    }
    else
    {
    	GoSub Set_Aero_Peek_Disable
    }
    
    SysGet, Desktop_Width, 61
    SysGet, Desktop_Height, 62
    EnvSub, Desktop_Width, 2
    EnvSub, Desktop_Height, 2
    
    SysGet, Monitor_Width, 0
    SysGet, Monitor_Height, 1
    
    ;User Timer Max Quantum Slice Resolution
    ;Quantum timer resolution
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 156000)		;15.600 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 100000)	;10.000 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 10000)		;1.000 ms
    ;DllCall("ntdll.dll\NtSetTimerResolution", UInt, 5000)		;0.500 ms
    DllCall("ntdll.dll\NtSetTimerResolution", UInt, 1)		;Min
    
    
    ;Run "H:\Program Files\Proxomitron\Proxomitron-MOD.exe"
    ;Sleep, 250
    ;bypass
    ;PostMessage, 0x111, 0x3EF, 0,, ahk_class PrxTronCls
    ;Tray_Icon_hWnd = % TrayIcons()
    ;RemoveTrayIcon(Tray_Icon_hWnd, 1, 2)
    
    
    ;Reduce Mem Usage
    Process, wait, AutoHotKey.exe	;Find the process
    NewPID = %ErrorLevel%		;Save the PID
    EmptyMem(NewPID)
    
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Edit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Edit:
    
    Edit
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Reload
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Reload:
    
    Reload
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Pause
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Pause:
    
    Pause
    
    return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Exit:
    
    if Network_Use_Keyboard_Leds = Enable
    {
    	GetKeyState, KeyState, ScrollLock, T
    	if KeyState = U
    	{
    		KeyboardLED(1, "Off")
    	}
    	GetKeyState, KeyState, CapsLock, T
    	if KeyState = U
    	{
    		KeyboardLED(4, "Off")
    	}
    	GetKeyState, KeyState, NumLock, T
    	if KeyState = U
    	{
    		KeyboardLED(2, "Off")
    	}
    }
    
    ExitApp
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    CPU: Intel Core i7-4930k [3332B054]
    CPU Heatsink: NZXT Kraken X60
    Mobo: ASUS Rampage IV Black Edition (0507 BIOS)
    MEM: 4x 4gig G.Skill [F3-2400C9Q-16GTXD] (Dual Sidded Samsung of Some Sorts)
    PSU: Antec HCP-850 Platinum
    VGA: nVidia Grid VGX K2 (WIP with 2x 680 lightnings)
    Monitor: ASUS VG278HE & 3DVision2 Kit
    Drives: 2x WD Red 2TB Drives [WDBMMA0020HNC-NRSN] (RAID 0), Corsair Force Series 3 CSSD-F60GB3A-BK 60GB SATA3 SSD, Pioneer BDR-2208 Blue Ray Burner
    Case: Rosewill Blackhawk Ultra
    OS's: Windows 2003 Enterprise x86 SP2-R2 VLM, Windows 7 Standard Embedded x86 SP1 EVL (128GB Patched), Windows 7 Standard Embedded x64 SP1 EVL
    Mouse: Using generic mouse for now...
    Arm:Samsung Galaxy S IV i9500 Octo-Core Quad Band 16gb Unlocked and 2x 64gig sd cards
    777

    You've been Battletoaded!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •