Jump to content

question about vista


Recommended Posts

i got a little code that makes a .ini in my program and i did get a email latey that my program wasn't making ini's in vista

take a look at my code

$sIni = "C:\Program Files\test\test.ini"
        $sMenu = "Menu= "& $tabmenu
        $sData = "Action1= "& $action & @LF & "Action2= "& $action1 & @LF & "Action3= "& $action2 & @LF & "Action4= "& $action3 & @LF
        $sData1 = "Action5= "& $action4 & @LF & "Action6= "& $action5 & @LF & "Action7= "& $action6 & @LF & "Action8= "& $action7
        IniWriteSection ($sIni, "Tabmenu", $sMenu)
        IniWriteSection($sIni, "ActionButton", $sData & $sData1)
Link to comment
Share on other sites

i got a little code that makes a .ini in my program and i did get a email latey that my program wasn't making ini's in vista

take a look at my code

$sIni = "C:\Program Files\test\test.ini"
        $sMenu = "Menu= "& $tabmenu
        $sData = "Action1= "& $action & @LF & "Action2= "& $action1 & @LF & "Action3= "& $action2 & @LF & "Action4= "& $action3 & @LF
        $sData1 = "Action5= "& $action4 & @LF & "Action6= "& $action5 & @LF & "Action7= "& $action6 & @LF & "Action8= "& $action7
        IniWriteSection ($sIni, "Tabmenu", $sMenu)
        IniWriteSection($sIni, "ActionButton", $sData & $sData1)
Because in Vista you're not admin by default. I think you don't have the right to write in Program Files. The good practice is to use the user profile.

I use this kind of syntax in Windows XP :

$AppData = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "AppData")

$sIni = $AppData & "\" & _FileGetFName(@ScriptName) & ".ini"

Edited by pixels75
Link to comment
Share on other sites

I'm trying to automate the Vista Wireless Zero client for wireless configuration and I'm having multiple issues. I'm uncertain at this time if these are bugs or programming mistakes, but I have made a script for people to try out. You will need a wireless card that is named 'Wireless' or rename the adapter variable to match your wireless card's name. Below is my sample code that goes through my list of problems in a step by step manor with comments showing alternate things that work and the issues I am having. Any help is much appreciated!

I have added a code box and attached the same.

CODE
global $NCTITLE = "Network Connections"

global $NETWORKSCONTROL = "SysListView321"

global $adapter = "Wireless"

Run ("control.exe ncpa.cpl")

WinActivate ($NCTITLE)

sleep (100)

ControlListView($NCTITLE, "", $NETWORKSCONTROL, "Select", ControlListView($NCTITLE,"",$NETWORKSCONTROL,"FindItem",$adapter) )

ControlSend($NCTITLE, "", $NETWORKSCONTROL, "+{F10}")

ControlSend($NCTITLE, "", $NETWORKSCONTROL, "o")

sleep(200)

WinActivate ("Connect to a network")

;This should work but doesn't

ControlClick ("Connect to a network", "", 1007)

sleep(200)

;This will work, but I want to use ID's!

;Send("{TAB}{TAB}{ENTER}")

;sleep(200)

WinActivate ("Network and Sharing Center")

;No way to make this one work. The links on the left aren't even seen by the AutoIT Info viewer

; Instead I'm clicking mouse location, but if my res isn't set right, I'm SOL.

MouseClick("",130,235)

sleep(200)

; At this point I need a list of currently configured connections so I can delete them

;See what the listview returns for the number of items. Try changing the number of network connections.

;I always get the same #.

$ListCount = ControlListView("Manage Wireless Networks","",1,"GetSubItemCount")

ConsoleWrite ("Number of network connections: " & $ListCount & @CRLF)

; Alo of note, if you click on a connection, the option to delete appears, but

; once again, the info box does not show this item.

Link to comment
Share on other sites

I'm trying to automate the Vista Wireless Zero client for wireless configuration and I'm having multiple issues. I'm uncertain at this time if these are bugs or programming mistakes, but I have made a script for people to try out. You will need a wireless card that is named 'Wireless' or rename the adapter variable to match your wireless card's name. Below is my sample code that goes through my list of problems in a step by step manor with comments showing alternate things that work and the issues I am having. Any help is much appreciated!

I have added a code box and attached the same.

CODE
global $NCTITLE = "Network Connections"

global $NETWORKSCONTROL = "SysListView321"

global $adapter = "Wireless"

Run ("control.exe ncpa.cpl")

WinActivate ($NCTITLE)

sleep (100)

ControlListView($NCTITLE, "", $NETWORKSCONTROL, "Select", ControlListView($NCTITLE,"",$NETWORKSCONTROL,"FindItem",$adapter) )

ControlSend($NCTITLE, "", $NETWORKSCONTROL, "+{F10}")

ControlSend($NCTITLE, "", $NETWORKSCONTROL, "o")

sleep(200)

WinActivate ("Connect to a network")

;This should work but doesn't

ControlClick ("Connect to a network", "", 1007)

sleep(200)

;This will work, but I want to use ID's!

;Send("{TAB}{TAB}{ENTER}")

;sleep(200)

WinActivate ("Network and Sharing Center")

