Execute script from URL Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JaydeNpie
Posts: 21
Joined: 04 Jan 2019, 04:13

Execute script from URL

24 Jun 2019, 03:14

Hello. I've made a script for a game, and share it with my friends. Since they all have different specs and stats, I have to update theirs manually and resend in every time. I was wondering if there was a way for me to put the script on a website, then run a command from the script to read from that website. This way, I can update it and all they have to do is reload their script. I havent the slightest how to do this though. :roll:

Edit: Here's the code in question:

Code: Select all

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

MsgBox, Game script now active. Currently in Off Mode. Press Alt + Shift + F1 to view general keybinds.

global sstrue := 0
global round := 0
global time := 0
global text := " "
global st := 0
global tb1 := 0
global t1 := 0
global tb2 := 0
global t2 := 0
global b1 := 0
global b2 := 0
global statx := 0
global staty := 0

global currentMode := 0 ; BCO Mode = 1, AX2 Mode = 2, Ro-Ghoul Mode = 3, Off = 0

global doSpam := 0

global totalStopped := 0

global keybindsActiveBox := 1 ; Same as current mode numbers

!+F1:: keybindGUI()

keybindGUI(){
	Gui, AKB:New,, Keybinds
	if global currentMode = 1
		{
		Gui, BCOGui:New
		Gui, Add, StatusBar
		if global totalStopped<1
			SB_SetText("So far, 0 Anti-Afk Pop-ups have been deterred.")
		else
			SB_SetText("So far, " . totalStopped . " Anti-Afk Pop-ups have been deterred.")
		Gui, Add, Tab3,, General|BCO|Resolutions
		Gui, Tab, General,, Exact
		Gui, Add, Text,, Ctrl + F11 = Change script mode
		Gui, Add, Text,, Alt + Shift + F1 = View Keybinds
		Gui, Add, Text,, Numpad 5 = Pause Script
		Gui, Add, Text,, Numpad 6 = Reload Script
		Gui, Tab, BCO,, Exact
		Gui, Add, Text,, Numpad 0 = Stop all looping
		Gui, Add, Text,, Numpad 1 = Loop X
		Gui, Add, Text,, Numpad 2 = Loop Z
		Gui, Add, Text,, Numpad 3 = Loop Left Click
		Gui, Add, Text,, Numpad 4 = Loop Magic
		Gui, Tab, Resolutions,, Exact
		Gui, Add, Text,, Supported resolutions:
		Gui, Add, Text,, 800x600
		Gui, Add, Text,, 1024x768
		Gui, Add, Text,, 1152x864
		Gui, Add, Text,, 1176x664
		Gui, Add, Text,, 1280x720
		Gui, Add, Text,, 1280x768
		Gui, Add, Text,, 1280x800
		Gui, Add, Text,, 1280x960
		Gui, Add, Text,, 1280x1024
		Gui, Add, Text,, 1360x768
		Gui, Add, Text,, 1366x768
		Gui, Add, Text,, 1440x900
		Gui, Add, Text,, 1600x900
		Gui, Add, Text,, 1600x1024
		Gui, Add, Text,, 1680x1050
		Gui, Add, Text,, 1768x992
		Gui, Add, Text,, 1920x1080
		Gui, Show
		exit
		}
	if global currentMode = 2
		{
		Gui, Add, Tab2,, General|AX2
		Gui, Tab, General,, Exact
		Gui, Add, Text,, Ctrl + F11 = Change script mode
		Gui, Add, Text,, Alt + Shift + F1 = View Keybinds
		Gui, Add, Text,, Numpad 5 = Pause Script
		Gui, Add, Text,, Numpad 6 = Reload Script
		Gui, Tab, AX2,, Exact
		Gui, Add, Text,, Mouse Button 4 = Q (Can be held)
		Gui, Add, Text,, Mouse Button 5 = Z (Can be held)
		Gui, Show
		exit
		}
	if global currentMode = 3
		{
		Gui, Add, Tab2,, General|Ro-Ghoul
		Gui, Tab, General,, Exact
		Gui, Add, Text,, Ctrl + F11 = Change script mode
		Gui, Add, Text,, Alt + Shift + F1 = View Keybinds
		Gui, Add, Text,, Numpad 5 = Pause Script
		Gui, Add, Text,, Numpad 6 = Reload Script
		Gui, Tab, Ro-Ghoul,, Exact
		Gui, Add, Text,, Middle Mouse Click = Loop W
		Gui, Add, Text,, Numpad3 = Auto-Clicker
		Gui, Show
		exit
		}
	if global currentMode = 0
		{
		Gui, Add, Tab,, General
		Gui, Tab, General,, Exact
		Gui, Add, Text,, Ctrl + F11 = Change script mode
		Gui, Add, Text,, Alt + Shift + F1 = View Keybinds
		Gui, Add, Text,, Numpad 5 = Pause Script
		Gui, Add, Text,, Numpad 6 = Reload Script
		Gui, Show
		}
	}

