Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Created QM video tutorials
#14
Create function "HkSetHotkey" and paste all the below code in it:

Function HK_SetHotkeyDlg
Code:
Copy      Help
\Dialog_Editor

;;********************************************************
;;*
;;* In the calling script declare 't_hk' thread global.
;;*
;;* Then you only have to check for the contents of 't_hk':
;;* if t_hk=0: user pressed cancel (line 93)
;;* if t_hk>0: user pressed hotkey
;;*
;;********************************************************

int- set_hk_up_down
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x8 0 0 219 65 "Set Hotkey"
;3 Edit 0x54030080 0x200 64 8 152 12 ""
;4 Static 0x54000200 0x0 7 9 54 11 "PRESS HOTKEY:"
;12 Static 0x54000200 0x0 110 25 71 7 "Hotkey numeric value:"
;13 Edit 0x54030880 0x200 185 23 30 11 ""
;14 Button 0x54032000 0x0 105 48 58 14 "Use hotkey"
;2 Button 0x54030000 0x4 168 48 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "*" "" "" ""



str controls = "3 13"
str e3 e13
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc
function# hDlg message wParam lParam

int- t_hhk t_hk
sel message
,case WM_INITDIALOG
,,str- regx_isnum="^[0-9]+$" ;; Checks if a string only contains NUMBERS
,,int k_vk
,,int k_mod
,,str k_vk_str
,,str k_mod_str
,,str t_hk_str
,,t_hhk=id(3 hDlg)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 14 ;; button 'Use hotkey'
,,_s.getwintext(id(3 hDlg))
,,if(empty(_s))
,,,mes("Put cursor in 'PRESS HOTKEY:' inputfield then press hotkey" "No hotkey pressed" "i")
,,,ret 0
,,k_vk=t_hk&255
,,k_mod=t_hk>>8        
,,k_vk_str=k_vk
,,k_mod_str=k_mod
,,t_hk_str=t_hk
,,
,,t_hk_str.setwintext(id(13 hDlg))
,,str human_readble_qmout
,,FormatKeyString k_vk k_mod &human_readble_qmout
,,_s.getwintext(id(13 hDlg))
,,if(findrx(_s regx_isnum)<0)
,,,mes("hk_Sethotkey[]Could not properly detect pressed hotkey, please retry[]If problem persists please restart this application and retry." "Error" "!")
,,,ret 0
,,else
,,,sel mes(F"Do you want to use hotkey:[][]{human_readble_qmout}" "Remap hotkey?" "YN?")
,,,,case 'Y'
,,,,,;; Use "DT_Ok(hDlg)" if this is in a sub dialog, for example a dialog contains another dialog with a button save...
,,,,,;; In this way the subdialog get's closed correctly with (global) variables in tact!!!!
,,,,,DT_Ok(hDlg)
,,,,case 'N'
,,,,,ret -1
,case EN_SETFOCUS<<16|3    
,,int-- t_hh
,,t_hh=SetWindowsHookEx(WH_KEYBOARD &sub.Hook_WH_KEYBOARD _hinst GetCurrentThreadId)
,case EN_KILLFOCUS<<16|3
,,UnhookWindowsHookEx t_hh
,case IDOK

,;note: mod used with RegisterHotKey is different: need to swap the first and third bits.
,case IDCANCEL
,,t_hk=0
,,ret -1
ret 1


#sub Hook_WH_KEYBOARD
function# nCode vk lparam
if(nCode<0) goto gNext

int up(lparam&0x80000000) m mod

sel(vk) case VK_SHIFT m=1; case VK_CONTROL m=2; case VK_MENU m=4; case [VK_LWIN,VK_RWIN] m=8
int-- t_mod
if(m) vk=0; if(up) t_mod~m; else t_mod|m
else mod=t_mod

if(!up) sub.SetHotkey vk mod

ret 1

;gNext
ret CallNextHookEx(0 nCode vk +lparam)


#sub SetHotkey
function vk mod

int- t_hhk t_hk
FormatKeyString vk mod &_s
_s.setwintext(t_hhk)
t_hk=mod<<8|vk

Create function "TabGetName"

and paste below code in it

Function TabGetNameFromIndex
Code:
Copy      Help
;/
function! htb item str&s

TCITEMW TabText.mask=WINAPI.TCIF_TEXT
BSTR b.alloc(260)
TabText.pszText=b
TabText.cchTextMax=260
SendMessageW(htb TCM_GETITEMW item &TabText)
s.ansi(b)
ret s.len!=0

;; http://www.quickmacros.com/forum/showthread.php?tid=3863&highlight=TCM_GETITEM


Messages In This Thread
Created QM video tutorials - by r0n - 01-02-2017, 05:52 PM
RE: Created QM video tutorials - by win - 05-11-2018, 03:25 PM
RE: Created QM video tutorials - by r0n - 05-16-2018, 04:52 PM
RE: Created QM video tutorials - by win - 05-17-2018, 01:49 AM
RE: Created QM video tutorials - by win - 11-14-2018, 12:03 AM
RE: Created QM video tutorials - by win - 04-05-2019, 12:08 AM
RE: Created QM video tutorials - by r0n - 04-06-2019, 04:39 PM
RE: Created QM video tutorials - by win - 04-06-2019, 09:14 PM
RE: Created QM video tutorials - by r0n - 04-06-2019, 10:07 PM
RE: Created QM video tutorials - by win - 04-06-2019, 10:15 PM
RE: Created QM video tutorials - by r0n - 04-06-2019, 10:46 PM
RE: Created QM video tutorials - by win - 04-06-2019, 10:49 PM
RE: Created QM video tutorials - by win - 04-07-2019, 03:21 AM
RE: Created QM video tutorials - by r0n - 04-07-2019, 04:01 AM

Forum Jump:


Users browsing this thread: 4 Guest(s)