Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use windows screensaver to launch QM code
#1
I had problems creating a proper method to launch QM code when windows is IDLE for ### seconds.
Even with the function "GetIdleTime", I used this method to create a QM way of handling it:
http://stackoverflow.com/questions/1682 ... er-is-idle

I created an elaborate youtube video tutorial here:
https://www.youtube.com/watch?v=26BamQ76VsI

Or you can use the below "short" explanation:
..........................................
STEP 1: create below qm functions
..........................................
- "_SCREENSAVER_TASKS_PRE" , then right click on it, go to 'Item properties' , goto tab 'Common Properties' take note of it's GUID below in the 'Common Properties' tab
- "_SCREENSAVER_TASKS_POST" , then right click on it, go to 'Item properties' , goto tab 'Common Properties' take note of it's GUID below in the 'Common Properties' tab

Within QM in the itemslist on the left, right click on "_SCREENSAVER_TASKS_PRE" then select 'Item properties'
1. in the first tab "Trigger", below you see the 'Cmdline...'-button, click it. The QM command line for that item is copied to clipboard (paste it in STEP 2)
2. in tab "Common Properties" take note of it's GUID below in the "Common Properties" tab, you must also paste it in STEP 2 Repeat this for "_SCREENSAVER_TASKS_POST"


..........................................
STEP 2: create below qm function "_SCREENSAVER_MAINEXEC"
compile to exe and rename extension to '.scr', it contains 3 lines.
And paste the GUID's correctly below. The first and third line you paste from clipboard (see STEP 1)
Below you see "##### PASTE GUID HERE###", this is the GUID and it is explained in STEP 1
..........................................

Macro _INFO_SCREENSAVER_EXEC_TASKS
Code:
Copy      Help
;; "F:\portableapps\quickmacrosportable_dev\App\QuickMacros\qmcl.exe" is the FULL path to MY 'qmcl.exe'
;; When you generate the command-line, in STEP 1 your path will be different!
;; Do NOT use QM $$-paths, with this I mean do NOT use: "$qm$\qmcl.exe". Use the FULL PATH!!!!
;; And do NOT forget to paste the GUID you see indicated below in "##### PASTE GUID HERE###" (replace that with GUID!)
run "F:\portableapps\quickmacrosportable_dev\App\QuickMacros\qmcl.exe" "M ''{##### PASTE GUID HERE###}_SCREENSAVER_TASKS_PRE''"
run "C:\Windows\system32\Mystify.scr" "/s"
run "F:\portableapps\quickmacrosportable_dev\App\QuickMacros\qmcl.exe" "M ''{##### PASTE GUID HERE###}_SCREENSAVER_TASKS_POST''"

Line 1: _SCREENSAVER_TASKS_PRE: executes commands BEFORE screensaver starts
Line 2: executes screensaver, ALWAYS PRESENT
Line 3: _SCREENSAVER_TASKS_PRE: executes commands AFTER screensaver is finsished

..........................................
STEP 3: After you created the above function, do (take note) of the following:
..........................................

* Why line 2 must always be present:
If you don't "start" the screensaver then it will block until you interrupt it, and then run the end program.
http://stackoverflow.com/questions/1682 ... er-is-idle

* Line 1 and 3: Execute the the pre and post actions within the QM functions on line 1 and 3

* Compile "_SCREENSAVER_MAINEXEC" which has the 3 lines to exe and rename the extension to '.scr' and set windows registry key "HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE" To the path of "_SCREENSAVER_MAINEXEC.scr"

* Make sure you have a correct timeout (time idle for screensaver (and qm tasks) to run!)
HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut
(value 60 = 1 minute, minimum value of "ScreenSaveTimeOut" is 60)


EDIT 1:
This is all tested only on Windows 7, the above path to the screensaver (C:\Windows\system32\Mystify.scr) is based on windows7
I think the above described method also works for Windows 8 and 10.

Other available default screensavers in Windows 7:
C:\Windows\system32\Bubbles.scr
C:\Windows\system32\Mystify.scr
C:\Windows\system32\PhotoScreensaver.scr
C:\Windows\system32\Ribbons.scr
C:\Windows\system32\ssText3d.scr
#2
Hello, r0n

Word processing, is the daily work often need to operate,
QM by default operating text, can not keep some character format, so I hope you can record some Word software aspects of the video tutorial (using word typelib):

E.g:

1. Use QM to open, create, save dos document

2. Use qm to change the character format in word

3. Use qm to change the paragraph format in word

4. Use qm to change the page format in word

5. Use QM's regular expression to find and replace characters (Word regular expression is not standardized, QM is very standardized)

Thank you very much for recording the tutorial, so I learned a lot of programming knowledge Smile
#3
VBA syntax, some long-winded, QM syntax is relatively simple, so I hope you can contrast to explain a VBA and QM operating syntax, this will make people better understand the strong QM programming Arrow
#4
Hi Ron,