screenYes(){
	Si5:
	global sstrue := 1
	Gui, Destroy
	MsgBox, A screenshot will be taken for every hour of continuous looping.
	if (sstrue = 52){
		No5:
		global sstrue := 0
		Gui, Destroy
		MsgBox, No screenshots will be taken.
		return
		}
	return
	}

^F11:: changeMode()

changeMode(){
	if global currentMode = 1
		{
		global currentMode := 2
		MsgBox, Switched to Anime Cross 2 Mode. Make sure NumLock is on, otherwise NumPad keybind will not work. Press Alt + Shift + F1 to view this mode's keybinds.
		return
		}
	if global currentMode = 2
		{
		global currentMode := 3
		MsgBox, Switched to Ro-Ghoul Mode. Make sure NumLock is on, otherwise NumPad keybind will not work. Press Alt + Shift + F1 to view this mode's keybinds.
		return
		}
	if global currentMode = 3
		{
		global currentMode := 0
		MsgBox, Script turned off. Make sure NumLock is on, otherwise NumPad keybind will not work. Press Alt + Shift + F1 to view general keybinds.
		return
		}
	if global currentMode = 0
		{
		global currentMode := 1
		MsgBox, Switched to Black Clover Online Mode. Make sure NumLock is on, otherwise NumPad keybind will not work. 
		MsgBox, Detected resolution of %A_ScreenWidth%x%A_ScreenHeight%. Press Alt + Shift + F1 to view supported resolutions and keybinds.
		Gui, Add, Text, x72 y9 w220 h30 , Would you like to screenshot during looping?
		Gui, Add, Button, x32 y49 w100 h30 gSi5, &Yes
		Gui, Add, Button, x222 y49 w100 h30 gNo5, &No
		Gui, Show, x448 y513 h102 w373, Screenshots
		return
		}
	}
	
magGui(){
	Gui, Add, Button, x12 y39 w120 h30 gRLoop, Loop &R
	Gui, Add, Button, x152 y39 w130 h30 gAllLoop, Loop &All Magic
	Gui, Add, Text, x82 y9 w110 h20 , Loop R or all magic?
	Gui, Show, x528 y471 h77 w297, Pick your Punishment
	}
	
mouseRNG(){
	Loop, 3
		{
		Random, mrx, 1, %A_ScreenWidth%
		Random, mry, 1, %A_ScreenHeight%
		MouseMove, %mrx%, %mry%
		sleep, 125
		}
	return
	}
	
