Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customize hotkey switch URL
#1
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
Code:
Copy      Help
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
#2
1. need to call 
we4._getcontrol(id(4 hDlg))
every time before using it.


2. see code below

Code:
Copy      Help
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
#3
thank you for your help

I try to disable/enable F11 with ctrl+F12 but it does not take effect  Huh


Macro Macro8
Code:
Copy      Help
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
#4
you had a couple little typo mistakes works now with CF12 key

Code:
Copy      Help
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
#5
Ctrl+f12 still fails to take effect  Huh
#6
works here just fine
are you sure your pressing ctrl+F12 and not just pressing F12 by mistake?
#7
Sorry, I just found out that I have a trigger that defines ctrl+f12, thanks a lot   Heart Tongue
#8
after checking documentation the we4 variable should not be a thread variable

do this instead
Code:
Copy      Help
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
#9
This will add a few lines of code    Smile
#10
yes but thats is the proper way to do it 
can do code like this


Code:
Copy      Help
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
#11
Well, it's a good way  Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)