Jump to content
Sign in to follow this  
quaizywabbit

ANYGUI.au3

Recommended Posts

I seem to remember a script that allowed the user toe enable controls in a target app

Wow, I gotta tell the drummer for Def Leppard about that one.

Share this post


Link to post
Share on other sites

I registered just now specifically so that I could thank you for this script. This is exactly what I need! This is excellent :)

Share this post


Link to post
Share on other sites

I registered just now specifically so that I could thank you for this script. This is exactly what I need! This is excellent :)

You're welcome! :D

I'm surprised this UDF has been going for over 2 years now with minor changes here and there and is still frequently downloaded....

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

Hi to every one, really sorry by my noob question that i will make:

I play a an online game Mu, i, as many others, want make a minimizer for it, but , in some point along the program, dosent work...

Can some one put a simple ex. code ,showing how we can resize a window with ANYGUI ? (like 800x600)

thks

Share this post


Link to post
Share on other sites

Hi. I am trying to use the AnyGui (2.8) to put an "info" window on top of an explorer window. The idea is to move down the control that holds the folder view (id 1) and leave a spot 100pixels high by the width of the window that I can put information about the folder in. I cannot seem to get a label, button or anything else to show up in that spot. I suspect it has something to do with the fact that I am trying to "anygui-ize" an Explorer window which may not be the same as calc or notepad in terms of controlling another gui, but am not sure. I was wondering if anyone has any ideas on this. Here is my code so far. Also, let me add that both the calc and notepad demos do work on my system.

#include <guiconstants.au3>
#include <ANYGUIv2.8.au3>

Opt("WinTitleMatchMode", 3)

$s_title = "C:\"
run("explorer " & $s_title)
WinWait ($s_title)

;Instantiate the anygui
$o_target = _GuiTarget ($s_title, 1 )
_SetWindow(0)
$s_winstats = _GetWindowStats($o_target)    ;window position check
$s_winsize = _GetWindowSize($o_target)      ;window resize check


While 1
    if($s_winstats <> _GetWindowStats($o_target)) Then
        _SetWindow(1)
        $s_winstats = _GetWindowStats($o_target)
    EndIf
    if($s_winsize <> _GetWindowSize($o_target)) Then
        _SetWindow(0)
        $s_winsize = _GetWindowSize($o_target)
    EndIf
    ;ConsoleWrite(GUIGetMsg($o_target))
    If Not WinExists($o_target) Then Exit
    Sleep(1000)
WEnd
      
Func _SetWindow($i_callnum)
    $a_controlinfo =ControlGetPos($o_target,"",1)
    if($i_callnum=0)Then
    ControlMove($o_target, "", 1, 0, 100, $a_controlinfo[2], $a_controlinfo[3]-100)
    EndIf
    GUISetState (@SW_SHOW)
    
    $a_wininfo = WinGetPos($o_target)
    $btn2 = _TargetaddButton ( "test",300,200,800,800)
    GUISetState(@SW_SHOW)
EndFunc

Func _GetWindowStats($o_target)
    $a_temp = WinGetPos($o_target)
    $s_comparestring = $a_temp[0] + $a_temp[1] + $a_temp[2] + $a_temp[3]
    
    Return $s_comparestring
EndFunc

Func _GetWindowSize($o_target)
    $a_temp = WinGetPos($o_target)
    $s_comparestring = $a_temp[2] + $a_temp[3]
    
    Return $s_comparestring
EndFunc

Share this post


Link to post
Share on other sites

@Reaper HGN

This is how you set a Button on an File Explorer and attach a function to it.

This will get you started.

#include <ANYGUI.au3>
#include <guiconstants.au3>

Opt("WinTitleMatchMode", 4) ; Allow ClassName lookup to avoid window confusion
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Global $handleList = ""
Dim $Test

While 1
    $appWindow = WinGetHandle("classname=ExploreWClass")
    If @error Then
        $handleList = "" ; No Explorer windows found, so clear the list
        sleep(250)
        ContinueLoop
    EndIf
    
;; CHECK WHETHER $handleList is up to date;;
    
;ToolTip("DEBUG:  " & $handleList & "      " & $appWindow)
    
;If $appWindow is not in our list, add it
    If Not StringInStr($handleList, "|" & $appWindow) Then
        $handleList = $handleList & "|" & $appWindow
        Addbutton($appWindow)
        
    Else
;;MsgBox(4096,"debug","present")
    EndIf