checkAndSetRes(){
	if (A_ScreenWidth = 1360 or A_ScreenWidth = 1366) && (A_ScreenHeight = 768){
		tb1 := 1081
		t1 := 608
		tb2 := 1162
		t2 := 616
		b1 := 632
		b2 := 640
		statx := 853
		staty := 702
		}
	if (A_ScreenWidth = 1600) && (A_ScreenHeight = 1024){
		tb1 := 1335
		t1 := 839
		tb2 := 1573
		t2 := 868
		b1 := 876
		b2 := 904
		statx := 1090
		staty := 950
		}
	if (A_ScreenWidth = 800) && (A_ScreenHeight = 600){
		tb1 := 514
		t1 := 438
		tb2 := 761
		t2 := 446
		b1 := 462
		b2 := 472
		statx := 290
		staty := 530
		}
	if (A_ScreenWidth = 1024) && (A_ScreenHeight = 768){
		tb1 := 731
		t1 := 607
		tb2 := 989
		t2 := 614
		b1 := 632
		b2 := 640
		statx := 520
		staty := 700
		}
	if (A_ScreenWidth = 1152) && (A_ScreenHeight = 864){
		tb1 := 864
		t1 := 703
		tb2 := 1115
		t2 := 710
		b1 := 743
		b2 := 738
		statx := 640
		staty := 800
		}
	if (A_ScreenWidth = 1176) && (A_ScreenHeight = 664){
		tb1 := 902
		t1 := 505
		tb2 := 1139
		t2 := 512
		b1 := 528
		b2 := 532
		statx := 660
		staty := 590
		}
	if (A_ScreenWidth = 1280) && (A_ScreenHeight = 720){
		tb1 := 987
		t1 := 560
		tb2 := 1235
		t2 := 567
		b1 := 584
		b2 := 590
		statx := 770
		staty := 650
		}
	if (A_ScreenWidth = 1280) && (A_ScreenHeight = 768){
		tb1 := 991
		t1 := 606
		tb2 := 1240
		t2 := 615
		b1 := 631
		b2 := 640
		statx := 770
		staty := 700
		}
	if (A_ScreenWidth = 1280) && (A_ScreenHeight = 800){
		tb1 := 989
		t1 := 639
		tb2 := 1241
		t2 := 648
		b1 := 663
		b2 := 673
		statx := 770
		staty := 730
		}
	if (A_ScreenWidth = 1280) && (A_ScreenHeight = 960){
		tb1 := 992
		t1 := 802
		tb2 := 1243
		t2 := 806
		b1 := 823
		b2 := 827
		statx := 765
		staty := 890
		}
	if (A_ScreenWidth = 1280) && (A_ScreenHeight = 1024){
		tb1 := 992
		t1 := 862
		tb2 := 1245
		t2 := 871
		b1 := 887
		b2 := 896
		statx := 770
		staty := 950
		}
	if (A_ScreenWidth = 800) && (A_ScreenHeight = 600){
		tb1 := 1153
		t1 := 741
		tb2 := 1406
		t2 := 750
		b1 := 762
		b2 := 771
		statx := 930
		staty := 830
		}
	if (A_ScreenWidth = 1600) && (A_ScreenHeight = 900){
		tb1 := 1316
		t1 := 741
		tb2 := 1567
		t2 := 748
		b1 := 765
		b2 := 771
		statx := 1090
		staty := 830
		}
	if (A_ScreenWidth = 1680) && (A_ScreenHeight = 1050){
		tb1 := 1396
		t1 := 889
		tb2 := 1643
		t2 := 896
		b1 := 912
		b2 := 926
		statx := 1170
		staty := 990
		}
	if (A_ScreenWidth = 1768) && (A_ScreenHeight = 992){
		tb1 := 1477
		t1 := 833
		tb2 := 1733
		t2 := 839
		b1 := 855
		b2 := 865
		statx := 1260
		staty := 920
		}
	if (A_ScreenWidth = 1920) && (A_ScreenHeight = 1080){
		tb1 := 1634
		t1 := 919
		tb2 := 1868
		t2 := 926
		b1 := 943
		b2 := 950
		statx := 1410
		staty := 1010		
		}
	return
	}
	
delOldFile(){
	x = %A_NowUTC%
	x += -4, Hours
	x += -30, Minutes
	Time = %x%
	scanFolder := "C:\Users\JaydeNpie\Pictures\Roblox\*.*"
	OldFile =
	Loop, %scanFolder%
		{
		if (A_LoopFileTimeModified < Time){
			OldFile := A_LoopFileLongPath
			filerecycle, %OldFile%
			}
		}
	return
	}
	
checkForAntiAfk(){
	;This is the code used for Black Clover Online to detect and remove Anti-Auto Popups.
	checkAndSetRes()
	CoordMode, Pixel, Screen
	PixelSearch, gCoordX1, gCoordY1, %tb1%, %t1%, %tb2%, %t2%, 0x62FF67, 1, Fast
	if ErrorLevel = 0
		{
		st+=1
		CoordMode, Pixel, Screen
		MouseGetPos, mouseX, mouseY
		gCoordY1+=10
		sleep, 350
		Click, %gCoordX1% , %gCoordY1% 
		SoundPlay, *-1
		sleep, 350
		MouseMove, %mouseX% , %mouseY%
		global totalStopped := totalStopped + 1
		sleep, 500
		}
	PixelSearch, gCoordX2, gCoordY2, %tb1%, %b1%, %tb2%, %b2%, 0x62FF67, 1, Fast
	if ErrorLevel = 0
		{
		st+=1
		CoordMode, Pixel, Screen
		MouseGetPos, mouseX, mouseY
		gCoordY2+=10
		sleep, 350
		Click, %gCoordX2% , %gCoordY2% 
		SoundPlay, *-1
		sleep, 350
		MouseMove, %mouseX% , %mouseY%
		global totalStopped := totalStopped + 1
		sleep, 500
		}
	return
	}
	
