Gyzmok Posted June 16, 2006 Share Posted June 16, 2006 (edited) This is propably a no brainer, but I don't see it. :"> In this example script (original from quaiziwabbit), how do I detect a "button1" and/or "button2" keypress ?Only "button3" is detected in the script below. (needs beta and the anygui.au3 include)expandcollapse popup#include <ANYGUI.au3> #include <guiconstants.au3> Run("notepad.exe") Sleep(1000) ;WinSetState("Naamloos - Kladblok", "", @SW_MAXIMIZE) ;$Targetwindow = _GuiTarget ("Naamloos - Kladblok",1); mode 1 set so all '_Targetadd(s) go to this window WinSetState("Untitled - Notepad", "", @SW_MAXIMIZE) $Targetwindow = _GuiTarget ("Untitled - Notepad", 1); mode 1 set so all '_Targetadd(s) go to this window ControlMove($Targetwindow, "", 15, 0, 0, 800, 500);resize Edit1 control so everything fits $btn1 = _TargetaddButton ( "Button1", 30, 550, 100, 50); GUISetState(@SW_SHOW); $btn2 = _TargetaddButton ( "Button2", 550, 550, 100, 50); GUISetState(@SW_SHOW); $Child = _TargetaddChild ("Test", 810, 0, 205, 500); GUISetBkColor(0xff000); $label1 = GUICtrlCreateLabel("Child Window", 60, 0, 100, 30) $btn3 = GUICtrlCreateButton("Button3", 52, 35, 100, 50); $grp1 = GUICtrlCreateGroup("Testing", 20, 90, 165, 200); $radio1 = GUICtrlCreateRadio("A", 95, 120); $radio2 = GUICtrlCreateRadio("B", 95, 180); $radio3 = GUICtrlCreateRadio("C", 95, 240); $Date = GUICtrlCreateDate("My Calender", 20, 300, 165, 180); GUISetState(@SW_SHOW); $tab = _TargetaddTab (300, 500, 715, 210); $tab1 = GUICtrlCreateTabItem("First"); $tab2 = GUICtrlCreateTabItem("Second"); $tab3 = GUICtrlCreateTabItem("Third"); GUISetState(@SW_SHOW) While WinExists($Targetwindow) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case Not WinExists($Targetwindow) Exit Case $msg = $btn1 MsgBox(0,"test","Button1 pressed") Case $msg = $btn2 MsgBox(0,"test","Button2 pressed") Case $msg = $btn3 MsgBox(0,"test","Button3 pressed") Case Else EndSelect Sleep(50) WEnd Edited June 16, 2006 by Gyzmok D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper Link to comment Share on other sites More sharing options...
is8591 Posted June 16, 2006 Share Posted June 16, 2006 I did not run the script but it looks like the same way as Button3 in message loop:Case $msg = $btn1 MsgBox(0,"test","Button1 pressed")Case $msg = $btn2 MsgBox(0,"test","Button2 pressed")Case $msg = $btn3 MsgBox(0,"test","Button3 pressed") Link to comment Share on other sites More sharing options...
Gyzmok Posted June 16, 2006 Author Share Posted June 16, 2006 (edited) Well ... that's the point : it's in the script, but it doesn't work. You should run the script and then you'll see.(you need the anygui.au3 #include to make it work)Anygui.au3 UDF let you add objects to an existing GUI application (as child windows).I would like to use this principle in other applications, but it seems that only button3 is "trapped" by the while...Wend loop. I think it has to do something with the multiple windows that are open : button1 and button2 are in different child windows than button3.How can I "trap" all of them ? Edited June 16, 2006 by Gyzmok D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper Link to comment Share on other sites More sharing options...
GaryFrost Posted June 16, 2006 Share Posted June 16, 2006 Case $msg = $btn1[0] MsgBox(0, "test", "Button1 pressed") Case $msg = $btn2[0] MsgBox(0, "test", "Button2 pressed") SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Gyzmok Posted June 16, 2006 Author Share Posted June 16, 2006 Thanks a lot gafrost ! It works fine. I think I understand it now : ... Func _TargetaddButton($text, $PosX, $PosY, $SizeX, $SizeY, $style = -1, $exstyle = -1, $LocTargethWnd = 0) If not ($LocTargethWnd = 0) Then $TargethWnd = $LocTargethWnd Local $a[3] $a[2] = _TargetaddChild($text, $PosX, $PosY, $SizeX, $SizeY, $TargethWnd) $a[0] = GUICtrlCreateButton($text, 0, 0, $SizeX, $SizeY, $style, $exstyle) $a[1] = ControlGetHandle($a[2], "", $a[0]) If $a[2] = 0 Or $a[0] = 0 Or $a[1] = "" Then SetError(1) Return 0 Else Return $a EndIf EndFunc ;==>_TargetaddButton ... The function _TargetaddButton returns an array and the button control-id is stored in $a[0] . D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now