SetTimer Issue, or Bad Idea issue?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

SetTimer Issue, or Bad Idea issue?

29 Mar 2018, 16:31

I'm not sure where my failure is for Debug Issue #2 (in the header), so I'm hoping someone can help me figure it out.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WhereAmI.ahk
; Created by: TXShooter with help from https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
; Purpose: 	To write a file to the MS OneDrive cloud folder the system's pertinent information for tracking purposes and other uses like a psuedo dyndns.
;			Run EXE at startup in the System Tray with Tool Tips giving updated information.
;
; Date: 		2018.03.25
; Revision: 	1
; Synopsis: 	When executed, this script will perform the following in sequence:
;					1) Read from the system Registry where the Microsoft OneDrive folder is located,
;					2) Start a timer to cycle every X minutes (i.e. 15 minutes)
;					3) Loop the following at the start of each timed cycle:
;						A) Get the LAN IP Address (lanIP). Error if not valid.
;						B) Get the WAN IP Address (wanIP). Error if not valid.
;						C) Get current date and time (time)
;						D) Get OS Version
;						E) Write INI File with the above information in the root of the OneDrive folder
;						F) Update Systray's icon tool tip
;					4) Write to Windows System Registry HKLM 'Run' key the EXE Path for automatic startup at boot.
;
; DEBUG ISSUES:
;					1) Using the clipboard to obtain the IP Addresses prevents usage of the clipboard for normal Windows operations.
;					2) The Tool Tip for the Systray is not updating the IP Addresses at all, whereas the double-click 'Open' SysTray Menu label is working correctly. [SOLVED]
;						a) Tool Tip for the Sysray for the variable "User" and "OSVer" are working correctly.
;					3) The variable "Time" is not updating. {SOLVED]
;					4) Unable to add the EXE file's path to the System Registry for unknown reason(s). Could be a permission issue?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Environment Setup:
	#NoEnv  						; Recommended for performance and compatibility with future AutoHotkey releases.
	SendMode Input  				; Recommended for new scripts due to its superior speed and reliability.
	SetWorkingDir %A_ScriptDir%  		; Ensures a consistent starting directory.
	#SingleInstance, Force
	#Persistent

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SysTray Menu Setup:
	Menu, Tray, NoStandard
	Menu, Tray, Add, Exit, Exit
	Menu, Tray, Add, Open, Open
	Menu, Tray, Default, Open

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Variables:
	Global OneDriveFolder := ""
		RegRead, OneDriveFolder, HKEY_CURRENT_USER\Environment, OneDrive
		OneDriveFolder := OneDriveFolder . "\"
	Global WhereAmIKey := "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
	Global WhereAmIString := "C:\Program Files\WhereAmI\WhereAmI.exe"
		RegWrite, REG_SZ, HKLM, %WhereAmIKey%, WhereAmI, %WhereAmIString%
	clipSave := ClipboardAll
	Clipboard := clipSave


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Script:
	SetTimer, GetInfo, 1000			; Timer in milliseconds
	GetInfo()						; Immediately call GetInfo()
	Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main:
GetInfo()
{
	Global Time = A_Now
	FormatTime, Time,, yyyy.MM.dd - HH:mm:ss
   	GetLanIP()
   	GetWanIP()
	Menu, Tray, Tip, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%
	IniWrite, %A_Username%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, User
	IniWrite, %A_OSVersion%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, OSVer
	IniWrite, %wanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, ExtIP
	IniWrite, %lanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, IpAddr
	IniWrite, %Time%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, Time of last update
	return
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Labels:
Exit:
	ExitApp

Open:
	MsgBox, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%`nTime: %Time%
	return

	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Functions:
GetLanIP()			; Credit https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
{
	Clipboard := ""
	run, %ComSpec% /c ipconfig | CLIP, , Hide
	ClipWait
	lanInfo := Clipboard
	loop, Parse, lanInfo, `n
	{
		if(InStr(A_LoopField, "IPv4"))
		{
			Global lanIp := Trim(SubStr(A_LoopField, InStr(A_LoopField, ":")+2), "`r`n")
			return
		}
	}
	Global lanIP := "Check Network Connection"
	Return
}