checkForBcoMode(){
	if global currentMode = 1
		return
	else
		exit
	}

checkForAx2Mode(){
	if global currentMode = 2
		return
	else
		exit
	}

checkForRgMode(){
	if global currentMode= 3
		return
	else
		exit
	}

checkForBcoOrRgMode(){
	if global currentMode = 1
		return
	else
		{
		if global currentMode = 3
			return
		else
			exit
		}
	}

 #MaxThreadsPerHotkey 3

MButton::
#MaxThreadsPerHotkey 1
checkForRgMode()
if KeepWinZRunning  ; This means an underlying thread is already running the loop below.
	{
    KeepWinZRunning := false  ; Signal that thread's loop to stop.
    return  ; End this thread so that the one underneath will resume and see the change made by the line above.
	}
; Otherwise:
KeepWinZRunning := true
Loop
	{
   	 ; The next four lines are the action you want to repeat (update them to suit your preferences):
   	 SendInput w
	sleep, 25
    	; But leave the rest below unchanged.
   	 if not KeepWinZRunning  ; The user signaled the loop to stop by pressing Win-Z again.
       	 break  ; Break out of this loop.
	}
KeepWinZRunning := false  ; Reset in preparation for the next press of this hotkey.
return

XButton2:: zDown()	

zDown(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForAx2Mode()
	Send, {z down}
	}

XButton2 Up:: zUp()

zUp(){
	checkForAx2Mode()
	Send, {z up}
	}

XButton1:: qDown()

qDown(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForAx2Mode()
	Send, {q down}
	}

XButton1 Up:: qUp()

qUp(){
	checkForAx2Mode()
	 Send, {q up}
	}

Numpad0:: ceaseLoops()

ceaseLoops(){
	checkForBcoOrRgMode()
	global keepLooping := 0
	global doSpam := 0
	}	


Numpad1:: loopX()
	

loopX(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForBcoMode()
	MsgBox, Looping X. Press Numpad 0 to Stop.
	global keepLooping := 1
	totalStopped := 0
	while (keepLooping = 1)
	{
	if (sstrue = 1){
		if (round = 4){
			global time = time + 1
			global round := 0
			if (time = 3600){
				Send {PrintScreen}
				delOldFile()
				sleep, 500
				global time := 0
				}
			}
		}
	checkForAntiAfk()
	Send x
	sleep, 250	
	}
MsgBox, %totalStopped% Anti-Auto Pop-Ups were deterred. Phew!
}
	
Numpad2:: loopZ()

loopZ(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForBcoMode()
	MsgBox, Looping Z. Press Numpad 0 to Stop.
	global keepLooping := 1	
	totalStopped := 0
	while (keepLooping = 1)
	{
	if (sstrue = 1){
		if (round = 4){
			global time = time + 1
			global round := 0
			if (time = 3600){
				Send {PrintScreen}
				delOldFile()
				sleep, 500
				global time := 0
				}
			}
		}
	checkForAntiAfk()
	Send z
	}
MsgBox, %totalStopped% Anti-Auto Pop-Ups were deterred. Phew!
}

Numpad3:: loopLC()

loopLC(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForBcoOrRgMode()
	MsgBox, Looping Left Click. Press Numpad 0 to Stop.
	global keepLooping := 1
	totalStopped := 0
	while (keepLooping = 1){
	if (sstrue = 1){
			if (round = 12){
			global time = time + 1
			global round := 0
			if (time = 3600){
				Send {PrintScreen}
				delOldFile()
				sleep, 500
				global time := 0
				}
			}
		}
	checkForAntiAfk()
	CoordMode, Pixel, Screen
	Click
	}
MsgBox, %totalStopped% Anti-Auto Pop-Ups were deterred. Phew!
}

Numpad4:: loopSprint()

loopSprint(){
	if  global currentMode = 0
		{
		MsgBox, Script is switched off. Press Ctrl + F11 to switch modes, or Numpad5 to pause the script.
		exit
		}
	checkForBcoMode()
	MsgBox, Looping Sprint. Press Numpad 0 to Stop.
	totalStopped := 0
	ml := 0
	magGui()
	}
	
