Posts: 726
Threads: 99
Joined: Mar 2018
Hello everyone,
I would like to use custom hotkeys to help me implement some functions, but I have encountered some problems, and I hope someone can point them out:
1. I want to use F1 to switch the address of the web page, but why can't the we4 object be called directly?
2. I disabled the default hotkey ctrl+c, but I want to toggle disable and enable(ctrl+c) by pressing F12. How to do it?
Thanks in advance
Macro Macro7
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]412 F12"
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case 401 ;;mes "F1"
,we4.Navigate("http://www.google.com")
,case 402 ;;mes "F2"
,we4.Navigate("http://www.facebook.com")
,case 403 ;;mes "F3"
,we4.Navigate("http://www.sina.com")
,case 404 ;;mes "F4"
,we4.Navigate("http://www.baidu.com")
,case 405 ;;mes "ctrl+c"
,
,case 412 ;;mes "F12"
,
ret 1
Posts: 1,336
Threads: 61
Joined: Jul 2006
05-23-2018, 01:59 AM
(This post was last modified: 05-23-2018, 04:25 AM by Kevin.)
1. need to call
we4._getcontrol(id(4 hDlg))
every time before using it.
2. see code below
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- acel
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]412 F12"
,acel=1
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case 401 ;;mes "F1"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.google.com")
,case 402 ;;mes "F2"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.facebook.com")
,case 403 ;;mes "F3"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.sina.com")
,case 404 ;;mes "F4"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.baidu.com")
,case 405 ;;mes "ctrl+c"
,
,case 412 ;;mes "F12"
,if acel =1
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]412 F12"
,,acel =0
,else
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]412 F12"
,,acel=1
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
05-23-2018, 03:12 AM
(This post was last modified: 05-23-2018, 03:14 AM by win.)
thank you for your help
I try to disable/enable F11 with ctrl+F12 but it does not take effect
Macro Macro8
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- acel
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 CF12"
,acel=1
,SHDocVw.WebBrowser- we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case 401 ;;mes "F1"
,we4.Navigate("http://www.baidu.com")
,case 402 ;;mes "F2"
,we4.Navigate("http://www.facebook.com")
,case 403 ;;mes "F3"
,we4.Navigate("http://www.sina.com")
,case 404 ;;mes "F4"
,we4.Navigate("http://www.baidu.com")
,case 405 ;;mes "ctrl+c"
,
,case 411 ;;mes "F11"
,if max(hDlg)
,,SetWinStyle hDlg WS_CAPTION 1
,,SetWinStyle hDlg WS_BORDER 1
,,res hDlg
,else
,,SetWinStyle hDlg WS_CAPTION 2
,,SetWinStyle hDlg WS_BORDER 2
,,max hDlg
,case 412 ;;mes "ctrl+F12"
,if acel =1
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]412 F12"
,,acel =0
,else
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 F12"
,,acel=1
ret 1
Posts: 1,336
Threads: 61
Joined: Jul 2006
you had a couple little typo mistakes works now with CF12 key
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- acel
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 CF12"
,acel=1
,SHDocVw.WebBrowser- we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case 401 ;;mes "F1"
,we4.Navigate("http://www.baidu.com")
,case 402 ;;mes "F2"
,we4.Navigate("http://www.facebook.com")
,case 403 ;;mes "F3"
,we4.Navigate("http://www.sina.com")
,case 404 ;;mes "F4"
,we4.Navigate("http://www.baidu.com")
,case 405 ;;mes "ctrl+c"
,
,case 411 ;;mes "F11"
,if max(hDlg)
,,SetWinStyle hDlg WS_CAPTION 1
,,SetWinStyle hDlg WS_BORDER 1
,,res hDlg
,else
,,SetWinStyle hDlg WS_CAPTION 2
,,SetWinStyle hDlg WS_BORDER 2
,,max hDlg
,case 412 ;;mes "ctrl+F12"
,if acel =1
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]412 CF12"
,,acel =0
,else
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 CF12"
,,acel=1
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
Ctrl+f12 still fails to take effect
Posts: 1,336
Threads: 61
Joined: Jul 2006
05-23-2018, 03:42 AM
(This post was last modified: 05-23-2018, 03:45 AM by Kevin.)
works here just fine
are you sure your pressing ctrl+F12 and not just pressing F12 by mistake?
Posts: 726
Threads: 99
Joined: Mar 2018
Sorry, I just found out that I have a trigger that defines ctrl+f12, thanks a lot
Posts: 1,336
Threads: 61
Joined: Jul 2006
after checking documentation the we4 variable should not be a thread variable
do this instead
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- acel
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 F12"
,acel=1
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case 401 ;;mes "F1"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.google.com")
,case 402 ;;mes "F2"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.facebook.com")
,case 403 ;;mes "F3"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.sina.com")
,case 404 ;;mes "F4"
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://www.baidu.com")
,case 405 ;;mes "ctrl+c"
,case 411 ;;mes "F11"
,out "test"
,if max(hDlg)
,,SetWinStyle hDlg WS_CAPTION 1
,,SetWinStyle hDlg WS_BORDER 1
,,res hDlg
,else
,,SetWinStyle hDlg WS_CAPTION 2
,,SetWinStyle hDlg WS_BORDER 2
,,max hDlg
,case 412 ;;mes "ctrl+F12"
,if acel =1
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]412 F12"
,,acel =0
,else
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 F12"
,,acel=1
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
This will add a few lines of code
Posts: 1,336
Threads: 61
Joined: Jul 2006
05-23-2018, 04:37 AM
(This post was last modified: 05-23-2018, 04:38 AM by Kevin.)
yes but thats is the proper way to do it
can do code like this
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 900 432 "dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "4"
str ax4SHD
ax4SHD="www.bing.com"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- acel
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 CF12"
,acel=1
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,DT_SetAutoSizeControls(hDlg "4s")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
,case [401,402,403,404]
,err-
,we4._getcontrol(id(4 hDlg))
,sel wParam
,,case 401 we4.Navigate("http://www.google.com")
,,case 402 we4.Navigate("http://www.facebook.com")
,,case 403 we4.Navigate("http://www.sina.com")
,,case 404 we4.Navigate("http://www.baidu.com")
,err+
,case 405 ;;mes "ctrl+c"
,
,case 411 ;;mes "F11"
,if max(hDlg)
,,SetWinStyle hDlg WS_CAPTION 1
,,SetWinStyle hDlg WS_BORDER 1
,,res hDlg
,else
,,SetWinStyle hDlg WS_CAPTION 2
,,SetWinStyle hDlg WS_BORDER 2
,,max hDlg
,case 412 ;;mes "ctrl+F12"
,if acel =1
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]412 CF12"
,,acel =0
,else
,,DT_SetAccelerators hDlg "401 F1[]402 F2[]403 F3[]404 F4[]405 Cc[]411 F11[]412 CF12"
,,acel=1
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
Well, it's a good way
|