Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple timers
#1
Hi there, just found quick macros recently and now i use it for some things.. mostly gaming. I needed some timers and i picked the progress bar code example added a for with a wait system. Now i'm trying to merge all timers in one dialog, and i know i can't have two for's running at the same time in a function. My question i have is what's the easiest way to do it. I know how to do it in java for instance. Please just give me a hint, and i'll get the rest. I hope is a simple way to do it.

Thanks in advance,
Pedro Gomes
#2
Function dialog_timers
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dialog_timers" &dialog_timers)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030506 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,SetTimer hDlg 1 1000 0
,SetTimer hDlg 2 2000 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,out 1
,,
,,case 2
,,KillTimer hDlg 2
,,out 2
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#3
That was it! Thank you so much Smile Tried 3 timers with the progress bar. Perfect. Thank you again!
#4
Sorry to bother again, just another quick question. If i want to increment for instance the 'out 1', changing the 1 for a variable (int). Where do i declare it? It's always resetting the int (i've tried it in different places). Sorry for this newbie questions.
#5
int- i
#6
Just came back to say that i got it. I need some sleep.. Thank you for your patience Smile
#7
Hello again!
So, my timers are progressing fast. But I'm stuck again as I don't know how to bind a keyboard shortcut to activate a button is a window. I tried to use 'lef' but it doesn't focus the window I was again. Also I'm using this for a game witch is full screen. Is there anyway to "hardcode" the hot-key in the main function and make it point to click on the dialog 'Start' button? I want to be able to compile with the hot-key already defined. Also I'm going to register, since you give great support.

Thanks
#8
Function Dialog126
Code:
Copy      Help
;/exe
;\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 20 12 48 14 "Start"
;4 Button 0x54032000 0x0 20 30 48 14 "Stop"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030506 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam
__RegisterHotKey- t_hk1 t_hk2
sel message
,case WM_INITDIALOG
,t_hk1.Register(hDlg 1 MOD_CONTROL|MOD_SHIFT VK_F5) ;;Ctrl+Shift+F5
,t_hk2.Register(hDlg 2 MOD_ALT|MOD_WIN 'Q') ;;Alt+Win+Q
,
,case WM_HOTKEY
,sel wParam
,,case 1 but+ 3 hDlg
,,case 2 but+ 4 hDlg
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,OnScreenDisplay "Start"
,case 4
,OnScreenDisplay "Stop"
ret 1

;BEGIN PROJECT
;main_function Dialog126
;exe_file $my qm$\Dialog126.exe
;icon <default>
;manifest $qm$\default.exe.manifest
;flags 6
;guid {2B095D9C-09F0-4D8A-A164-6DBD2E243CA5}
;END PROJECT
#9
That's it. I'm felling stupid, because it's seems that all the answers are in the Archive, but i can't find them. Is there other sample Archive or it's me that just can find it? Also, i can't find the option to include files on executable during compile. Thanks for your help. I'm going to register as soon as i get my pay-check Smile
#10
If you have whole Archive.qml imported, you can search it using the 'Search Help and tools' edit box in the top-right of QM window. At first click the down arrow next to it, click Options, add
/Archive
and click OK to rebuild the search words index.

There are 2 ways of adding files to exe:
1. #exe addfile "file"
2. With QM functions that use files use a resource id like ":10 file.bmp", and in Make Exe dialog check 'Auto add...'.
#11
Hi, it's me again. My macro is almost ready but i'm having some trouble with hot keys. I did follow the example above, and as I started testing i noticed that if the game is in focus the keys don't work. Only when it's out of focus the keys do trigger the buttons. On the other hand, if i create a normal macro and assign a key by right clicking on it and go to properties, it always works even with the game focused. Help me please, I dunno what to do more to find what's wrong. Thanks Smile
#12
Try to run your macro-exe as administrator.
It that does not work, will need a keyboard hook.
#13
Humm.. i checked the application with administrator and i got the same result. I think it's because of the level of the hook. I'm guessing assigning a key to a macro in the macros proprieties creates a lower lvl hook that with the method you gave in the example. Can you give me some hints on how to do that, as i want to include the keyboard hooks to exe for easy configuration. Thank again Smile
#14
Function dialog_and_keyboard_hook
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dialog_and_keyboard_hook" &dialog_and_keyboard_hook)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Static 0x54000000 0x0 8 10 48 12 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030506 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,int- t_hdlg t_kh
,t_hdlg=hDlg
,t_kh=SetWindowsHookEx(WH_KEYBOARD_LL &DAKH_HookProc _hinst 0)
,
,case WM_DESTROY
,UnhookWindowsHookEx t_kh
,
,case WM_APP+10
,FormatKeyString lParam 0 &_s
,_s.setwintext(id(3 hDlg))
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Function DAKH_HookProc
Code:
Copy      Help
;/dialog_and_keyboard_hook
function nCode wParam KBDLLHOOKSTRUCT&h

FormatKeyString h.vkCode 0 &_s; out "%s %s" _s iif(h.flags&LLKHF_UP "up" "down") ;;disable this

;Example of triggers for keys F7 and F8.
;With Ctrl etc need more work, eg reliably remember key state.

if(h.flags&(LLKHF_INJECTED|LLKHF_UP)) goto gr

int- t_hdlg
sel h.vkCode
,case [VK_F7,VK_F8] SendMessage t_hdlg WM_APP+10 0 h.vkCode

;gr
ret CallNextHookEx(0 nCode wParam &h)
#15
Tested, working. Thank you :wink:


Forum Jump:


Users browsing this thread: 1 Guest(s)