Jump to content

Process Create and Screensavers


Hermano
 Share

Recommended Posts

I am currently writing a full library of functions tailored to those that use a multi monitor situation where one of the two monitor is a tv set or project.

The full libray will be available to the community very soon. In the mean time i would appreciate some ideas how to sort the following problem

IF I LAUNCH AN EXISTING SCREENSAVER on one monitor than the process starts to intercept all keyboard and mouse inputs and therefore self-close itself as soon as i do an operation on the other screen. HOW CAN this be avoided?? (beside writing my on screensaver on a separate gui)

One of my attempt was

  • 1 Use create process to launch the screensaver
  • 2 catching the generated thread
  • 3 Hooking it with a callback and SetWindowsHookEx function (absolutely local)

but it does not work the thread generated does not receive the hook. Only Hotkey is capable to intercept the keystrokes before the screensaver.

But not all bad news are bad so to induce you guys to help me i will start by sharing the PROCESSCREATE function. It can be extremely useful to control the way programs open (much more powerful than the classic RUN()

CODE

#include <winapi.au3>

;#include <A3LWinAPI.au3>

; =======================================================================

; Process Create Flags Constants

; =========================================================================

Global Const $IDLE_PRIORITY_CLASS =0x00000040

Global Const $BELOW_NORMAL_PRIORITY_CLASS =0x00004000

Global Const $NORMAL_PRIORITY_CLASS =0x00000020

Global Const $ABOVE_NORMAL_PRIORITY_CLASS =0x00008000

Global Const $HIGH_PRIORITY_CLASS =0x00000080

Global Const $REALTIME_PRIORITY_CLASS =0x00000100

Global Const $DETACHED_PROCESS =0x00000008

Global Const $CREATE_NEW_CONSOLE=0x00000010

; ==============================================================================

; Startup Constants

; ==============================================================================

Global Const $STARTF_USESHOWWINDOW = 0x00000001

Global Const $STARTF_USESIZE = 0x00000002

Global Const $STARTF_USEPOSITION = 0x00000004

Global Const $STARTF_USECOUNTCHARS = 0x00000008

Global Const $STARTF_USEFILLATTRIBUTE = 0x00000010

Global Const $STARTF_RUNFULLSCREEN = 0x00000020

Global Const $STARTF_FORCEONFEEDBACK = 0x00000040

Global Const $STARTF_FORCEOFFFEEDBACK = 0x00000080

Global Const $STARTF_USESTDHANDLES = 0x00000100

; ===============================================================================

; ShowWindow Constants

; =================================================================================

Global Const $SW_HIDE = 0

Global Const $SW_SHOWNORMAL = 1

Global Const $SW_NORMAL = 1

Global Const $SW_SHOWMINIMIZED = 2

Global Const $SW_SHOWMAXIMIZED = 3

Global Const $SW_MAXIMIZE = 3

Global Const $SW_SHOWNOACTIVATE = 4

Global Const $SW_SHOW = 5

Global Const $SW_MINIMIZE = 6

Global Const $SW_SHOWMINNOACTIVE = 7

Global Const $SW_SHOWNA = 8

Global Const $SW_RESTORE = 9

Global Const $SW_SHOWDEFAULT = 10

Global Const $SW_FORCEMINIMIZE = 11

Global Const $SW_MAX = 11

;============================================================================

; ProcessCreate Needed structures

; =============================================================================

Global Const $tagSECURITY_ATTRIBUTES = "int Length;ptr Descriptor;int InheritHandle"

Global Const $tagSTARTUPINFO = "int Size;ptr Reserved1;ptr Desktop;ptr Title;int X;int Y;int XSize;int YSize;int XCountChars;" & _

"int YCountChars;int FillAttribute;int Flags;short ShowWindow;short Reserved2;ptr Reserved3;int StdInput;" & _

"int StdOutput;int StdError"

Global Const $tagPROCESS_INFORMATION = "hwnd hProcess;hwnd hThread;int ProcessID;int ThreadID"

;=============================================================================

; ProcessCreate

; ===============================================================================

$Nm = "" ;<<--- 1 can be ignored

$Cm= "ssstars.scr /s" ;<<--- 2

$ProcSec = DllStructCreate($tagSECURITY_ATTRIBUTES)

DllStructSetData ($ProcSec,"Length",DllStructGetSize($ProcSec))

DllStructSetData ($ProcSec,"InheritHandle",False) ; inherit security process

$pProcSec = DllStructGetPtr($ProcSec) ;<<--- 3

$ThredSec = DllStructCreate($tagSECURITY_ATTRIBUTES)

DllStructSetData ($ThredSec,"Length",DllStructGetSize($ThredSec))

DllStructSetData ($ThredSec,"InheritHandle",False) ;; inherit security Thread

$pThredSec = DllStructGetPtr($ProcSec) ;<<--- 4

$Inht = True ;<<--- 5

$Flags = BitOR($NORMAL_PRIORITY_CLASS,0) ;<<--- 6

$Env = 0 ;<<--- 7

$dir = "" ;<<--- 8 no working dir specified

; -------------startup elements

$StartUp = DllStructCreate($tagSTARTUPINFO)

DllStructSetData ($StartUp,"Size",DllStructGetSize($StartUp))

DllStructSetData($Startup, "ShowWindow",$SW_SHOWNOACTIVATE)

DllStructSetData($Startup, "Flags",BitOR($STARTF_USESHOWWINDOW,$STARTF_FORCEONFEEDBACK))

$pStartUP = DllStructGetPtr($StartUp) ;<<--- 9

$ProcInfo= DllStructCreate($tagPROCESS_INFORMATION)

$pProcInfo= DllStructGetPtr($ProcInfo) ;<<--- 10

_WinAPI_CreateProcess($Nm, $Cm, $pProcSec, $pThredSec, $Inht, $Flags, $Env,$dir, $pStartUP, $pProcInfo)

$Hproc = DllStructGetData($ProcInfo,1) ;- A handle to the newly created process

$Hthr = DllStructGetData($ProcInfo,2) ;- A handle to the primary thread of the newly created process

$PID = DllStructGetData($ProcInfo,3) ;- A value that can be used to identify the process

$ThID = DllStructGetData($ProcInfo,4) ;- A value that can be used to identify the thread

_oo("$Hproc =0x; $hthr=0x; $Pid=; $ThId =; ",Hex($Hproc), Hex($hthr),$Pid,$ThId )

;**********************************************************************************************

; debugging funciton

;************************************************************************************************

Func _oo ($Input, $Inp1=0, $Inp2=0, $Inp3=0, $Inp4=0, $Inp5=0, $Inp6=0, $Inp7=0, $Inp8=0, $Inp9=0, $Inp10=0)

Dim $str,$i, $Output="",$param

$str = StringSplit ($input,";")

For $i = 1 To $str[0] -1

$param=String(Eval("Inp"&String($i)))

$Output =$Output & $str[$i] & $param

Next

ConsoleWrite ($Output & @CR)

EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...