loopAllMagic(){
	AllLoop:
	global keepLooping := 1
	Gui, Destroy
	while (keepLooping = 1){
		if (sstrue = 1){
			if (round = 42){
				Send {PrintScreen}
				delOldFile()
				sleep, 500
				global round := 0
				}
			}
		checkForAntiAfk()
		Send {w up}
		sleep, 125
		mouseRNG()
		CoordMode, Pixel, Screen
		sleep, 125
		MouseMove, %statx%, %staty%, 10
		sleep, 125
		Click		
		sleep, 250
		Send {Shift}
		sleep, 125
		Send {Left down}
		sleep, 650
		Send {Left up}
		sleep, 125
		Send {Shift}
		sleep 250
		Send {Ctrl}
		sleep, 250
		if (keepLooping = 0){
			break
			}
		Send {w down}
		Loop, 3
			{
			checkForAntiAfk()
			if (keepLooping = 0){
				break 2
				}
			sleep, 2500
			Send v
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			Send g
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			Send h
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			checkForAntiAfk()
			Send r
			sleep, 2500
			if (ml = 2){
				break 2
				}
			if (keepLooping = 0){
				break 2
				}
			Send t
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			Send f
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			checkForAntiAfk()
			Send y
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
			Send r
			sleep, 2500
			if (keepLooping = 0){
				break 2
				}
		checkForAntiAfk()
		Send {c down}
		sleep, 12000
		Send {c up}
		ml+=1
		}
		sleep, 3000
		ml := 0
		checkForAntiAfk()
		Send {Escape}
		sleep, 250
		Send r
		sleep, 250
		Send {Enter}
		sleep, 10000
		}
	MsgBox, %totalStopped% Anti-Auto Pop-Ups were deterred. Phew!
	return
	}
	
rMag(){
	RLoop:
		global keepLooping := 1
	Gui, Destroy
	while (keepLooping = 1){
		checkForAntiAfk()
		Send {w up}
		sleep, 125
		mouseRNG()
		CoordMode, Pixel, Screen
		sleep, 125
		MouseMove, %statx%, %staty%, 10
		sleep, 125
		Click		
		sleep, 250
		Send {Shift}
		sleep, 125
		Send {Left down}
		sleep, 650
		Send {Left up}
		sleep, 125
		Send {Shift}
		sleep 250
		Send {Ctrl}
		sleep, 250
		if (keepLooping = 0){
			break
			}
		Send {w down}
		Loop, 7
			{
			checkForAntiAfk()
			l+=1
			Send r
			if l = 7
				{
				sleep, 1250
				continue, 1
				}
			sleep, 3125
			if (keepLooping = 0){
				break 2
				}
			}
        }
        l := 0
        Send {c down}
        sleep, 9500
        Send {c up}
		sleep, 3000
		ml := 0
		checkForAntiAfk()
		Send {Escape}
		sleep, 250
		Send r
		sleep, 250
		Send {Enter}
		sleep, 10000
		}
		
Numpad6::Pause
For example, I'd want it to look something like this:

Code: Select all

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

; Run "https www.scriptishere.com /"
Broken Link for safety
RickC
Posts: 299
Joined: 27 Oct 2013, 08:32

Re: Execute script from URL

24 Jun 2019, 11:27

Have you looked into using Google Drive/OneDrive/Dropbox etc. and using a public folder to which your friends have the URL? I use this method for a shared journal. I update the local copy of the journal and the Google Drive app takes care of the syncing.

Rather than execute from the URL, perhaps create a simple 'downloader' using UrlDownloadToFile?
gummby8
Posts: 14
Joined: 03 Feb 2016, 11:53

Re: Execute script from URL

24 Jun 2019, 11:47

Oh I can answer this....YES!

I did this with a script I wanted to give my friends, but it was in testing all teh time so I was constantly making revisions.

Rather than giving them new AHK files every revision I created this launcher to pull the AHK from a website and run. Being perfectly honest I have not looked at this script in over 6 years so I can't tell you exactly how it works anymore.
I don't think DynaRun2 is even called at all

Pretty much build the URL to your .ahk. put that in a variable. And I think the second parameter of DynaRun is whatever you want the name of the script to be.

I didn't make this, someone else did and i have no idea who/where to give credit.

Code: Select all

name:= "http preview.lifeplugins.net /"  Broken Link for safety
urlraw:="Cephalopod.ahk"

url= %name%%urlraw%


test:= UrlDownloadToVar(url)


DynaRun(test,"Cephalopod")












