Jump to content

Modifying other windows


gianfun
 Share

Recommended Posts

Hello all.

A loooong time ago, I had found some code that would resize the Windows Calculator (calc.exe), just to make it longer, and then put a button that would invoke a msgbox saying something, like a "hello" message of some kind.

This was done during the calc.exe runtime (i.e. not changing the exe, but rather interacting with it whilst it was open)

I have searched the forum, but found nothing.

Is this possible? or am I mistaking it for something else? Even though I am pretty sure it was Autoit.

Thanks :)

Edit:

Joy be the Help File.

Sorry people, I had tried some things such as getting the Handle of the window and then modifying it with GUI functions.

I now found WinMove (which I hadn't realized can also resize)

here's how it is

AutoItSetOption("WinTitleMatchMode", 4)

if not ProcessExists("calc.exe") Then
    run("calc.exe")
    sleep(300) ;wait for it to open.
Else
endif

$hWnd = ""
$iPID = ProcessExists("calc.exe")

If $iPID <> 0 Then
    $aWinList = WinList()

    For $i = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$i][0]) = $iPID Then
            $hWnd = $aWinList[$i][1]
            ExitLoop
        EndIf
    Next
EndIf

If $hWnd <> "" Then
    $title = WinGetTitle($hWnd)
    ;MsgBox(0, 0, $title & @CRLF & $hWnd)
Else
    MsgBox(64, "Not Found", "No matching process found.")
EndIf
WinActivate($title)
WinMove($title, "", 50,50,600,200) ;resizing. AH!

$control = GUICtrlCreateButton("hi", 500,100) ;Is this possible?

Func alert($msg)
    MsgBox(0, "MsgBox", $msg)
EndFunc

Well. I was able to resize.

Do I need to use a dll to add a control?

Thanks ;)

Edited by gianfun

My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]

Link to comment
Share on other sites

Hi,

yes it works...^^

#include <WindowsConstants.au3>
AutoItSetOption("WinTitleMatchMode", 4)

if not ProcessExists("calc.exe") Then
    run("calc.exe")
    sleep(300) ;wait for it to open.
Else
endif

$hWnd = ""
$iPID = ProcessExists("calc.exe")

If $iPID <> 0 Then
    $aWinList = WinList()

    For $i = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$i][0]) = $iPID Then
            $hWnd = $aWinList[$i][1]
            ExitLoop
        EndIf
    Next
EndIf

If $hWnd <> "" Then
    $title = WinGetTitle($hWnd)
    ;MsgBox(0, 0, $title & @CRLF & $hWnd)
Else
    MsgBox(64, "Not Found", "No matching process found.")
EndIf
WinActivate($title)
WinMove($title, "", 50,50,600,200) ;resizing. AH!


$a = GUICreate("huhu", 100, 50, 500,100, $WS_CHILD, -1, $hWnd)
$control = GUICtrlCreateButton("hi", 0,0,50,30) ;Is this possible?   YES^^

guisetstate()

While 1
    $msg = GUIGetMsg ( )
    If $msg = $control Then alert($msg)
WEnd


Func alert($msg)
    MsgBox(0, "MsgBox", $msg)
EndFunc
Link to comment
Share on other sites

Hi,

yes it works...^^

#include <WindowsConstants.au3>
AutoItSetOption("WinTitleMatchMode", 4)

if not ProcessExists("calc.exe") Then
    run("calc.exe")
    sleep(300) ;wait for it to open.
Else
endif

$hWnd = ""
$iPID = ProcessExists("calc.exe")

If $iPID <> 0 Then
    $aWinList = WinList()

    For $i = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$i][0]) = $iPID Then
            $hWnd = $aWinList[$i][1]
            ExitLoop
        EndIf
    Next
EndIf

If $hWnd <> "" Then
    $title = WinGetTitle($hWnd)
    ;MsgBox(0, 0, $title & @CRLF & $hWnd)
Else
    MsgBox(64, "Not Found", "No matching process found.")
EndIf
WinActivate($title)
WinMove($title, "", 50,50,600,200) ;resizing. AH!


$a = GUICreate("huhu", 100, 50, 500,100, $WS_CHILD, -1, $hWnd)
$control = GUICtrlCreateButton("hi", 0,0,50,30) ;Is this possible?   YES^^

guisetstate()

While 1
    $msg = GUIGetMsg ( )
    If $msg = $control Then alert($msg)
WEnd


Func alert($msg)
    MsgBox(0, "MsgBox", $msg)
EndFunc

Thank you very much :)

My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]

Link to comment
Share on other sites

Works fine. But I can't see the purpose of this script.

And what was the purpose of your comment? Pump your post count?

And this can be used to add functionality to programs...

My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]

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