;No way to make this one work. The links on the left aren't even seen by the AutoIT Info viewer

; Instead I'm clicking mouse location, but if my res isn't set right, I'm SOL.

MouseClick("",130,235)

sleep(200)

; At this point I need a list of currently configured connections so I can delete them

;See what the listview returns for the number of items. Try changing the number of network connections.

;I always get the same #.

$ListCount = ControlListView("Manage Wireless Networks","",1,"GetSubItemCount")

ConsoleWrite ("Number of network connections: " & $ListCount & @CRLF)

; Alo of note, if you click on a connection, the option to delete appears, but

; once again, the info box does not show this item.

i think i now your mouse problem

you have this;No way to make this one work. The links on the left aren't even seen by the AutoIT Info viewer
; Instead I'm clicking mouse location, but if my res isn't set right, I'm SOL.
MouseClick("",130,235)
sleep(200

but MouseClick work

only if you type

MouseClick ( "Button (Left, Right and more)", x-cor, z-cor, amount of click (if You Want default 1) no need to fill this in)

example of a good MouseClick

MouseClick("left", 524, 467, 1)
Edited by lilx
Link to comment
Share on other sites

Because in Vista you're not admin by default. I think you don't have the right to write in Program Files. The good practice is to use the user profile.

I use this kind of syntax in Windows XP :

$AppData = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "AppData")

$sIni = $AppData & "\" & _FileGetFName(@ScriptName) & ".ini"

can please explain your codes plz i still kinda new in coding

Link to comment
Share on other sites

can please explain your codes plz i still kinda new in coding

The first line read the value of the key AppData on the registry, that's the location of your profile

The second line build the path of the ini file based on the profile

And I forget the _FileGetFName function for geting the name of the script without the extension...

Func _FileGetFName($szPath)
    Local $i, $dir, $fname, $ext
    
; Set the directory and file name if present
    For $i = StringLen($szPath) To 0 Step - 1
        If StringMid($szPath, $i, 1) = "\" Or StringMid($szPath, $i, 1) = "/" Then
            $dir = StringLeft($szPath, $i)
            $fname = StringRight($szPath, StringLen($szPath) - $i)
            ExitLoop
        EndIf
    Next
    
; If $szDir wasn't set, then the whole path must just be a file, so set the filename
    If StringLen($dir) = 0 Then $fname = $szPath
    
; Check the filename for an extension and set it
    For $i = StringLen($fname) To 0 Step - 1
        If StringMid($fname, $i, 1) = "." Then
            $ext = StringRight($fname, StringLen($fname) - ($i - 1))
            $fname = StringLeft($fname, $i - 1)
            ExitLoop
        EndIf
    Next
    
    Return $fname
EndFunc
Edited by pixels75
Link to comment
Share on other sites

i think i now your mouse problem

you have this;No way to make this one work. The links on the left aren't even seen by the AutoIT Info viewer
; Instead I'm clicking mouse location, but if my res isn't set right, I'm SOL.
MouseClick("",130,235)
sleep(200

but MouseClick work

only if you type

MouseClick ( "Button (Left, Right and more)", x-cor, z-cor, amount of click (if You Want default 1) no need to fill this in)

example of a good MouseClick

MouseClick("left", 524, 467, 1)

But that is not the issue. The issue is that The Info box doesn't see those links and therefore can't directly select them. Instead, I have to click on a set of mouse co-ordinates. This is a problem if the resolution is changed between runs. Try going to that control panel page and using the Window Info tool and see if you can see those links as objects.

Link to comment
Share on other sites

The first line read the value of the key AppData on the registry, that's the location of your profile

The second line build the path of the ini file based on the profile

And I forget the _FileGetFName function for geting the name of the script without the extension...

Func _FileGetFName($szPath)
    Local $i, $dir, $fname, $ext
    
; Set the directory and file name if present
    For $i = StringLen($szPath) To 0 Step - 1
        If StringMid($szPath, $i, 1) = "\" Or StringMid($szPath, $i, 1) = "/" Then
            $dir = StringLeft($szPath, $i)
            $fname = StringRight($szPath, StringLen($szPath) - $i)
            ExitLoop
        EndIf
    Next
    
; If $szDir wasn't set, then the whole path must just be a file, so set the filename
    If StringLen($dir) = 0 Then $fname = $szPath
    
; Check the filename for an extension and set it
    For $i = StringLen($fname) To 0 Step - 1
        If StringMid($fname, $i, 1) = "." Then
            $ext = StringRight($fname, StringLen($fname) - ($i - 1))
            $fname = StringLeft($fname, $i - 1)
            ExitLoop
        EndIf
    Next
    
    Return $fname
EndFunc
ok it's nice that you try to explain it but i just can't get it. i hope that some els can explain it to me :$ :">
Link to comment
Share on other sites

Everyone, remember one very important thing in Vista:

If for some reason attempts to manipulate SOMETHING in Windows Vista just fail without apparent reason (especially if you have User Account Control active which it is by default!), there is one thing that you should definitely try to put on top of your script:

#RequireAdmin

This makes your script popup one of those UAC dialogs and gets a high permission level if the user agrees (and correctly enters the admin password if asked for it).

It enabled me to stop and start services and manipulate the registry in Vista, for instance.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...