[python-win32] Is it possible to (un)check items in "Local Area Connection Properties" ?

Stef Mientki stef.mientki at gmail.com
Thu Oct 29 23:50:32 CET 2009


thanks Kevin,

Kevin Horn wrote:
> On Wed, Oct 28, 2009 at 4:22 PM, Stef Mientki <stef.mientki at gmail.com 
> <mailto:stef.mientki at gmail.com>> wrote:
>
>     hello,
>
>     For connecting though CheckPoint VPN,
>     I need to check the item "Check Point SecuRemote" in the Local
>     Area Connections Properties.
>
>     I couldn't find a way to read and or toggle this switch (through
>     some registry setting),
>     so I made an AutoIt program to accomplish the task.
>
>     The main disadvantage is that if the number of items above "Check
>     Point SecuRemote" changes,
>     the Auto-It script will (un)check the wrong item.
>
>     thanks,
>     Stef Mientki
>
>
> There are some python tools that do desktop automation in a fashion 
> similar to what AutoIt does, but this kind of task is one of the few I 
> actually don't usually use Python for.  I usually use AutoIt.
>
> PyWinAuto (http://pywinauto.openqa.org/) is probably the best-known of 
> the windows solutions out there.  I thought there was another main 
> one, but I can't find it at the moment.
>
> Before you go haring off looking for a new tool, have you tried 
> getting the control ID using the AutoIt Winspy-thingy?  I've been able 
> to use that to send messages directly to individual controls, rather 
> than the window, which has helped me in similar situations.
>
> Hope this helps, and let us know how it works out!
I updated my autoit script ( whole lot of trial and error :-( ,
but it works now, the spy tip was a good one !!
If someone is interested, the code is below.

cheers,
Stef

;********************************************************************************** 

;Systeem Settings
;********************************************************************************** 

;Er moet voor gezorgd worden dat LAN en VPN gesynchroniseerd zijn
;Het disablen van VPN by startup gaat als volgt:
;  Control Panel
;     Administrative Tools
;         Computer Management
;             Services and Applications
;                 Services
;                      CheckPoint SecuRemote Watchdog = manual

;********************************************************************************** 

;Define directories and window titles in some local vars
;********************************************************************************** 

local $Net_Conn = "Network Connections"
local $LAN_Status = "Local Area Connection Status"
local $LAN_Props = "Local Area Connection Properties"


;********************************************************************************** 

;correct the default AutoIt settings
;********************************************************************************** 

;AutoItSetOption("TrayIconHide",0)    ;0 = hide (after 1 second)
AutoItSetOption("MouseCoordMode", 0)       ;1 = absolute screen 
coordinates (default)
;BlockInput(1)


;********************************************************************************** 

;launch Network Connections, then launch LAN_status and close Network 
Connections
;********************************************************************************** 

Run("control ncpa.cpl")

WinWait( $Net_Conn)
If Not WinActive( $Net_Conn) Then
 WinActivate( $Net_Conn)
EndIf

ControlFocus( $Net_Conn, "", "SysListView321")
ControlSend( $Net_Conn, "", "SysListView321","local")
Send("{ENTER}")
WinClose( $Net_Conn)

;********************************************************************************** 

;wait till LAN_status window active, then click on Properties
;********************************************************************************** 

WinWait($LAN_Status)
If Not WinActive($LAN_Status) Then
 WinActivate($LAN_Status)
EndIf

ControlFocus($LAN_Status, "", "&Properties")
ControlClick($LAN_Status, "", "&Properties")
WinClose( $LAN_Status)

$WinText = ''
$Name = 'Check Point SecuRemote'

$NameIndex = ControlListView ( $LAN_Props, $WinText, 'SysListView321', 
"FindItem", $Name)
WinActivate($LAN_Props)
WinWaitActive($LAN_Props)

; THIS DOESN'T WORK !!!
;ControlListView ( $WinTitle, $WinText, 'SysListView321', "SelectClear")
;sleep(200)
;ControlListView ( $WinTitle, $WinText, 'SysListView321', "Select", 
$NameIndex)
;sleep(200)
;send("{space}")

For $i = 1 to $NameIndex
 Send("{down}")
Next
sleep(200)
send("{space}")
ControlClick($LAN_Props,$WinText,"Button8") ;OK knop

BlockInput(0)


More information about the python-win32 mailing list