rahoolm
Active Members-
Posts
26 -
Joined
-
Last visited
About rahoolm
- Birthday 09/24/1980
Profile Information
-
Location
Pune, India
-
Interests
Internet Browsing
Recent Profile Visitors
300 profile views
rahoolm's Achievements
Seeker (1/7)
0
Reputation
-
C# - get info (tool-tips) of System Tray icons.
rahoolm replied to shEiD's topic in AutoItX Help and Support
Thanks for the solution! Is there any way to Display a balloon like ToolTip on screen similar to AutoIt ToolTip in C#? I have used the AutoItX.ToolTip for C# but it is not showing the ToolTip on my windows 8 machine. Also, it has no option for balloon like tips. My intention is to show a tooltip near an IE DOM Element using the x, y position, I am working on WatiN Web UI Automation framework. Thanks for your help. -
Hi, is this question answered? I am into same situation where in I want to show a tooltip on screen. Now, AutoItX is coming with .NET dll directly, can we create a tooltip at a particular location on screen or say in IE window. I am automation browser with WatiN .NET framework. Now I aim to show tooltip where on IE, I am clicking. Please post your solution if already done. Thanks a lot!
-
Actually I want to code something in java but I am not familiar with it. I am good in AutoIt. I am automating a web side scenario in which I am not able to automate windows dialog for upload and download. So I want to use java code to do that. I am trying to use jna library. But I am not able to understand it. My plan is to understand the how it can work in AutoIt and then I will apply it through java. Currently using the above code I am able to automate upload of file with the web automation script. I am using Sahi Web Automation Please help!
-
Hello, I have a following autoit script which works fine for me. $title = "Open" $file = "C:\temp\mylogfile.txt" If WinExists($title) Then ControlSetText($title,"","[CLASS:Edit;]",$file) ControlClick($title, "", "[CLASS:Button; TEXT:&Open;]") Else MsgBox(0,"Upload Error", "Window not found", 2) EndIf Here I have used autoit functions. Instead of using autoit functions like WinExists, ControlSetText, ControlClick and MsgBox I want to use only functions from the _WinAPI_ UDFs Can anybody help me? regards, rahoolm
-
I am getting the following message in the console. --> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (Logout) --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType with the code below: $oLogout = _IEGetObjById($oIE, "Logout") and this error --> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Logout, Index: 0) --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType while using this code $oLogout = _IEGetObjByName($oIE, "Logout")
-
IE.au3 Get and Click object without id and having title="Logout" I want to get the object from the Web page code is below and click on it. <td title="Logout" class="icon-button" noWrap="nowrap" itemID="xxx522081682204.21765"> The structure where this td is located is as follows <form name="myForm"> <div>.... <div>.... <div> id = divToolbar... <div> <table....> <tbody...> <tr> <td...........> <td............> <td title="Logout" ........> How to get such object and then perform click operation on it? I am also attaching the exact html code image. Is there any general function available? Thanks in advance for help.
-
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
Thanks Richard! I got the solution and I am able to send string to cmd prompt using SendMessage. I used GetWindow method of Win32 API to find the child window handle of the picture box. Now I am able to send commands to the command prompt and also I am able to embed the cmd prompt in my GUI using SetParent method. Now I dont need a function like ControlSend anymore. I will try your method also. If you can provide a simple C# code. Thanks ! RAhooLm -
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
In my org, we have to set certain env using some variable and then only we can work on with other commands. This is to be done in same command prompt window by entering some commands one by one in a sequence or randomly. Moreover, I want that the user should be able to see what is going on in the command prompt window. The strings that will be passed to the command prompt will hard coded in the program. These strings(commands) are very long and difficult to remember. I do not want to collect the output of the command prompt to any file it should show the progress in the window itself. Let me know if you can help. I have successfully created application in Auto It v3 but I want to create it in csharp as autoit application is shown as virus in our org. Moreover, I have embedded the cmd prompt inside the WinForm so that user cannot interact with close or minimize button . Thanks for your time! Regards, Rahul (Currently I am trying to use PostMessage. I am successfull in sending certain characters to the command prompt but they are appearing in small case) -
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
I want to create an application (windows form application ) with button on it. When I click a particular button a string should be sent to command prompt window. Then when I click button2 then other string should be sent to the same command prompt window. The command prompt should be open all the time. I want that the string should be sent only when button is clicked. I tried using SendMessage that is user32.dll I am able to send string to Notepad. But I am not able to send a string to command prompt. /* * Created by SharpDevelop. * User: * Date: 5/6/2011 * Time: 4:06 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; namespace SendToNotepad { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } public const int WM_CLOSE = 16; void BtnOpenClick(object sender, EventArgs e) { int hwnd = -1; //Get a handle for the Calculator Application main window hwnd = FindWindow(null, "Untitled - Notepad"); if (hwnd == 0) { if (MessageBox.Show("Do you want to start it?", "Notepad", MessageBoxButtons.YesNo) == DialogResult.Yes) { Process ntp = Process.Start("notepad.exe"); } } else { MessageBox.Show("Application is running! Handle value is " + hwnd); } } [DllImport("User32.dll")] public static extern int FindWindow(string strClassName, string strWindowName); [DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")] public static extern Int32 SendMessage(int hWnd, int Msg, int wParam, int lParam); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam); void BtnCloseClick(object sender, EventArgs e) { int hwnd; //Get a handle for the Calculator Application main window hwnd = FindWindow(null, "Untitled - Notepad"); //send WM_CLOSE system message if (hwnd != 0) SendMessage(hwnd, WM_CLOSE, 0, IntPtr.Zero); else MessageBox.Show("Application is not running!"); } void BtnSendClick(object sender, EventArgs e) { int hwnd = 0; hwnd = FindWindow(null, "Untitled - Notepad"); //SendMessage((IntPtr)hwnd, 0x000C, 0, textBox1.Text); if (hwnd != 0) { IntPtr hwndChild = IntPtr.Zero; hwndChild = FindWindowEx((IntPtr)hwnd, new IntPtr(0), null, null); if(hwndChild != IntPtr.Zero) { SendMessage(hwndChild, 0x000C, 0, textBox1.Text); } else { MessageBox.Show("Cannot Get the Child Handle :( !"); } } else MessageBox.Show("Application is not running!"); } } } I think I am not able to get the correct value for 2nd option in the SendMessage function SendMessage(hwndChild, 0x000C, 0, textBox1.Text); 0x000C is for WM_SETTEXT When tried on notepad I observed that when I send this string to Notepad the contents of notepad are replaced. The strings are not getting appended to the previous string. Let me know if you can provide me a link for all SendMessage related constants. Also, if someone can tell how the ControlSend function in AutoIt was written then I think it will be very helpful. Thanks and Regards, Rahul -
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
Could you please explain me by giving an example? -
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
C# code which I am using to attach a cmd window to winform. Problem I am facing is when I click the command button the string should be passed to the cmd window. here is the code: /* * Created by SharpDevelop. * User: biggy * Date: 04/10/2007 * Time: 10:32 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; using System.IO; using System.Threading; namespace picBoxApp { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // // Killing a process // Process p= Process.GetProcessById(PID); // p.Kill(); } void Timer1Tick(object sender, EventArgs e) { System.IntPtr winParent; System.IntPtr x; System.IntPtr winHandle = Usr32.FindWin("ConsoleWindowClass", "MY OWN CONSOLE"); if(winHandle != System.IntPtr.Zero) { winParent = Usr32.GetParent(winHandle); x = Usr32.SetParent(winHandle, this.pictureBox1.Handle); x = Usr32.SetWindowPos(winHandle, 1, -5, -32, 649, 445, 0); this.timer1.Enabled = false; } } void BtnExitClick(object sender, EventArgs e) { //System.Diagnostics.Process.GetProcessById //this.timer1.Enabled = false; if (Usr32.MYCMDPID != 0) { try { System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(Usr32.MYCMDPID); if (p != null) { p.Kill(); } } catch { MessageBoxEx.Show("Process terminated Abnormally", "Error",200); } } Application.Exit(); } void BtnStartClick(object sender, System.EventArgs e) { //MessageBox.Show("Hello World", "Hello"); //string cmd1 = "generate business card"; //MessageBox.Show (cmd1 , "Command One"); //string pid; //uint pid; //CmdWindow pid = new CmdWindow(); if (Usr32.MYCMDPID != 0) { try { System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(Usr32.MYCMDPID); if (p != null) { p.Kill(); } } catch { MessageBoxEx.Show("Starting a new Process!", "Error",2000); } } Process mycmd = new Process(); mycmd.StartInfo.UseShellExecute = false; mycmd.StartInfo.Arguments += " /K TITLE MY OWN CONSOLE"; mycmd.StartInfo.FileName = "cmd.exe"; mycmd.StartInfo.CreateNoWindow = false; //mycmd.StartInfo.ErrorDialog = false; //mycmd.StartInfo.RedirectStandardError = true; //mycmd.StartInfo.RedirectStandardInput = true; //mycmd.StartInfo.RedirectStandardOutput = true; //mycmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // Do not show command prompt window separately //psi.CreateNoWindow = true; //psi.WindowStyle = ProcessWindowStyle.Hidden; //redirect all standard inout to program mycmd.Start(); this.timer1.Enabled = true; //mycmd.Close(); //MessageBox.Show("Process Id : " + bob.Id + " and Process Name : " + bob.ProcessName , "Process Details"); //link the streams to standard inout of process //StreamWriter inputWriter = mycmd.StandardInput; //StreamReader outputReader = mycmd.StandardOutput; //StreamReader errorReader = mycmd.StandardError; //send command to cmd prompt and wait for command to execute with thread sleep //inputWriter.WriteLine("DIR\r\n"); Usr32.MYCMDPID = mycmd.Id; } void BtnCommandClick(object sender, System.EventArgs e) { Process p = Process.GetProcessById(Usr32.MYCMDPID); IntPtr pid; pid = p.Handle; Usr32.SetForegroundWindow(pid); //Thread.Sleep(300); SendKeys.Send("DIR \r\n"); } void ChkBoxConsoleCheckedChanged(object sender, EventArgs e) { string mytitle; if (chkBoxConsole.Checked) { mytitle = "MY OWN CONSOLE"; Usr32.AllocConsole(); System.Console.Title = mytitle; } else Usr32.FreeConsole(); } void BtnAttachConsoleClick(object sender, EventArgs e) { this.timer1.Enabled = true; } } public class Usr32 { #region Class Variables public const int SM_CXSCREEN=0; public const int SM_CYSCREEN=1; public static int MYCMDPID=0; #endregion #region Class Functions [DllImport("user32.dll", EntryPoint="FindWindow")] public static extern IntPtr FindWin(string lpClassName, string lpWindowName); [DllImport("user32.dll", EntryPoint="SetParent")] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint="GetParent")] public static extern IntPtr GetParent(IntPtr hWnd); [DllImport("user32.dll", EntryPoint="SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter , int x , int Y , int cx , int cy , int wFlags); [DllImport("user32.dll", EntryPoint="ShowWindow")] public static extern IntPtr ShowWindow(IntPtr hWnd, long nCmdShow); [DllImport("user32.dll", EntryPoint="CloseWindow")] public static extern IntPtr CloseWindow(IntPtr hWnd); [DllImport("user32.dll", EntryPoint="DestroyWindow")] public static extern IntPtr DestroyWindow(IntPtr hWnd); [DllImport("User32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd); [DllImport("user32.dll")] public static extern uint SendMessage(IntPtr hWnd, uint nMessage, uint wParam, uint lParam); [DllImport("user32.dll")] public static extern uint PostMessage(IntPtr hWnd, uint nMessage, uint wParam, uint lParam); // my lines below are needed to make the console window visible [DllImport("kernel32.dll")] public static extern Boolean AllocConsole(); [DllImport("kernel32.dll")] public static extern Boolean FreeConsole(); #endregion } } -
How to create a C Sharp function similar to ControlSend
rahoolm replied to rahoolm's topic in AutoIt Technical Discussion
Here is the code in Auto It which I am using taken guidance from thread below My Code is below: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> ;~ Opt("GUIOnEventMode", 1) ; Change to OnEvent mode #region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 700, 500, 200, 20) Global $btnCommand = GUICtrlCreateButton("Command", 30, 50, 75, 25, $WS_GROUP) GUISetIcon("D:\102.ico") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### ;~ GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;~ GUISetOnEvent($btnCommand, "SENDCommand") GUIRegisterMsg(0xF, "WM_PAINT") Global $pid = Run("cmd.exe /T:F0 /k TITLE PLM") ProcessWait($pid) ; get the handle of the cmd window as i cannot be certain that there will be only one instance of the cmd running with the same window title or class Global $cmdHandle = _ProcessGetHWnd($pid, 2) ;~ _ArrayDisplay($cmdHandle) Global $hWndChild = $cmdHandle[1][1] DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $Form1) DllCall("user32.dll", "long", "SetwindowLong", "hwnd", $hWndChild, "int", -20, "long", 0x80000000 + 0x40000000 + 0x40000) GUISetStyle(BitOR($WS_POPUP, $WS_BORDER), '', $hWndChild) WinSetState($hWndChild, '', @SW_SHOW) WinMove($hWndChild, '', 140, 60, 498, 348) ;~ Global $handle = _gethwnd($pid) ;~ ConsoleWrite("Window Handle for " & $pid & " is " & $hWndChild & @CRLF) ;~ ControlSend($hWndChild,"","","Hello") ; inifinite event loop While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CLOSEClicked() Case $btnCommand SENDCommand() EndSwitch ; sleep for 100 milliseconds (to not hog the cpu) Sleep(100) ; end of event loop WEnd Func CLOSEClicked() ; take care of things to do when exiting ProcessClose($pid) Exit EndFunc ;==>CLOSEClicked Func SENDCommand() ConsoleWrite("Window Handle for " & $pid & " is " & $hWndChild & @CRLF) ControlSend($hWndChild, "", "", "DIR{ENTER}") EndFunc ;==>SENDCommand Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) Sleep(100) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0) EndFunc ;==>WM_PAINT Func _gethwnd($proc) $Windowlist = WinList() Local $winhandle = 0 For $i = 1 To $Windowlist[0][0] If WinGetProcess($Windowlist[$i][1]) = $proc Then $winhandle = $Windowlist[$i][1] EndIf Next ConsoleWrite("Window Handle for " & $proc & " is " & $winhandle & @CRLF) Sleep(500) Return $winhandle EndFunc ;==>_gethwnd ;=============================================================================== ; ; Function Name: _ProcessGetHWnd ; Description: Returns the HWND(s) owned by the specified process (PID only !). ; ; Parameter(s): $iPid - the owner-PID. ; $iOption - Optional : return/search methods : ; 0 - returns the HWND for the first non-titleless window. ; 1 - returns the HWND for the first found window (default). ; 2 - returns all HWNDs for all matches. ; ; $sTitle - Optional : the title to match (see notes). ; $iTimeout - Optional : timeout in msec (see notes) ; ; Return Value(s): On Success - returns the HWND (see below for method 2). ; $array[0][0] - number of HWNDs ; $array[x][0] - title ; $array[x][1] - HWND ; ; On Failure - returns 0 and sets @error to 1. ; ; Note(s): When a title is specified it will then only return the HWND to the titles ; matching that specific string. If no title is specified it will return as ; described by the option used. ; ; When using a timeout it's possible to use WinWaitDelay (Opt) to specify how ; often it should wait before attempting another time to get the HWND. ; ; ; Author(s): Helge ; ;=============================================================================== Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000) Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit() While 1 ; Get list of windows $aWin = WinList($sTitle) ; Searches thru all windows For $i = 1 To $aWin[0][0] ; Found a window owned by the given PID If $iPid = WinGetProcess($aWin[$i][1]) Then ; Option 0 or 1 used If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ; Option 2 is used ElseIf $iOption = 2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aWin[$i][0] $aReturn[$aReturn[0][0]][1] = $aWin[$i][1] EndIf EndIf Next ; If option 2 is used and there was matches then the list is returned If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn ; If timed out then give up If TimerDiff($hTimer) > $iTimeout Then ExitLoop ; Waits before new attempt Sleep(Opt("WinWaitDelay")) WEnd ; No matches SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd Also providing the C# code in next post. -
Hello All, I have created an application in C Sharp which has embedded cmd window inside it. Now I want to create button which when clicked should send a command to the cmd window. I have tried StreamWriter but it is not working as expected. I have created similar thing on Auto It V3. Can anybody help? Please let me know if you need any link for source code. I have the handle of the cmd window and PID of the cmd window. Regards, Rahul
-
Thanks to Authenticity!