I've followed your steps and create the appropriate files.
But when executed I've got the following error:
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."

Here is the code for both Pre and Post macros:

Function _ss_main
Code:
Copy      Help
run "D:\P\QM\qmcl.exe" "M ''{0e424eda-f484-425a-86cf-11da91c92761}_ss_tasks_pre''"
run "C:\Windows\System32\Ribbons.scr" "/s"
run "D:\P\QM\qmcl.exe" "M ''{887485a4-ff93-4f3d-af0f-02f6f0604ccd}_ss_tasks_post''"

;BEGIN PROJECT
;main_function  _ss_main
;exe_file  d:\3\_ss_main.exe
;icon  <default>
;manifest  $qm$\default.exe.manifest
;flags  6
;guid  {10DA3A0E-1A6C-4D59-8851-48353D362671}
;END PROJECT

Function _ss_tasks_pre
Code:
Copy      Help
run "C:\Windows\System32\mspaint.exe"

Function _ss_tasks_post
Code:
Copy      Help
run "C:\Windows\System32\notepad.exe"

Function Activate_ScreenSaver
Code:
Copy      Help
str timeout="60"  ;; 1 min idle before SS starts.
rset(timeout "ScreenSaveTimeOut" "Control Panel\Desktop" HKEY_CURRENT_USER)
str screensave_path="D:\3\_ss_main.scr"
rset(screensave_path "SCRNSAVE.EXE" "Control Panel\Desktop" HKEY_CURRENT_USER)
#5
@kyjdp and Start_Learning

My apologies, for seeing the replies now, I totally overlooked them.
@kyjdp I am afraid I can not elobarate further on office and QM and VBA compared to QM scripting.
I might do this in the future though, but I can't promise anything.

@Start_Learning
I can't find any faults in your code, but here is a short checklist

Code:
Copy      Help
1. Run below line from QM itself, does it start the screensaver?:
  .......
  run "C:\Windows\system32\Bubbles.scr"
  .......
2. Run the below line from QM itself, immediatly after running keep eye on 'Running Items' (right-side)
  Does it appear correctly very briefly in 'Runnn items'?
  'qmcl.exe' is important to be run from within the QM installation (or portable location).
  .......
  run "F:\portableapps\quickmacrosportable_clean\App\QuickMacros\qmcl.exe"
  .......
3. Have you copied the correct GUID from '..._PRE' and '..._POST' correctly into '..._MAINEXEC'
4. Turn of UAC if it is on and test it, maybe it's UAC issue.
  You can turn it back on after testing.
5. Is QM running as admin?
6. Do the following registry key paths exist:
  HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut
  HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE

Again @kyjdp and Start_Learning, I am really sorry that I didn't see your posts earlier.
#6
Hi Ron,

1. Run below line from QM itself, does it start the screensaver?:
  .......
  run "C:\Windows\system32\Bubbles.scr"
  .......

Yes this line did start the screensaver.

2. Run the below line from QM itself, immediatly after running keep eye on 'Running Items' (right-side)
  Does it appear correctly very briefly in 'Runnn items'?
  'qmcl.exe' is important to be run from within the QM installation (or portable location).
  .......
  run "D:\P\QM\qmcl.exe"
  .......

Yes this line did make it appear very briefly on "Running Items"

3. Have you copied the correct GUID from '..._PRE' and '..._POST' correctly into '..._MAINEXEC'

Yes I did check the GUID and they are copied correctly.

4. Turn of UAC if it is on and test it, maybe it's UAC issue.
  You can turn it back on after testing.

Yes I did turn off the UAC but the problem still exists.

5. Is QM running as admin?

Yes QM is running as Admin.

6. Do the following registry key paths exist:
  HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut
  HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE

Yes those 2 registry key paths did exist.

Note:
- If I put a message using "mes" prior the line: "run "C:\Windows\System32\Ribbons.scr" "/s"" in _ss_main macro, it did show the message.

- If I put a message using "mes" after the line: "run "C:\Windows\System32\Ribbons.scr" "/s"" in _ss_main macro, it did show the message.
#7
Hi Ron,

I've found out the reason I've got the error message is because I have another Firewall program running in the background and it blocks those executable programs.

But after I turn off the Firewall program, I still see the blue screen appear but not the actual program running, like "mspaint.exe" or "notepad.exe".

As a work around I did this and it works:

Function _ss_main
Code:
Copy      Help
_SCREENSAVER_TASKS_PRE
1
run "C:\Windows\System32\Ribbons.scr" "/s" "" "" 0x400

_SCREENSAVER_TASKS_POST

The flag "0x400" is to make sure the screensaver keeps on running until the user terminates it; otherwise it will keep running the _
Code:
Copy      Help
_SCREENSAVER_TASKS_POST function right away.
#8
Good to know this!
Thanks for your feedback, I honestly could not find a solution.


Forum Jump:


Users browsing this thread: 1 Guest(s)