Jump to content

Run a program in specific windows size


akorx
 Share

Recommended Posts

Hi guys,

I've got a little problem, and perhaps a big if I don't find a solution !

At work we have to change ours screen's settings to use big resolution but one of our application runs very bad if we don't use a resolution of 1024x768. I've tried to find a way on google but I've found nothing. So I've decided to create a little autoit script that will load this program in a windows (that has got the good size) but I don't know where I should start... perhaps use GUIcreate() ?

Have you got an idea ?

The best way should be something like that : loader.exe -w 1024 -h 768 "my program"

PS :

- computer are one Windows XP SP3 and I've to do this on 300 computers.

- sorry for my bad english, I hope you will understand my query.

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

Thx for your somdcomputerguy but I think that WinMove() function is to "light" because it won't forbid a resize by the user... I think a good way is to do something like that :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$prg='c:\Program Files\InfraRecorder\InfraRecorder.exe'

$hGUI = GUICreate("Loader", 1024, 768, 5, 5 ,BitOR($WS_SYSMENU,$WS_CLIPCHILDREN))
GUISetState(@SW_SHOW)

$pid=Run($prg,"",@SW_HIDE)
Sleep(1000)
While ProcessExists($pid) = 0
    Sleep(100)
WEnd
$title=_WinGetByPID($pid,1)
;msgbox(4096,"DEBUG",$title)
;Exit

WinWaitActive($title)

$hPRG= WinGetHandle($title)
_SetParent($hPRG, $hGUI)
WinSetState($hPRG, "", @SW_SHOWMAXIMIZED)

Do
Sleep(10)
Until GuiGetMsg() =-3

Func _SetParent($id_child, $h_parent)
    If Not IsHWnd($h_parent) Then $h_parent = HWnd($h_parent)
    If Not IsHWnd($id_child) Then $id_child = GUICtrlGetHandle($id_child)
    If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $id_child, "hwnd", $h_parent) <> 0 Then
        Return 1
    Else
        seterror(1)
        Return 0
    EndIf
EndFunc

Func _WinGetByPID($iPID, $iArray = 1) ; 0 Will Return 1 Base Array & 1 Will Return The First Window.
    Local $aError[1] = [0], $aWinList, $sReturn
    If IsString($iPID) Then
        $iPID = ProcessExists($iPID)
    EndIf
    $aWinList = WinList()
    For $A = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$A][1]) = $iPID And BitAND(WinGetState($aWinList[$A][1]), 2) Then
            If $iArray Then
                Return $aWinList[$A][1]
            EndIf
            $sReturn &= $aWinList[$A][1] & Chr(1)
        EndIf
    Next
    If $sReturn Then
        Return StringSplit(StringTrimRight($sReturn, 1), Chr(1))
    EndIf
    Return SetError(1, 0, $aError)
EndFunc   ;==>_WinGetByPID

1- This is a first step and just with infrarecorder.exe... now the next step is to delete this :

Sleep(1000)
While ProcessExists($pid) = 0
    Sleep(100)
WEnd

... because I don't know how many time will take infrarecorder to start completely and perhaps it will never start so I must integrate à timeout.

2- There will be a big bug if the program called (here infrarecorder) opens a second window just after the start (for example if it ask for a password or if it gives tips at startup), because the name of the windows given by $title won't be the good one ! It must the PARENT windows ! perpahs with _WinAPI_GetAncestor() ? How can I do ?

3- The last step will to use $cmdline to give in arguments the size of the window and the name of the program that must be called, like this : loader.exe -w 1024 -h 768 "my program". But there will have a problem with ProcessWait() if there is 2 instances of the program (example we have load infrarecorder twice) how will I do ?

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

  • Moderators

akorx, you posted this in the Examples forum - you know, the one that states THIS IS NOT A GENERAL SUPPORT FORUM at the top?? Might be wise to ask a Mod to move the post to the correct forum, and be aware of where you're posting in the future.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

This forum is for people who would like to show their work as an Example, not for someone who is asking for help to get it to work, so it can someday become an example...If you need help with the script, which it appears you do, we are happy to assist. But you will get more eyes on the subject if you post in the right spot.

Once you get the bugs worked out, you're more than welcome to post the working script here as an example to others.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I've send a message to "contact" to move this post is the good forum.

Now, I'm waiting for a solution for my 3 questions (points "1-" , "2-" and "3-") , who can help me ?

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

  • Moderators

akorx,

Please do not bump your own threads within 24 hours. :naughty:

Remember that this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. Although the problem might be urgent to you, it is not to anyone else. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...