Random text view - text

I'm having a problem because when I touch my button sometimes my text doesn't appear...
function randomText(event)
display.remove(mmDis)
local a = { "Cristiano ronaldo jest najlepszy!",
"messi jest dobry!","lewandowski jest ok", "diego lopez to bramkarz realu"
}
com = (a[math.random(1, #a)])
local mmDis = display.newText(tostring(com),
display.contentWidth*0.57, display.contentHeight*0.7,
display.contentWidth*0.9, display.contentHeight*0.8, "Impact", 30)
mmDis.y=20
mmDis.x=190
mmDis:setFillColor(0, 0, 0, 1)
mmDis.anchorY = 0
end
play:addEventListener ("tap", randomText )

Related

Corona sdk random text

I`m have a problem because when i touch my button sometimes not appear my text... (Sorry for my English!)
Code:
function randomText(event)
display.remove(mmDis)
local a = {"Cristiano ronaldo jest najlepszy!","messi jest dobry!","lewandowski jest ok","diego lopez to bramkarz realu"}
com = (a[math.random(1,#a)])
local mmDis = display.newText(tostring(com),
display.contentWidth*0.57, display.contentHeight*0.7,
display.contentWidth*0.9, display.contentHeight*0.8, "Impact", 30)
mmDis.y=20
mmDis.x=190
mmDis:setFillColor(0, 0, 0, 1)
mmDis.anchorY = 0
end
play:addEventListener ("tap", randomText )
end
end
play:addEventListener( "touch", object )
Make sure you are localizing your variables properly. You need to declare "mmDis" outside your function, and then do not localize it inside the function. Something like this
local mmDis* -- this will ensure code from here on out all use the SAME "mmDis"
function randomText(event)
display.remove(mmDis)
local a = {"Cristiano ronaldo jest najlepszy!","messi jest dobry!","lewandowski jest ok","diego lopez to bramkarz realu"}
com = (a[math.random(1,#a)])
-- NOTICE how I removed the local keyword below.
-- This will ensure your code is talking about the same "mmDis"
-- you declared before your function
mmDis = display.newText(tostring(com),
display.contentWidth*0.57, display.contentHeight*0.7,
display.contentWidth*0.9, display.contentHeight*0.8, "Impact", 30)
mmDis.y=20
mmDis.x=190
mmDis:setFillColor(0, 0, 0, 1)
mmDis.anchorY = 0
end
play:addEventListener ("tap", randomText )
end
end
play:addEventListener( "touch", object )
Ultimately, the problem you were having is that you were not removing the old text off the screen because mmDis was localized inside the randomText function. Make sure you localize your variables with proper scope. Here's a good read about it http://lua-users.org/wiki/ScopeTutorial
local mmDis
function randomText(event)
if event.phase == "began" then
if mmDis then
display.remove(mmDis)
end
local a = {"Cristiano ronaldo jest najlepszy!","messi jest dobry!","lewandowski jest ok","diego lopez to bramkarz realu"}
local com = a[math.random(1,#a)]
mmDis = display.newText(tostring(com),
display.contentWidth*0.57, display.contentHeight*0.7,
display.contentWidth*0.9, display.contentHeight*0.8, "Impact", 30)
mmDis.y=20
mmDis.x=190
mmDis:setFillColor(0, 0, 0, 1)
mmDis.anchorY = 0
end
end
play:addEventListener ("tap", randomText )
end
end
play:addEventListener( "touch", object )
Try this and see.

Load Excel File To Powerbuilder

I have this code for buttonclicked event to load excel and text file to powerbuilder and the excel data is not copied i.e ll_return_xls <= 0 and thus when i want to load it to db i will get error since it has no value or data in it...The problem here is i get the data from text file but not from the excel file...Any help will be appreciated
long ll_return
long ll_return_xls
OLEObject excel
IF rb_file.checked then
IF dwo.Name = "b_browse_meters" THEN // Browse Button Clicked for Text
ll_return = GetFileOpenName ( "Select Meter File", is_fullname, is_filename, "TXT", &
"Text Files (*.txt), *.txt" )
if ll_return < 1 then
gnv_msg.f_mensaje("EX28", "", "", OK!)
return
end if
END IF // Browse Button Clicked
END IF
IF dwo.Name ="b_browse_meters_xls" THEN // Browse Button Clicked for Excel
ll_return_xls = GetFileOpenName ( "Select Meter File", is_fullname, is_filename, "XLS", &
"Excel Files (*.xls), *.xls" )
if ll_return_xls < 1 then
gnv_msg.f_mensaje("EX28", "", "", OK!)
return
end if
excel = create oleobject
excel.ConnectToNewObject( "excel.application" )
excel.visible = false
excel.workbooks.open( is_fullname)
excel.Range("A1:A2").Select
excel.ActiveCell.CurrentRegion.Select()
ClipBoard('')
excel.Selection.Copy()
ClipBoard('')
excel.ActiveWorkbook.Close
excel.Disconnectobject()
Destroy excel
END IF // Browse Button Clicked
And Function to load it the text and excel data
long ll_return, ll_arr_len, ll_loop, ll_indx, ll_pass = 0
integer li_rc, li_file_nbr, li_fr_rc //File Read Return Code
string ls_file, ls_line, ls_msg
string lsa_meters[], lsa_meter_pass[]
string ls_meters
long ll_total_valid, ll_total_aparatos
SetPointer(HourGlass!)
if IsValid(w_progbar) then Close(w_progbar)
openwithparm(w_progbar,"Uploading file data ...")
w_progbar.uo_progress_bar.set_position(10)
li_rc = SUCCESS
ll_total_aparatos = 0
ll_total_valid = 0
// Open file
if li_rc = SUCCESS then
ls_file = is_fullname
li_file_nbr = FileOpen(ls_file, LineMode!)
if IsNull(li_file_nbr) or li_file_nbr < 1 then
li_rc = NO_ACTION
end if
end if
// Read file, store serial numbers into array lsa_meters[]
if li_rc = SUCCESS then // File Opened
ll_indx = 0
do while ll_indx > -1 and li_rc = SUCCESS
li_fr_rc = FileRead(li_file_nbr, ls_line)
choose case li_fr_rc
case is > 0
ll_indx ++
lsa_meters[ll_indx] = ls_line
case 0, -100
ll_indx = -1
case -1
li_rc = FAILURE
gnv_msg.f_mensaje("EX21", "", "", OK!)
end choose
loop
if li_rc = SUCCESS then // File Read OK
ll_arr_len = UpperBound(lsa_meters)
if ll_arr_len > 0 then // Data found in file
for ll_loop = 1 to ll_arr_len step 1
if ib_meter then
ll_return = wf_luhn_check(lsa_meters[ll_loop])
ll_total_valid ++
else
if Len(lsa_meters[ll_loop]) >= 9 then
ll_return = 1
ll_total_valid ++
else
ll_return = -1
end if
end if
if ll_return = 1 then
if wf_aparatos_check(lsa_meters[ll_loop]) <= 0 then
ll_return = 1
else
ll_return = -1
ll_total_aparatos ++
end if
end if
if ll_return = 1 then
ll_pass++
lsa_meter_pass[ll_pass] = lsa_meters[ll_loop]
ls_meters = ls_meters + lsa_meters[ll_loop] + isk_TAB_PB
end if
w_progbar.uo_progress_bar.set_position(50 + ((ll_loop / ll_arr_len) * 40))
next
ll_arr_len = UpperBound(lsa_meter_pass)
if ll_arr_len > 0 then
dw_datos_ingreso.Object.num_ini[1] = lsa_meter_pass[1]
dw_datos_ingreso.Object.num_fin[1] = lsa_meter_pass[ll_arr_len]
is_meters_passed = ls_meters // Concatenated string of meter serial no.
il_apa_filemeters_count = ll_arr_len // Number of meters
else
li_rc = FAILURE
if ib_meter then
gnv_msg.f_mensaje("EX27", "", "", OK!)
else
gnv_msg.f_mensaje("EX22", "", "", OK!)
end if
if ll_total_valid = ll_total_aparatos then
gnv_msg.f_mensaje("EX23", "", "", OK!)
end if
end if
else
li_rc = FAILURE
gnv_msg.f_mensaje("EX24", "", "", OK!)
end if // Data found in file
end if // File Read OK
end if // File Opened
w_progbar.uo_progress_bar.set_position(100)
Close(w_progbar)
//Clean up
if li_file_nbr > 0 then
if FileClose(li_file_nbr) = FAILURE then
li_rc = FAILURE
gnv_msg.f_mensaje("EX25", "", "", OK!)
end if
end if
if ll_total_aparatos > 0 then
gnv_msg.f_mensaje("EW140", String(ll_total_aparatos) , "", OK!)
end if
if li_rc = FAILURE then
gnv_msg.f_mensaje("EX26", "", "", OK!)
RETURN FALSE
end if
RETURN TRUE
You can use the ODBC driver directly to the Excel file, and then build a Pipeline object that moves the data from the spreadsheet directly into the database. Don't write code you don't need to.

Corona + objects are not cleared between levels despite removeSelf + set to nil

I have multilevel game and all my objects stay 'empty' in memory between levels
what i mean is that if I set physics to hybrid, when i come again in the level, (or another level) it shows a box but without the picture. (and physics act on these empty boxes)
in the destroyScene I have made sure they are all
myObj:removeSelf()
myObj = nil
and i print a message to prove that it actually does it.
Also in the menu in the enterScene, just in case I do a
local prior_scene = storyboard.getprevious()
storyboard.purgescene( prior_scene )
and also tried a
storyboard.removeAll()
and even a
storyboard.purgeOnSceneChange = true
nothing works when i go to the next level, or into the same level again, all my previous objects are still here, I just don't get it
ok, it's gonna be a bit long but here the entire level. it does go through the destroyscene but somehow the display objects are not removed.
-- scene5
----------------------------------------------------------------------------------
local storyboard = require( "storyboard" )
local scene5 = storyboard.newScene()
function scene5:createScene( event )
local group = self.view
puppetJColCount = 0
print ("createScene5", puppetJColCount)
-----------------------------------------------------------------------------
-- CREATE display objects and add them to 'group' here.
-- Example use-case: Restore 'group' from previously saved state.
local physics = require("physics")
physics.start()
--physics.setScale(50)
puppetT_outside = false
puppetJ_outside = false
end -- scene -------------------------
-- set and release the catapult for puppetT
function arm_puppetT(event)
if event.phase == "began" then
display.getCurrentStage():setFocus(puppetT)
arming_puppetT = true
elseif event.phase == "moved" then
puppetT.x = event.x
puppetT.y = event.y
elseif event.phase == "ended" then
puppetT:applyLinearImpulse(event.xStart - event.x, event.yStart - event.y, puppetT.x, puppetT.y)
display.getCurrentStage():setFocus(nil)
arming_puppetT = false
end
end -- arm_puppetT ----------------------------------------------------------------------------
function build_puppetT()
-- setup puppetT
puppetT = display.newImage("assets/t-head-57-78.png")
puppetT.x = 80
puppetT.y = 100
physics.addBody(puppetT,"dynamic",{density=1.0, friction =0.3, bounce=0.2})
-- setup catapult event for arming puppetT
puppetT:addEventListener("touch", arm_puppetT)
end -- build_puppetT
function build_puppetJ_wall()
puppetJColCount = puppetJColCount + 1 -- how many columns of puppetJ
puppetJIJ = {} -- define puppetJ as an array
ij = 0
ipuppetJtot = 0
--puppetJColCount = 1
print ("build_puppetJ_wall puppetJColCount>" , puppetJColCount);
for i=1, 4 do
for j=1, puppetJColCount do
ij = ij + 1 -- # of puppetJs on the screen
ipuppetJtot = ipuppetJtot + 1
puppetJIJ = display.newImageRect("assets/j-head-70-75.png",80,75)
puppetJIJ.x = 600 + j*22
puppetJIJ.y = 100 + (puppetJIJ.height /2 * (i -1))
physics.addBody(puppetJIJ,"dynamic",{density=1.0,friction=0.3,bounce=0.2,isSensor=false,radius = var})
end
end
print ("building puppetJs #:" ,ipuppetJtot)
end -- build_puppetJ_wall -------------------------------------------------------------
function every_frame( event )
end -- every_frame --------------------------------------------------------------------
--reset level
function tap_reset_level(event)
puppetT:applyLinearImpulse(0, 0, 0, 0) -- stop the kick
print "restarting physics?"
puppetT:setLinearVelocity( 0, 0 ) -- stop the speed
puppetT.x = 80
puppetT.y = 100
for ij = 1,ipuppetJtot do
if (puppetJIJ) then
puppetJIJ:removeSelf()
puppetJIJ = nil ------
end
end
puppetT:removeSelf()
puppetT = nil
build_puppetJ_wall()
build_puppetT()
puppetT_outside = false
puppetJ_outside = false
-- physics.addBody(puppetT,"dynamic",{density=1.0, friction =0.3, bounce=0.2})
-- puppetT:addEventListener("touch", arm_puppetT)
--physics.start()
end -- tap_reset_level -------------------------------------------------------------------------
function tap_main_menu(event)
print ("going to main menu")
Runtime:removeEventListener("enterFrame", every_frame)
for ij = 1,ipuppetJtot do
if (puppetJIJ) then
puppetJIJ:removeSelf()
puppetJIJ = nil ------
end
end
if (puppetT) then
puppetT:removeSelf()
puppetT = nil
end
-- scene5:exitScene(scene5)
storyboard.gotoScene( "menu" )
end -- tap_main_menu ---------------------------------------------------------------------------------
-- ======================================================================================
-- Called immediately after scene has moved onscreen:
function scene5:enterScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- INSERT code here (e.g. start timers, load audio, start listeners, etc.)
-- group:insert( reset_btn )
-- load background
print ("enterScene scene5 " , puppetJtot)
background = display.newImage("assets/parliament-1200-800.png",0,0)
--create reset level button
reset_btn = display.newImageRect( "assets/btn_reset_128.png", 50,50)
reset_btn.x = 50
reset_btn.y = 50
--create main menu button
main_menu_btn = display.newImageRect( "assets/btn_home_128.png", 50,50)
main_menu_btn.x = 100
main_menu_btn.y = 50
-- show the level
local myText = display.newText( "Level 5", display.contentWidth - 60, 50, "Helvetica", 24 )
myText:setTextColor(255, 255, 255)
-- insert(floor);
floor = display.newRect(20,display.contentHeight - 40,display.contentWidth - 40 ,10)
physics.addBody(floor,"static",{density=1.0, friction =-0.3,bounce=-0.2,isSensor=false})
-- build puppetT
build_puppetT()
print ("width=" , display.contentWidth , "height=",display.contentHeight)
-- setup puppetJs
build_puppetJ_wall()
-- everything happens in everyframe function
Runtime:addEventListener("enterFrame", every_frame)
--add reset event
reset_btn:addEventListener( "tap", tap_reset_level )
--add mainmenu event
main_menu_btn:addEventListener( "tap", tap_main_menu )
end -- scene:enterScene ----------------------------------------------------------------
-- ======================================================================================
-- Called when scene is about to move offscreen:
function scene5:exitScene( event )
local group = self.view
print "scene:exitScene5"
-----------------------------------------------------------------------------
-- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
end -- exitScene
-- Called prior to the removal of scene's "view" (display group)
function scene5:destroyScene( event )
local group = self.view
Runtime:removeEventListener("enterFrame", every_frame)
puppetJColCount = 0
if (reset_btn) then
print ("destroyScene5 - removing tap_reset_level")
reset_btn:removeEventListener( "tap", tap_reset_level )
reset_btn:removeSelf()
end
reset_btn = nil
if (main_menu_btn) then
main_menu_btn:removeEventListener( "tap", tap_main_menu )
main_menu_btn:removeSelf()
end
main_menu_btn = nil
for ij = 1,ipuppetJtot do
if (puppetJIJ) then
puppetJIJ:removeSelf()
end
puppetJIJ = nil ------
end
if (puppetT) then
puppetT:removeSelf()
end
puppetT = nil
scene5 = nil
end -- destroyScene ------------------------------------------------------------
scene5:addEventListener( "createScene", scene5 )
scene5:addEventListener( "enterScene", scene5 )
scene5:addEventListener( "exitScene", scene5 )
scene5:addEventListener( "destroyScene", scene5 )
---------------------------------------------------------------------------------
return scene5
update:
Hi #DevfaR
Ha, I have restarted from scratch with the corona template and figured out a few things:
1) the exitScene/destroyScene actually does something if the local group is used to group display objects. it removes the display group !
not really obvious as there is only one declaration in it, no code as such
2) the reason why I had so much of removeSelf of objects all over the place is because nothing was working. So I tried pretty much everything under the web.
3) And the reason why it didnt work is because I was creating my display objects into a function. and somehow the display group is not passed there. if I move the code into the createScene function then indeed it is all cleared up when going to the next scene.
problem is .. I really would like to group my puppetCreation code !
e.g.
function scene:createScene( event )
local group = self.view
local physics = require("physics")
physics.start()
background = display.newImage("assets/bckg.png",0,0)
group:insert(background)
createPuppet1(group)
createPuppet2(group)
end
function createPuppet1(group)
puppet1= display.newImage("assets/puppet1.png",0,0)
group:insert(puppet1)
end
function createPuppet2(group)
puppet2= display.newImage("assets/puppet2.png",0,0)
group:insert(puppet2)
end
I passed (group) because the function createPuppet doesnt let me specify
local group = self.view
my email address is edualczatebed#gmail.com
thank you for your help
there's a lot of bug in your code the way you implement it is not good because when you go to a scene and then you switch to another scene your removing all of the object on the destroyScene together with it's listener which is not very efficient i cannot point out what's causing the problem because like i said there is a lot of bug in your code. i think you didn't quite understand how to use a storyboard on Corona. to give you an idea on how will you solve your problem i will implement some code for you to understand that even if you do not remove the object on destroyScene you can remove the object via it's on display groups.
local rectangle
local circle
local function nextScene(event)
storyboard.gotoScene( "scene_2", "fade", "500")
end
-- Called when the scene's view does not exist:
function scene:createScene( event )
local group = self.view
-----------------------------------------------------------------------------
rectangle = display.newRect(100,100,100,100)
rectangle:setFillColor(255,0,0)
rectangle.x = 100
rectangle.y = 100
circle = display.newCircle(100,100,50)
circle.x = 250
circle.y = 100
circle:setFillColor(0,255,0)
--inserting all of your object into display group so that if you destroy the scene the display group will be remove
group:insert(rectangle)
group:insert(circle)
-----------------------------------------------------------------------------
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
-----------------------------------------------------------------------------
rectangle:addEventListener("tap", nextScene)
circle:addEventListener("tap", nextScene)
-----------------------------------------------------------------------------
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
local group = self.view
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
end
as you can see i create 2 object the rectangle and circle after i created the objects insert it to group then on enterScene i added a tap listener which will go to the second scene if i tap the object. notice that i didn't bother to remove the object and listener on destroyScene when i go to the scene_2 that is because when i insert the object to the display group whenever i change the scene it will always remove the object. so after moving to the next scene you can either purged the last scene or completely remove it so when you get back to that scene it will recreate the object.
hope this can help you solve your problem

how to play web url audio files corona sdk?

I am trying to play audio file from web link but it seems not working now. These are the codes I tried:
local birdSound = audio.loadSound("www.sound.com/birds.mp3")
audio.play(birdSound)
It gives an error
You can't load in memory a remote audio file with the loadSound API because this function is just intended to load local files.
By default the file is searched for in the project folder (system.ResourceDirectory), but changing the baseDir parameter you can also look inside a different local folder.
So to play your remote audio file you should first dowload it in the system.DocumentsDirectory through the network.download API. When it is done you can load it with the loadSound, specifying the correct baseDir.
For details about the network.download API look here
Use the sniper below to download your remote file and then save it to localFilename at base dir basedir:
local xmnetwork = {
last_error = nil,
downloadHandlerInProgress = nil,
downloadHandlerFinished = nil,
downloadBeginHandler = nil,
network = require("network")
}
function xmnetwork.download(url, errorHandler,beganHandler, inProgressHandler, endedHandler, localFilename, basedir)
if( xmnetwork.network == nil) then
xmnetwork.network = require("network")
end
xmnetwork.downloadHandlerInProgress = inProgressHandler
xmnetwork.downloadHandlerFinished = endedHandler
xmnetwork.downloadBeginHandler = beganHandler
xmnetwork.errorHandler = errorHandler
local function downloadListener( event )
print("download event:" .. tostring(event))
if ( event.isError ) then
print( "Network error!" )
if( xmnetwork.errorHandler) then
xmnetwork.errorHandler(event)
end
elseif ( event.phase == "began" ) then
if ( event.bytesEstimated <= 0 ) then
print( "Download starting, size unknown" )
else
print( "Download starting, estimated size (in MB): " .. ( event.bytesEstimated /1024/1024))
end
if( xmnetwork.downloadBeginHandler) then
xmnetwork.downloadBeginHandler(event)
end
elseif ( event.phase == "progress" ) then
if(xmnetwork.downloadHandlerInProgress ) then
xmnetwork.downloadHandlerInProgress (event)
end
if ( event.bytesEstimated <= 0 ) then
print( "Download progress: " .. event.bytesTransferred )
else
print( "Download progress: " .. (event.bytesTransferred / event.bytesEstimated) * 100 .. "'%'")
-- log("xmnetwork.download", "downloading :" .. (event.bytesTransferred / event.bytesEstimated) * 100 .. "'%'")
end
elseif ( event.phase == "ended" ) then
print( "Download complete, total bytes transferred: " .. event.bytesTransferred )
if(xmnetwork.downloadHandlerFinished) then
xmnetwork.downloadHandlerFinished(event)
end
end
end
local params = {}
-- Tell network.request() that we want the "began" and "progress" events:
params.progress = "download"
-- Tell network.request() that we want the output to go to a file:
params.response = {
filename = localFilename,
baseDirectory = basedir
}
xmnetwork.network.request( url, "GET", downloadListener, params )
end

Autoit proxy IE object

I'd like to use a proxy to mask my ip surfing the net an autoit browser!
This is my code:
#NoTrayIcon
#include <GUIConstants.au3>
#Include <IE.au3>
#include <GUIConstantsEx.au3>
GUICreate("Web Browser By EMPĀ£!!",800,600)
GUISetBkColor(0x808080)
GUISetState(#SW_SHOW)
$Edit=GUICtrlCreateInput("http://www.whatismyip.com/",20,20,500,20)
$Vai=GUICtrlCreateButton("SURF!!!",600,10,150,50)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 10, 90,780, 500)
$ret = HttpSetProxy(2,"61.163.78.51:3128")
If $ret == 0 Then
MsgBox(0, "Proxy", "Proxy Error")
Exit
EndIf
While 1
$msg=GUIGetMsg()
Switch $msg
Case $Vai
$Link=GUICtrlRead($Edit)
_IENavigate($oIE,($Link))
GUICtrlSetData($Edit,$Link)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
I navigate on http://www.whatismyip.com/ and i can see my real ip address! I'd like to hide a proxy!
The HttpSetProxy function is only for use with InetGet, it makes no difference to the internet explorer settings. In order to make a proxy for internet explorer windows you need to change the internet explorer settings.
The way I would do it is something like:
#include <GUIConstants.au3>
#include <IE.au3>
#include <GUIConstantsEx.au3>
Global Const $sInetSettingsKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
GUICreate("Web Browser By EMPĀ£!!", 800, 600)
GUISetBkColor(0x808080)
GUISetState(#SW_SHOW)
$Edit = GUICtrlCreateInput("http://www.whatismyip.com/", 20, 20, 500, 20)
$Vai = GUICtrlCreateButton("SURF!!!", 600, 10, 150, 50)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 10, 90, 780, 500)
MySetProxy("61.163.78.51:3128")
While 1
$msg = GUIGetMsg()
Switch $msg
Case $Vai
$Link = GUICtrlRead($Edit)
_IENavigate($oIE, ($Link))
GUICtrlSetData($Edit, $Link)
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
MySetProxy()
Func MySetProxy($sProxy = "", $fEnable = True)
Local Static $sPrev = ""
Local Static $fWasEnabled = False
If $sProxy = "" Then
If $sPrev <> "" Then __setProxyInfo($fWasEnabled, $sPrev)
Else
If $sPrev = "" Then
$sPrev = RegRead($sInetSettingsKey, "ProxyServer")
$fWasEnabled = RegRead($sInetSettingsKey, "ProxyEnable")
EndIf
__setProxyInfo($fEnable, $sProxy)
EndIf
EndFunc
Func __setProxyInfo($fEnabled, $sProxy)
RegWrite($sInetSettingsKey, "ProxyEnable", "REG_DWORD", 1)
RegWrite($sInetSettingsKey, "ProxyServer", "REG_SZ", $sProxy)
EndFunc
whatismyip.com didn't like it much though. But the IP address definitely changed.

Resources