it@flude.co.uk
Member
Has anyone found an easy way to start a Dial-Up Internet Connection from Progress? I need to password protect some Internet Connection Icons to stop people messing at night .....
The only way I've found to do it is a bit messy:
1. Create a Shortcut to Network Connections from Control Panel.
2. Run this program.
What it does is to run the shortcut, then use Sendkeys to select the appropriate DUN Shortcut, start it going and press Dial. Then it closes the Networking Connections box.
It works, but the trouble is, this is a bit messy and not as fast as starting from the DUN Shortcut.
/* Anything starting p_shell is to do with the wsshell sendkeys functionality - included to make coding easier */
def temp-table t_wsshell no-undo
field name as char form "x(20)"
field shell as com-handle
index idx1 name.
run p_connect_dun("Wanadoo","Wanadoo pay As You Go").
function f_shell_key returns char (inp_word as char):
return chr(123) + inp_word + chr(125).
end function.
procedure p_shell_create:
def input param inp_name as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if not available t_wsshell then do:
create t_wsshell.
t_wsshell.name = inp_name.
end.
if not valid-handle (t_wsshell.shell) then create "WScript.Shell" t_wsshell.shell no-error.
if not valid-handle (t_wsshell.shell) then delete t_wsshell.
end procedure.
procedure p_shell_release:
def input param inp_name as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then release object t_wsshell.shell no-error.
end procedure.
procedure p_shell_command:
def input param inp_name as char no-undo.
def input param inp_command as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then t_wsshell.shell:run ("cmd /C " + chr(34) + inp_command + chr(34),2).
end procedure.
procedure p_shell_activate:
def input param inp_name as char no-undo.
def input param inp_activate as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then t_wsshell.shell:AppActivate (inp_activate).
end procedure.
procedure p_shell_sendkeys:
def input param inp_name as char no-undo.
def input param inp_activate as char no-undo.
def input param inp_keys as char no-undo.
def input param inp_pause as int no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then do:
if inp_activate <> "" then t_wsshell.shell:AppActivate (inp_activate).
t_wsshell.shell:SendKeys (inp_keys).
end.
if inp_pause > 0 then pause inp_pause.
end procedure.
procedure p_connect_dun:
def input param inp_shortkey as char no-undo.
def input param inp_dun_name as char no-undo.
def var key_enter as char no-undo.
def var this_nc as char initial "Network Connections" no-undo.
key_enter = f_shell_key("ENTER").
os-command silent value ("""n:\sapv8\sysdata\lnk\Network Connections.lnk""") no-wait.
run p_shell_create("nc").
run p_shell_create("dun").
run p_shell_sendkeys ("nc", this_nc, inp_shortkey + key_enter,2).
run p_shell_sendkeys ("dun", inp_dun_name, key_enter,2).
run p_shell_sendkeys ("nc", this_nc, "%Fc",2).
run p_shell_release ("nc").
run p_shell_release ("dun").
end procedure.
The only way I've found to do it is a bit messy:
1. Create a Shortcut to Network Connections from Control Panel.
2. Run this program.
What it does is to run the shortcut, then use Sendkeys to select the appropriate DUN Shortcut, start it going and press Dial. Then it closes the Networking Connections box.
It works, but the trouble is, this is a bit messy and not as fast as starting from the DUN Shortcut.
/* Anything starting p_shell is to do with the wsshell sendkeys functionality - included to make coding easier */
def temp-table t_wsshell no-undo
field name as char form "x(20)"
field shell as com-handle
index idx1 name.
run p_connect_dun("Wanadoo","Wanadoo pay As You Go").
function f_shell_key returns char (inp_word as char):
return chr(123) + inp_word + chr(125).
end function.
procedure p_shell_create:
def input param inp_name as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if not available t_wsshell then do:
create t_wsshell.
t_wsshell.name = inp_name.
end.
if not valid-handle (t_wsshell.shell) then create "WScript.Shell" t_wsshell.shell no-error.
if not valid-handle (t_wsshell.shell) then delete t_wsshell.
end procedure.
procedure p_shell_release:
def input param inp_name as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then release object t_wsshell.shell no-error.
end procedure.
procedure p_shell_command:
def input param inp_name as char no-undo.
def input param inp_command as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then t_wsshell.shell:run ("cmd /C " + chr(34) + inp_command + chr(34),2).
end procedure.
procedure p_shell_activate:
def input param inp_name as char no-undo.
def input param inp_activate as char no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then t_wsshell.shell:AppActivate (inp_activate).
end procedure.
procedure p_shell_sendkeys:
def input param inp_name as char no-undo.
def input param inp_activate as char no-undo.
def input param inp_keys as char no-undo.
def input param inp_pause as int no-undo.
find t_wsshell where t_wsshell.name = inp_name no-lock no-error.
if available t_wsshell then do:
if inp_activate <> "" then t_wsshell.shell:AppActivate (inp_activate).
t_wsshell.shell:SendKeys (inp_keys).
end.
if inp_pause > 0 then pause inp_pause.
end procedure.
procedure p_connect_dun:
def input param inp_shortkey as char no-undo.
def input param inp_dun_name as char no-undo.
def var key_enter as char no-undo.
def var this_nc as char initial "Network Connections" no-undo.
key_enter = f_shell_key("ENTER").
os-command silent value ("""n:\sapv8\sysdata\lnk\Network Connections.lnk""") no-wait.
run p_shell_create("nc").
run p_shell_create("dun").
run p_shell_sendkeys ("nc", this_nc, inp_shortkey + key_enter,2).
run p_shell_sendkeys ("dun", inp_dun_name, key_enter,2).
run p_shell_sendkeys ("nc", this_nc, "%Fc",2).
run p_shell_release ("nc").
run p_shell_release ("dun").
end procedure.