Sign in to follow this  
Followers 0
donhorn20

Help with _IsPressed only active when in a certain field box

9 posts in this topic

I am trying to work between two separate applications where if a control box in application 1 is selected, via the {END} button, it will send the contents over to application 2. The contents it is capturing is a phone number.

My problem though is with my winactive call outs. If I am not on the phone number box and am within a different box within the application and click {END}, it will copy the phone number text and send it over. I only want the {END} key to work when the cursor is in the "EDIT1" box, otherwise function as normal. Here is the window information along with my current piece of code. Could someone please help me on this? I believe my issue is with the active windows but am just drawing blanks.

>>>> Window <<<<

Title: Call Logging - [Work Group - 1 of 1]

Class: BENDATAWINHEAT

Position: 129, 0

Size: 850, 979

Style: 0x14CF8000

ExStyle: 0x00000100

Handle: 0x00500800

>>>> Control <<<<

Class: Edit

Instance: 1

ClassnameNN: Edit1

Name:

Advanced (Class): [CLASS:Edit; INSTANCE:1]

ID: 500

Text:

Handle: 0x000B1312

#include

Opt("WinTitleMatchMode", 2)
Opt("SendAttachMode",1)

Local $hDLL = DllOpen('user32.dll')

While 1
If _IsPressed('23', $hDLL) Then
WinWait ("[TITLE:Call Logging; CLASS:BENDATAWINHEAT]", "", 5)
Sleep(500)
local $click = ControlGetText("[CLASS:BENDATAWINHEAT]", "", "Edit1")
Sleep(500)
MsgBox(0, "ControlGetText", "The control text is: " & $click)
;WinActivate("[TITLE:Communicator; CLASS:WindowsForms10.window.8.app.0.3ce0bb8]") <<<<< This is the second application that will replace the msg box once I figure out the first part
;Send($click)<<<<
EndIf
WEnd
DllClose($hDLL)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

-Get the control coords: WinGetPos+ControlGetPos

-When the mouse is over the control enable the _IsPressed function: MouseGetPos

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

At what stage in my code would I be implementing this, before _IsPressed or after? Still learning how to write code properly, any help would be greatly appriciated. Also, if I understand this correctly, the suggested code would eliminate the potential problem if the phone number is in a different box wouldn't it? See attachement of what I mean.

post-67658-0-29324100-1365610159_thumb.j

Edited by donhorn20

Share this post


Link to post
Share on other sites

any help would be greatly appriciated

The helpfile is great for that.

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

Local Const $_iCXDLGFRAME = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)
Local Const $_iCYCAPTION = _WinAPI_GetSystemMetrics($SM_CYCAPTION)

#region GUI
$hGUI = GUICreate("MyGUI")

$iMyInput = GUICtrlCreateInput("", 20, 20)

GUISetState(@SW_SHOW, $hGUI)
#endregion

$aWgp = WinGetPos($hGUI)
$aControlPos = ControlGetPos($hGUI, "", $iMyInput)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)

    $aMgp = MouseGetPos()

    If $aMgp[0] >= $aWgp[0] + $_iCXDLGFRAME + $aControlPos[0] And $aMgp[0] <= $aWgp[0] + $aControlPos[0] + $aControlPos[2] _
                And $aMgp[1] >= $aWgp[1] + $_iCYCAPTION + $aControlPos[1] And $aMgp[1] <= $aWgp[1] + $_iCYCAPTION + $aControlPos[1] + $aControlPos[3] Then
        If _IsPressed(...
    EndIf
WEnd

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

FireFox, I appriciate the sample code and help provided so far. I am just not seeing how your sample code is works. I tried placing some code in the _IsPressed(... section but just not seeing it.

Just to let you know, I have been reading the help files over and over before even posting to the forum. I just can't seem to grasp the proper statements thus the reason I am asking for more help. Whats wierd is the INFO box tool says that the Phone field box and Mobile field box are the same Control ClassID's. Would I even need to worry about the mouse position if the class ID's are the same? See info box information below. I just want it to work where when I place the cursor inside that field box and click END that the copy action is performed. If the cursor is in any other box besides the EDIT1 then the END button will function as normal.

PHONE FIELD

>>>> Window <<<<

Title: Call Logging - [Work Group - 1 of 1]

Class: BENDATAWINHEAT

Position: 129, 0

Size: 850, 979

Style: 0x14CF8000

ExStyle: 0x00000100

Handle: 0x00500DF6

>>>> Control <<<<

Class: Edit

Instance: 1

ClassnameNN: Edit1

Name:

Advanced (Class): [CLASS:Edit; INSTANCE:1]

ID: 500

Text:

Position: 92, 217

Size: 89, 16

ControlClick Coords: 50, 7

Style: 0x50000180

ExStyle: 0x00000000

Handle: 0x005B0856

MOBILE PHONE FIELD

>>>> Window <<<<

Title: Call Logging - [Work Group - 1 of 1]

Class: BENDATAWINHEAT

Position: 129, 0

Size: 850, 979

Style: 0x14CF8000

ExStyle: 0x00000100

Handle: 0x00500DF6

>>>> Control <<<<

Class: Edit

Instance: 1

ClassnameNN: Edit1

Name:

Advanced (Class): [CLASS:Edit; INSTANCE:1]

ID: 500

Text:

Position: 306, 217

Size: 89, 16

ControlClick Coords: 35, 11

Style: 0x50000180

ExStyle: 0x00000000

Handle: 0x005A0856

Share this post


Link to post
Share on other sites

What about this?

$hWnd = WinGetHandle("Call Logging - [Work Group - 1 of 1]")

$aWgp = WinGetPos($hWnd)
$aControlPos = ControlGetPos($hWnd, "", "[CLASS:Edit; INSTANCE:1]")

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thanks for the suggested code, but I am still not understanding how I can make it so that when I click the keyboard END key that it will function like the END key should. However if I am within these two field boxes (phone or mobile) it will perform the copying of text? The code you provided still allows for the END button to produce results even if I am in a different program. I understand this is going to probably rely on a If/Then statement with the active windows being present or not, but just can't seem to get it.

Share this post


Link to post
Share on other sites

I understand this is going to probably rely on a If/Then statement with the active windows being present or not, but just can't seem to get it.

If WinActive($hWnd) > 0 Then
    ;do smt
EndIf


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Look into ControlGetFocus, and only send over when it's your expected classnn for the window.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  
Followers 0