UrlDownloadToVar(URL) {
 ComObjError(false)
 WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
 WebRequest.Open("GET", URL)
 WebRequest.Send()
 Return WebRequest.ResponseText
}



DynaRun(TempScript, pipename:="", params:=""){
   static _:="uint",__:="Ptr"
   If (pipename = "")
      name := "AHK" A_TickCount
   Else
      name := pipename
   __PIPE_GA_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,__,0,__,0)
   __PIPE_    := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,__,0,__,0)
   if (__PIPE_=-1 or __PIPE_GA_=-1)
      Return 0
   If A_IsCompiled || (A_IsDll && DllCall(A_AhkPath "\ahkgetvar","Str","A_IsCompiled")) ; allow compiled executable to execute dynamic scripts. Requires AHK_H
    Run, % "`"" A_AhkPath "`" /E `"\\.\pipe\" name "`"" (params?" " params:""),,UseErrorLevel HIDE, PID
   else
    Run, % "`"" A_AhkPath "`" `"\\.\pipe\" name "`"" (params?" " params:""),,UseErrorLevel HIDE, PID
   If ErrorLevel
      MsgBox, 262144, ERROR,% "Could not open file:`n" __AHK_EXE_ "`"\\.\pipe\" name "`""
   DllCall("ConnectNamedPipe",__,__PIPE_GA_,__,0)
   DllCall("CloseHandle",__,__PIPE_GA_)
   DllCall("ConnectNamedPipe",__,__PIPE_,__,0)
   script := (A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) TempScript
   if !DllCall("WriteFile",__,__PIPE_,"str",script,_,(StrLen(script)+1)*(A_IsUnicode ? 2 : 1),_ "*",0,__,0)
      Return DllCall("CloseHandle",__,__PIPE_),A_LastError
   DllCall("CloseHandle",__,__PIPE_)
   Return PID
}









DynaRun2(TempScript, pipename="")
{
   static _:="uint",@:="Ptr"
   If pipename =
      name := "AHK" A_TickCount
   Else
      name := pipename
   __PIPE_GA_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
   __PIPE_    := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
   if (__PIPE_=-1 or __PIPE_GA_=-1)
      Return 0
   Run, %A_AhkPath% "\\.\pipe\%name%",,UseErrorLevel HIDE, PID
   If ErrorLevel
      MsgBox, 262144, ERROR,% "Could not open file:`n" __AHK_EXE_ """\\.\pipe\" name """"
   DllCall("ConnectNamedPipe",@,__PIPE_GA_,@,0)
   DllCall("CloseHandle",@,__PIPE_GA_)
   DllCall("ConnectNamedPipe",@,__PIPE_,@,0)
   script := (A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) TempScript
   if !DllCall("WriteFile",@,__PIPE_,"str",script,_,(StrLen(script)+1)*(A_IsUnicode ? 2 : 1),_ "*",0,@,0)
      Return A_LastError,DllCall("CloseHandle",@,__PIPE_)
   DllCall("CloseHandle",@,__PIPE_)
   Return PID
}
User avatar
JaydeNpie
Posts: 21
Joined: 04 Jan 2019, 04:13

Re: Execute script from URL

24 Jun 2019, 13:06

I'll try the Google Drive and that script, but as of now im on the road, and not on my computer. Ill make sure to update when I try them. Thanks for the replies!!
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Execute script from URL  Topic is solved

25 Jun 2019, 08:57

If you are sending them the .ahk file, not the compiled exe, then you can just download and override the running script file and then reload.

Example:

Code: Select all

global scriptVersion := "1.10"

AutoUpdate()

AutoUpdate() {
	URL_SCRIPT := "https://git.io/fjr4v"
	URL_VERSION := "https://git.io/fjr4f"

	whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	whr.Open("GET", URL_VERSION)
	whr.Send()
	onlineVersion := whr.ResponseText

	if (onlineVersion > scriptVersion) {
		UrlDownloadToFile, % URL_SCRIPT, % A_ScriptFullPath
		Reload
	}
}

MsgBox, % scriptVersion
ExitApp
User avatar
JaydeNpie
Posts: 21
Joined: 04 Jan 2019, 04:13

Re: Execute script from URL

27 Jun 2019, 08:12

Thanks guys! I tried gummyby8's and tmplinshi's, and both worked for what I wanted to do. I chose tmplinshi's as the answer for simplicity's sake. Thanks again, and sorry I took so long. I was at a hotel away from home :clap: :clap: :clap:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, haomingchen1998 and 128 guests