GetWanIP()			; Credit https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
{
	Clipboard := ""
	run, %ComSpec% /c nslookup myip.opendns.com resolver1.opendns.com | CLIP, , Hide
	ClipWait
	wanInfo := Clipboard
	if(!InStr(wanInfo, "Name:"))
	{
		Global wanIP := "Check Network Connection"
		return
	}
	else
	{
		wanInfo := SubStr(wanInfo, instr(wanInfo, "Name:"))
		loop, Parse, wanInfo, `n
		{
			if(InStr(A_LoopField, "Address"))
			{
				Global wanIP := Trim(SubStr(A_LoopField, InStr(A_LoopField, ":")+3), "`r`n")
				break
			}
		}
	}
	return
}

debugQuit()
{
	MsgBox Debug Stop.
	WinActivate, ahk_class Notepad++
	ExitApp
}
Does anyone have any pointers?

EDIT1: Updated to show OP has been solved (thanks to gregster)... now looking for help with Debug Item #1.

EDIT2: Updated to show SP has been solved (Debug Item #1) (thanks again to gregster)... now looking for help on Debug Item #4.
Last edited by TXShooter on 30 Mar 2018, 15:07, edited 2 times in total.
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Re: SetTimer Issue, or Bad Idea issue?

29 Mar 2018, 18:08

I also noticed that these lines aren't doing their jobs either:

Code: Select all

	IniWrite, %wanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, ExtIP
	IniWrite, %lanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, IpAddr
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 07:07

Did I put this into the incorrect place on the Forum for help? I would've thought by now somebody would've suggested something.
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 07:41

Consider the difference between accessing global variables from inside a function and super-global variables: https://autohotkey.com/docs/Functions.htm#Global
This in a function

Code: Select all

Global lanIP
accesses the (global) variable lanIP (if it exists) in this specific function or creates it as (normally) global, but does not make it global for other functions. To do that, define these variables as (super-)global in the auto-execute section of the script (or, you can probably access them via global in the specific functions, again).

So, wlanIP and lanIP are most probably empty here:

Code: Select all

IniWrite, %wanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, ExtIP
IniWrite, %lanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, IpAddr
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 08:13

gregster wrote:Consider the difference between accessing global variables from inside a function and super-global variables: https://autohotkey.com/docs/Functions.htm#Global
This in a function

Code: Select all

Global lanIP
accesses the (global) variable lanIP (if it exists) in this specific function or creates it as (normally) global, but does not make it global for other functions. To do that, define these variables as (super-)global in the auto-execute section of the script (or, you can probably access them via global in the specific functions, again).

So, wlanIP and lanIP are most probably empty here:

Code: Select all

IniWrite, %wanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, ExtIP
IniWrite, %lanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, IpAddr
If that's the case, wouldn't this line be having an issue too?

Code: Select all

MsgBox, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%`nTime: %Time%
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 08:44

TXShooter wrote: If that's the case, wouldn't this line be having an issue too?

Code: Select all

MsgBox, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%`nTime: %Time%
Yes, it should... at least, inside in the GetInfo() function, where you write to the ini-file. If you are using it in a label/sub section like above, it is in the global space anyway. That's a big difference.

Code: Select all

;global x		; uncomment and compare
func()
msgbox % x
func2()
ExitApp

func(){
	global x := 5

}
func2(){
	msgbox % x
}
Last edited by gregster on 30 Mar 2018, 08:54, edited 2 times in total.
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 08:49

Btw, why not just use a return value with your functions?

Code: Select all

GetLanIP(){
...
return lanIP
}

GetInfo(){
...
lanIP := GetLanIP()
...
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 08:55

gregster wrote:Btw, why not just use a return value with your functions?

Code: Select all

GetLanIP(){
...
return lanIP
}

GetInfo(){
...
lanIP := GetLanIP()
...
Because I couldn't figure out how to return a value with the function (I originally wanted to do this, but... ). Now after looking at your reply I may give that a try.
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Moved the Globals to the Variable Section helped

30 Mar 2018, 08:59

I did as you suggested, gregster, and I also moved the Global definitions to the 'Variable's section. That fixed Debug Item #2.

Now to find some better way of obtaining the WAN and LAN IP addresses without using the clipboard. Got any thoughts on that?
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 09:21

Something like this, I would suggest:

Code: Select all

msgbox % GetLanIP()

GetLanIP()			; Credit https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
{
	tempfile := "C:\Users\g\Desktop\ipinfo.txt"				; adjust filepath
	FileDelete, % tempfile
	run, %ComSpec% /c ipconfig > %tempfile%, , Hide		
	While !FileExist(tempfile)
		sleep, 100
	FileRead lanInfo, % tempfile						
	loop, Parse, lanInfo, `n
	{
		if(InStr(A_LoopField, "IPv4"))
		{
			lanIp := Trim(SubStr(A_LoopField, InStr(A_LoopField, ":")+2), "`r`n")
			FileDelete, % tempfile
			Return lanIP
		}
	}
	lanIP := "Check Network Connection"
	Return lanIP
}
Adjust the file path to your needs!
For now, I kept global, but if you moved it all to the main part, you can remove it... here, the return value delivers the IP. global is not needed, if you use the return value.
Last edited by gregster on 30 Mar 2018, 09:52, edited 3 times in total.
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 09:40

I updated the code in the box above to an improved version - but it is only tested superficially and can most probably be improved further (I stuck mainly to the original code). :D
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Re: SetTimer Issue, or Bad Idea issue?

30 Mar 2018, 15:06

gregster wrote:I updated the code in the box above to an improved version - but it is only tested superficially and can most probably be improved further (I stuck mainly to the original code). :D
That's awesome! I didn't even think to use a temporary file. That works like a charm.

And with that information I went to figure out the WAN IP aspect (to keep from using the clipboard), and I came across this code that helped tremendously.

So that takes care of all but one item... to register this script so that it will run on every boot.

I really appreciate the help!
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

WhereAmI.ahk

30 Mar 2018, 15:12

The functional code:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WhereAmI.ahk
; Created by: TXShooter with help from https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/ and https://autohotkey.com/boards/viewtopic.php?f=5&t=46333
; Purpose: 	To write a file to the MS OneDrive cloud folder the system's pertinent information for tracking purposes and other uses like a psuedo dyndns.
;			Run EXE at startup in the System Tray with Tool Tips giving updated information.
;
; Date: 		2018.03.25
; Revision: 	1
; Synopsis: 	When executed, this script will perform the following in sequence:
;					1) Read from the system Registry where the Microsoft OneDrive folder is located,
;					2) Start a timer to cycle every X minutes (i.e. 15 minutes)
;					3) Loop the following at the start of each timed cycle:
;						A) Get the LAN IP Address (lanIP). Error if not valid.
;						B) Get the WAN IP Address (wanIP). Error if not valid.
;						C) Get current date and time (time)
;						D) Get OS Version
;						E) Write INI File with the above information in the root of the OneDrive folder
;						F) Update Systray's icon tool tip
;					4) Write to Windows System Registry's HKLM 'Run' key the EXE Path for automatic startup at boot.
;
; DEBUG ISSUES:
;					1) Using the clipboard to obtain the IP Addresses prevents usage of the clipboard for normal Windows operations. [SOLVED]
;					2) The Tool Tip for the Systray is not updating the IP Addresses at all, whereas the double-click 'Open' SysTray Menu label is working correctly. [SOLVED]
;						a) Tool Tip for the Sysray for the variable "User" and "OSVer" are working correctly.
;					3) The variable "Time" is not updating. {SOLVED]
;					4) Unable to add the EXE file's path to the System Registry for unknown reason(s). Could be a permission issue?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Environment Setup:
	#NoEnv  						; Recommended for performance and compatibility with future AutoHotkey releases.
	SendMode Input  				; Recommended for new scripts due to its superior speed and reliability.
	SetWorkingDir %A_ScriptDir%  		; Ensures a consistent starting directory.
	#SingleInstance, Force
	#Persistent

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SysTray Menu Setup:
	Menu, Tray, NoStandard
	Menu, Tray, Add, Exit, Exit
	Menu, Tray, Add, Open, Open
	Menu, Tray, Default, Open

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Variables:
	Global wanIP
	Global lanIP
	Global OneDriveFolder := ""
		RegRead, OneDriveFolder, HKEY_CURRENT_USER\Environment, OneDrive
		OneDriveFolder := OneDriveFolder . "\"
	Global WhereAmIKey := "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
	Global WhereAmIString := "C:\Program Files\WhereAmI\WhereAmI.exe"
		RegWrite, REG_SZ, HKLM, %WhereAmIKey%, WhereAmI, %WhereAmIString%
	clipSave := ClipboardAll
	Clipboard := clipSave


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Script:
	SetTimer, GetInfo, 1000			; Timer in milliseconds
	GetInfo()						; Immediately call GetInfo()
	Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main:
