Jump to content

Run Notepad inside GUI


jfcby
 Share

Recommended Posts

How can the following script be modified to run notepad inside an GUI?

Global $oNotepad

 $oNotepad = ObjCreate("notepad.exe")
;~     If Not IsObj($oNotepad) Then
;~         MsgBox(8192, "test", "quit!")
;~         Exit
;~     EndIf

GUICreate("test")
GUICtrlCreateObj($oNotepad, 10, 10, 300, 300)

GUISetState(@SW_SHOW)

while 1
    $msg = GUIGetMsg()
    If $msg = -3 Then
        GUIDelete()
    EndIf

    Sleep(20)
WEnd

Thank you for your help,

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
Share on other sites

How can the following script be modified to run notepad inside an GUI?

Global $oNotepad

 $oNotepad = ObjCreate("notepad.exe")
;~     If Not IsObj($oNotepad) Then
;~         MsgBox(8192, "test", "quit!")
;~         Exit
;~     EndIf

GUICreate("test")
GUICtrlCreateObj($oNotepad, 10, 10, 300, 300)

GUISetState(@SW_SHOW)

while 1
    $msg = GUIGetMsg()
    If $msg = -3 Then
        GUIDelete()
    EndIf

    Sleep(20)
WEnd

Thank you for your help,

jfcby

Since the above is not possible then how would Valuater and holger code below be modified to:

1. Remove Valuater xskin

2. show notepad inside a default GUI

I've studied the code and I do not undstand what to remove and what to keep.

#include <GUIConstantsEx.au3>
#include <XSkin.au3>
;#include <XSkinShell.au3>

Dim $loop, $Myrunner

; folder of skin
$Skin_Folder = @ScriptDir & "\Skins\Universal"

$XSkinGui = XSkinGUICreate ( "My GUI", 400, 450, $Skin_Folder)

$Icon_Folder = @ScriptDir & "\Skins\Default"



    Local $XhWnd = 0, $XstPID = DllStructCreate("int"), $XSWinList, $XhWinSize, $XSdll, $XPID, $XPID2, $XR_Ret[3], $Xh_ret, $oxStyle, $ostyle
    $XPID = Run($XR_Program, '', @SW_HIDE)
    Do
        $XSWinList = WinList()
        For $i = 1 To $XSWinList[0][0]
            If $XSWinList[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $XSWinList[$i][1], "ptr", DllStructGetPtr($XstPID))
                If DllStructGetData($XstPID, 1) = $XPID Then
                    $XhWnd = $XSWinList[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(20)
    Until $XhWnd <> 0
    $XSdll = ""
    $XstPID = 0
    If $XhWnd <> 0 Then
        $XhWinSize = WinGetPos($XhWnd)
        $XPID2 = XSkinGUICreate ( $XR_Title, ($XhWinSize[2]) + ($tile_size * 2) , ($XhWinSize[3]) + ($tile_size * 2), $Skin_Folder)
        If FileExists($Icon_Folder) Then $Xh_ret = XSkinIcon ($XPID2)
        $oxStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $XPID2, "int", -16)
        DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $XPID2, "int", -16, "long", BitOR($oxStyle[0], $WS_CLIPCHILDREN))
        $ostyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $XhWnd, "int", -16)
        DllCall("user32.dll", "int", "SetParent", "hwnd", $XhWnd, "hwnd", $XPID2)
        DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $XhWnd, "int", -16, "long", BitOR($WS_POPUP, $WS_CHILD, $WS_VISIBLE, $WS_CLIPSIBLINGS))
        GUISetState()
        WinMove($XhWnd, "", $tile_size, $tile_size)
        WinSetState($XhWnd, "", @SW_SHOW)
        WinActivate($XhWnd)
        $XR_Ret[0] = $XPID2
        $XR_Ret[1] = $XhWnd
        $XR_Ret[2] = $Xh_ret[1]
        Return $XR_Ret
    EndIf

Thank you for your help,

jfcby

Edited by jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
Share on other sites

The below code was found on this forum. It includes notepad in an AutoIt GUI. With my modifications it still does not inclde Notepad++ or Miscrosoft Word. How can I get the following script to include notepad++ and Miscrosoft Word in an AutoIt GUI?

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

$GUI = GUICreate("Audio Setup (Virtual Audio Cable) - Qsek", 1000, 484, 10, 10, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_CLIPCHILDREN,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))

GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")


$PID_AR1 = Run(@WindowsDir & '\notepad.exe') ; Mic(Soundcard)      --> VirtualCable 1
WinWaitActive("[CLASS:notepad]", "", 5)     ;wait 5 seconds
$PID_AR2 = Run(@ProgramFilesDir & '\Notepad++\notepad++.exe') ; SBM(VirtualCable 2) --> VirtualCable 1
WinWaitActive("[CLASS:Notepad++]", "", 10)  ;wait 5 seconds
$PID_AR3 = Run(@ProgramFilesDir & '\Microsoft Office\OFFICE11\WINWORD.EXE') ; SBM(VirtualCable 2) --> Soundcard
WinWaitActive("[CLASS:OpusApp]", "", 5)     ;wait 5 seconds -- Miscrosoft Word

$AR1 = _GetHwndFromPID($PID_AR1)
$AR2 = _GetHwndFromPID($PID_AR2)
$AR3 = _GetHwndFromPID($PID_AR3)

MsgBox(0, "Debug:", "$AR1 = " & $AR1 & @CRLF & "$AR2 = " & $AR2 & @CRLF & "$AR3 = " & $AR3)

WinSetTitle($AR1,"","Mic(Soundcard) --> VirtualCable 1")
WinSetTitle($AR2,"","SBM(VirtualCable 2) --> VirtualCable 1")
WinSetTitle($AR3,"","SBM(VirtualCable 2) --> Soundcard")

_WinAPI_SetWindowLong($AR1, $GWL_EXSTYLE , $WS_EX_MDICHILD)
_WinAPI_SetParent($AR1,$GUI)
_WinAPI_SetWindowLong($AR2, $GWL_EXSTYLE , $WS_EX_MDICHILD)
_WinAPI_SetParent($AR2,$GUI)
_WinAPI_SetWindowLong($AR3, $GWL_EXSTYLE , $WS_EX_MDICHILD)
_WinAPI_SetParent($AR3,$GUI)

WinMove($AR1,"",0       ,0,340,300)
WinMove($AR2,"",340     ,0,340,300)
WinMove($AR3,"",340+340 ,0,340,300)

While 1
    Sleep(10)
WEnd


Func _GetHwndFromPID($PID)
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc ;==>_GetHwndFromPID

Func Close()
    Exit
EndFunc

Thank you for your help,

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

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