Sign in to follow this  
Followers 0
Paulie

Popup Blocker Idea

6 posts in this topic

I am thinking about how i could block some popups from coming up on my comp, and i also wanted to improve my scripting skills so i'm making one in autoit. however, it is saying that i have an error

Heres Code:

#NoTrayIcon
;---Includes---
#Include <GUIConstants.au3>

;---Variables---

Global $Button_[1], $i = 0

;---INI---
If Not FileExists(@ScriptDir & "\Popuplist.ini") Then Create_def_ini()
Global $Window_name = IniReadSection(@ScriptDir & "\Popuplist.ini", "Name")

;---GUI---

$wind = GuiCreate("Popup?", 275, 50, 1000,900, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Button_[0] = GUICtrlCreateButton("Push Here If Active Window Is A Popup", 25, 10, 225, 30)
GUISetState()


;---Display---
While 1
Closepopups()
$msg= GUIGetmsg()

If $msg = $GUI_EVENT_CLOSE then
$close_msg= Msgbox(2, "Close?", "This will close you Popup blocker, Are you sure?")
If $close_msg = 7 then 
Continueloop
Else
Exitloop
Endif
Endif

If $msg = $Button_[0] then
$windtitle = WinGetTitle("")    
    IniWrite(@ScriptDir & "\Popuplist.ini", "Name", $i, $windtitle)
$i = $i + 1
Endif
Wend

;---Functions---
Func Create_def_ini()
    IniWrite(@ScriptDir & "\Popuplist.ini", "Author", 1, "Paulie")
EndFunc

;===
Func Closepopups()
For $numbers= 1 to $Window_name[0][0]
If Winexists( $Window_name[$numbers][1]) Then
Winkill($Window_name[$numbers][1])
Endif
Next
EndFunc

and it says my varible here:

For $numbers= 1 to $Window_name[0][0]

has subscript used without an array variable,

but the helpfile says

Returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.

help plz

TY

Share this post


Link to post
Share on other sites



**Bump**

No ideas? No helpful hints or tips? For real?!! :):(

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

but the helpfile says

Throw an _arraydisplay in just after your $Window_name[0][0] statement to see what that variable contains. I don't see it declared in your script. Are you sure it would contain a number? Also, be sure to #include <array.au3> if you use _arraydisplay... Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Throw an _arraydisplay in just after your $Window_name[0][0] statement to see what that variable contains. I don't see it declared in your script. Are you sure it would contain a number? Also, be sure to #include <array.au3> if you use _arraydisplay...

I get the same error with array display,

and the var is declared right here:

;---INI---
If Not FileExists(@ScriptDir & "\Popuplist.ini") Then Create_def_ini()
Global $Window_name = IniReadSection(@ScriptDir & "\Popuplist.ini", "Name")

Share this post


Link to post
Share on other sites

Does this line work by itself? That is, can you have a key named "1"? If so, don't you need quotes around it?

IniWrite(@ScriptDir & "\Popuplist.ini", "Author", 1, "Paulie")

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Looks like you've never populated "Name" that your doing the IniReadSection on. It's in your loop but your calling the function before you ever get to populate it. When you create it originally, your creating Author not Name section.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0