GetInfo()
{
	Global Time = A_Now
	FormatTime, Time,, yyyy.MM.dd - HH:mm:ss
   	GetLanIP()
   	GetWanIP()
	Menu, Tray, Tip, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%
	IniWrite, %A_Username%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, User
	IniWrite, %A_OSVersion%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, OSVer
	IniWrite, %wanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, ExtIP
	IniWrite, %lanIP%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, IpAddr
	IniWrite, %Time%, %OneDriveFolder%%A_ComputerName%.ini, %A_ComputerName%, Time of last update
	return
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Labels:
Exit:
	ExitApp

Open:
	MsgBox, User: %A_Username%`nComputer Name: %A_ComputerName%`nLanIP: %lanIP%`nWanIP: %wanIP%`nTime: %Time%
	return

	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Functions:
GetLanIP()			; Credit https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
{
	tempfile := "C:\Temp\ipinfo.txt"				; adjust filepath
	FileDelete, % tempfile
	run, %ComSpec% /c ipconfig > %tempfile%, , Hide		
	While !FileExist(tempfile)
		sleep, 100
	FileRead lanInfo, % tempfile					; The above credited to gregster.

	loop, Parse, lanInfo, `n
	{
		if(InStr(A_LoopField, "IPv4"))
		{
			lanIp := Trim(SubStr(A_LoopField, InStr(A_LoopField, ":")+2), "`r`n")
			FileDelete, % tempfile
			Return lanIP
		}
	}
	lanIP := "Check Network Connection"
	Return lanIP
}

GetWanIP()			; Credit https://www.reddit.com/r/AutoHotkey/comments/6haneq/external_ip_address/
{
	output := func("nslookup myip.opendns.com resolver1.opendns.com")
	wanInfo := output
	if(!InStr(wanInfo, "Name:"))
	{
		wanIP := "Check Network Connection"
		return wanIP
	}
	else
	{
		wanInfo := SubStr(wanInfo, instr(wanInfo, "Name:"))
		loop, Parse, wanInfo, `n
		{
			if(InStr(A_LoopField, "Address"))
			{
				wanIP := Trim(SubStr(A_LoopField, InStr(A_LoopField, ":")+3), "`r`n")
				break
			}
		}
	}
	return wanIP
}

debugQuit()
{
	MsgBox Debug Stop.
	WinActivate, ahk_class Notepad++
	ExitApp
}

func(cmdline)						; Credited to Bobo https://autohotkey.com/boards/codeboxplus/download/206426-1
{
	DetectHiddenWindows On
	Run %ComSpec%,, Hide, pid
	WinWait ahk_pid %pid%
	DllCall("AttachConsole", "UInt", pid)
	WshShell := ComObjCreate("Wscript.Shell")
	exec := WshShell.Exec(cmdline)
	output := exec.StdOut.ReadAll()
	DllCall("FreeConsole")
	Process Close, %pid%
	Return output
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], inseption86, Mannaia666, mikeyww and 150 guests