chandler1983 Posted October 3, 2013 Posted October 3, 2013 Hi everyone, I have an excel spreadsheet with file numbers on it. The file numbers change daily, and needs to be the plug-in variable for my autoit script. Is there a function/command which will read what was clicked in excel and pass that to my autoit script? Once a user clicks the file number, it should copy the text and paste into autoit and run normally. Any one? Thanks!
reb Posted October 3, 2013 Posted October 3, 2013 (edited) _IsPressed might do what you are looking for. Check the help file 01 Left mouse button 02 Right mouse button Then read the active cell REB On 2nd thought it might not read key presses from another window. Sorry if it doesn't You could click your cell then use a button or what ever in your program to read the active cell in excel. REB Edited October 3, 2013 by reb MEASURE TWICE - CUT ONCE
reb Posted October 3, 2013 Posted October 3, 2013 (edited) compile then run this click on any program and see the message box tested with desk top, SciTE, and note pad #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=..\..\..\..\..\Desktop\check returns.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Do $msg = GUIGetMsg() If _IsPressed('01', $hDLL) Then ; Left mouse click ;;;;;;;;;;;;;; Your script here ;;;;;;;;;;;;;; MsgBox(0, "", "Hi") While _IsPressed("01", $hDLL) Sleep(250) WEnd EndIf Until _IsPressed('1B') ;; ESCAPE DllClose($hDLL) Exit REB Just checked excel and it works there also looked at the help file and added important dll open and close Edited October 3, 2013 by reb MEASURE TWICE - CUT ONCE
reb Posted October 4, 2013 Posted October 4, 2013 Here is a tamed version which might be what you want. Shift + Alt + z toggles capture on and off expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=..\..\..\..\..\Desktop\check returns.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include <Excel.au3> #include <WindowsConstants.au3> Local $hDLL = DllOpen("user32.dll") Global $Column, $Row, $title, $text, $flag = 0 ClipPut("") HotKeySet('!+z', 'Flag') ;;;;;;; Toggles Capture on and off ;;;;;;;; $Excel = _ExcelBookNew() _ExcelBookOpen($Excel) $title = WinGetTitle('') Do If $flag > 0 Then ToolTip("TO MY PROG.") ;;;; Reminder that capture is on ;;;; $msg = GUIGetMsg() $msg2 = $msg If _IsPressed('01', $hDLL) Then CheckForMyProgram() ; Left mouse click While _IsPressed("01", $hDLL) Sleep(250) WEnd Until _IsPressed('1B', $hDLL) ;; ESCAPE DllClose($hDLL) _ExcelBookClose($Excel, 0, 0) Exit Func CheckForMyProgram() If $flag < 1 Then Return $Win = WinGetTitle('') If $Win <> $title Then Return EndIf $Column = $Excel.Activecell.Column $Row = $Excel.Activecell.Row $text = _ExcelReadCell($Excel, $Row, $Column) WinActivate($title) Main() EndFunc ;==>CheckForMyProgram Func Main() ToolTip("") MsgBox(0, "", "YOUR PROGRAM IS RUNNING WITH INFORMATION CAPTURED FROM EXCEL " & $text, 2) HotKeySet('!+z', 'Flag') WinActivate($title) ;;;;;;;;;;;;;; Your script here ;;;;;;;;;;;;;; EndFunc ;==>Main Func Flag() If $flag = 0 Then $flag = 1 Else $flag = 0 ToolTip("") EndIf ConsoleWrite($flag & " = $flag" & @CRLF) EndFunc ;==>Flag Good luck with your project REB MEASURE TWICE - CUT ONCE
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