;If $handleList has no-longer-existing enteries, remove them
;Doesn't work, possibly due to syntax or handle-string conversion issues
    #cs
    $rebuiltList = ""
    $array = StringSplit($handleList, "|")
    For $i = 1 to $array[0]
        If WinExists("handle=" & $array[$i]) Then $rebuiltList = $rebuiltList & "|" & $array[$i]
    Next
    $handleList = $rebuiltList
    #ce
    
    sleep(250)
WEnd


Func Clicked()
    $test=ControlGetText("","",41477)
    MsgBox(0,"TEST","OK  "&$test)
EndFunc

Func AddButton($winhandle)
    Local $Targetwindow, $btn
    $Targetwindow = _GuiTarget($winhandle,"","FolderView",40960); mode 1 set so all '_Targetadd(s) go to this window
    $btn = _TargetaddButton ( "New Button", 740, 3, 80, 30,"","",$Targetwindow);
    GUICtrlSetOnEvent($btn[0], "Clicked") ; [0] returns the array element of the button see detail $a[0] in AnyGui Functions
    
    GUISetState(@SW_SHOW)
EndFunc

Regards,

ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites

@Reaper HGN

This is how you set a Button on an File Explorer and attach a function to it.

This will get you started.

#include <ANYGUI.au3>
#include <guiconstants.au3>

Opt("WinTitleMatchMode", 4) ; Allow ClassName lookup to avoid window confusion
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Global $handleList = ""
Dim $Test

While 1
    $appWindow = WinGetHandle("classname=ExploreWClass")
    If @error Then
        $handleList = "" ; No Explorer windows found, so clear the list
        sleep(250)
        ContinueLoop
    EndIf
    
;; CHECK WHETHER $handleList is up to date;;
    
;ToolTip("DEBUG:  " & $handleList & "      " & $appWindow)
    
;If $appWindow is not in our list, add it
    If Not StringInStr($handleList, "|" & $appWindow) Then
        $handleList = $handleList & "|" & $appWindow
        Addbutton($appWindow)
        
    Else
;;MsgBox(4096,"debug","present")
    EndIf

;If $handleList has no-longer-existing enteries, remove them
;Doesn't work, possibly due to syntax or handle-string conversion issues
    #cs
    $rebuiltList = ""
    $array = StringSplit($handleList, "|")
    For $i = 1 to $array[0]
        If WinExists("handle=" & $array[$i]) Then $rebuiltList = $rebuiltList & "|" & $array[$i]
    Next
    $handleList = $rebuiltList
    #ce
    
    sleep(250)
WEnd
Func Clicked()
    $test=ControlGetText("","",41477)
    MsgBox(0,"TEST","OK  "&$test)
EndFunc

Func AddButton($winhandle)
    Local $Targetwindow, $btn
    $Targetwindow = _GuiTarget($winhandle,"","FolderView",40960); mode 1 set so all '_Targetadd(s) go to this window
    $btn = _TargetaddButton ( "New Button", 740, 3, 80, 30,"","",$Targetwindow);
    GUICtrlSetOnEvent($btn[0], "Clicked") ; [0] returns the array element of the button see detail $a[0] in AnyGui Functions
    
    GUISetState(@SW_SHOW)
EndFunc

Regards,

ptrex

Thank you ptrex. That got me going. The ("classname=ExploreWClass") had to be changed to ("classname=CabinetWClass"), but the button shows up. Now all I have to do is incorporate that into what I am doing and it should be good to go.

Thanks for your help.

Share this post


Link to post
Share on other sites

Hi,

Can i use this to show/hide the titlebar of some window (not my gui)? what parameters should i pass?


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

I'm having some problems, I'm trying to put the GUI at coords 10, 10 in my Diablo II window. Problem is when I start the test script, it says "invalid coors(10, 10)"

Here's my script.

#include<_AnyGUI.au3>
#include<GUIConstants.au3>

Dim $XYCord[2]

$XYCord[0] = 0
$XYCord[1] = 0

WinActivate("Diablo II")

$Target = _GuiTarget("Diablo II", 1, -1, $XYCord)

$GUI = _TargetaddChild("D2ImP", 10, 10, 300, 300, $Target)

$Button1 = _TargetaddButton("Test", 20, 20, 40, 20, -1, -1, $Target)


While 1
    Sleep(1)
WEnd

Thanks in advance for any help.

~TK

Share this post


Link to post
Share on other sites

Look at SetWindowLong API function with GWL_STYLE and/or GWL_EXSTYLE parameter

Search this forum and MSDN for examples/details ...

Thanks, this is what i needed:

Func _ToggleWinTitleBar($hWnd)
    Local Const $SWP_NOMOVE = 0x2
    Local Const $SWP_NOSIZE = 0x1
    Local Const $SWP_SHOWWINDOW = 0x40
    Local Const $SWP_NOZORDER = 0x4
    Local $iFlags = BitOr($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    Local $wStyle
    
    $aRet = DllCall("User32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -16)
    
    If $aRet[0] <> -1803288576 Then
        $wStyle = $WS_POPUP + $WS_BORDER + $WS_SIZEBOX
    Else
        $wStyle = $WS_CAPTION+$WS_POPUP+$WS_SYSMENU+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX+$WS_SIZEBOX
    EndIf
    
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hwnd, "int", -16, "ptr", $wStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0,  "int", 0, "int", 0, "int", 0, "int", $iFlags)
EndFunc

But the problem is, that i can not use this function on all windows, because i can not know all styles that window have (originaly)...

How to toggle the titlebar but have an ability to restore the original styles when it toggeled back?


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks, this is what i needed:

Func _ToggleWinTitleBar($hWnd)
    Local Const $SWP_NOMOVE = 0x2
    Local Const $SWP_NOSIZE = 0x1
    Local Const $SWP_SHOWWINDOW = 0x40
    Local Const $SWP_NOZORDER = 0x4
    Local $iFlags = BitOr($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    Local $wStyle
    
    $aRet = DllCall("User32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -16)
    
    If $aRet[0] <> -1803288576 Then
        $wStyle = $WS_POPUP + $WS_BORDER + $WS_SIZEBOX
    Else
        $wStyle = $WS_CAPTION+$WS_POPUP+$WS_SYSMENU+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX+$WS_SIZEBOX
    EndIf
    
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hwnd, "int", -16, "ptr", $wStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0,  "int", 0, "int", 0, "int", 0, "int", $iFlags)
EndFunc

But the problem is, that i can not use this function on all windows, because i can not know all styles that window have (originaly)...

How to toggle the titlebar but have an ability to restore the original styles when it toggeled back?

Can't you save the styles for a given window and then restore when needed?

Why not use GuiGetStyle, GuiSetStyle?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

But the problem is, that i can not use this function on all windows, because i can not know all styles that window have (originaly)...

How to toggle the titlebar but have an ability to restore the original styles when it toggeled back?

Use GetWindowLong to get original styles and combine them (Bitxxx functions) with your for SetWindowLong

Share this post


Link to post
Share on other sites

I'm having some problems, I'm trying to put the GUI at coords 10, 10 in my Diablo II window. Problem is when I start the test script, it says "invalid coors(10, 10)"

Here's my script.

#include<_AnyGUI.au3>
#include<GUIConstants.au3>

Dim $XYCord[2]

$XYCord[0] = 0
$XYCord[1] = 0

WinActivate("Diablo II")

$Target = _GuiTarget("Diablo II", 1, -1, $XYCord)

$GUI = _TargetaddChild("D2ImP", 10, 10, 300, 300, $Target)

$Button1 = _TargetaddButton("Test", 20, 20, 40, 20, -1, -1, $Target)
While 1
    Sleep(1)
WEnd

Thanks in advance for any help.

~TK

You need to put some error checking in your script. The error message 'invalid coordinates' comes from _GuiTarget when the handle for the window with the title "Diablo II" is not found, or the coordinates given in your $XYCord are not over a control (presumably a child window) in the target window as far as I can see. So check what winactivate returns, it might be 0. Check that 10,10 is over the correct control or child window in "Diablo II" window.

Try _GuiTarget without the 4th parameter. I would have expected the third parameter to be "" rather than -1, but I might be wrong about that.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Can't you save the styles for a given window and then restore when needed?

No, the window is diferend every time, i can not save the info for all possible windows that script will work with :)

Why not use GuiGetStyle, GuiSetStyle?

This is in new version? but these are for AutoIT GUI(?), and i need for external windows.

Use GetWindowLong to get original styles

How?

Here is what i thouth that will do it:

$aRet = DllCall("User32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -16)

But it returns current styles as i understood, not original... or should i use it in other way? How?


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Well now I took out the fourth param in _GuiTarget and it works, it activates Diablo II and there are no errors, however... the GUI doesn't show up inside the D2 screen. Is there some kind of @SW_SHOW I have to use with AnyGUI?? There are no errors so the GUI is being created, it's just the problem of it will not show up, at all. Here's my script.

#include<_AnyGUI.au3>
#include<GUIConstants.au3>

WinActivate("Diablo II")

$Target = _GuiTarget("Diablo II", 1, "")

$GUI = _TargetaddChild("D2ImP", 10, 10, 300, 300, $Target)

$Button1 = _TargetaddButton("Test", 20, 20, 40, 20, -1, -1, $Target)


While 1
    Sleep(1)
WEnd

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...