siem123 Posted October 7, 2011 Share Posted October 7, 2011 (edited) Hi Guys, I'm a complete newbie to AutoIt, but I want to have a programm which can simulate key-strokes in our ERP system. Unfortunally, our ERP programm only accepts CAPITAL characters, and since the data is not always in capital, I want to force capslock, regardless of the data. But I'm completely lost between the differences: Opt("SendCapslockMode",0) Send("{CAPSLOCK on}") Send("{CAPSLOCK off}") Send("{CAPSLOCK toggle}") Send("{CAPSLOCK toggle}") Send("{CAPSLOCK Down}") Send("{CAPSLOCK up}") Can someone tell me what I need to do, to force capslock? Thanks in advanced! Siem Edited October 7, 2011 by siem123 Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 7, 2011 Share Posted October 7, 2011 Do you "only" want to send keystrokes? Why not just sending them in capital letters instead of sending capslock before? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
siem123 Posted October 7, 2011 Author Share Posted October 7, 2011 I don't want to change the data I have. It is a database of old drawings, which are not all in capital.. Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 7, 2011 Share Posted October 7, 2011 If you just want to Send texts, then you could use Func _SendCapital($text, $flag = 0) Send(StringUpper($text), $flag) EndFunc ;==>_SendCapital Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
siem123 Posted October 10, 2011 Author Share Posted October 10, 2011 (edited) I've been trying to place the piece of code, but I don't know where to place it so it works. Can you help me by placing it in the attachted code? expandcollapse popup; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "Create items in Glovia", "This script will create items in Glovia. Is Glovia open on the right spot?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "AutoIt", "Then put is there. Bye!") Exit EndIf ; Put Glovia on Top WinActivate("glovia.rad - NL_PILOT.PIV") ; Wait for Glovia to become active WinWaitActive("glovia.rad - NL_PILOT.PIV") ; Open Notepad for testing ; Run("notepad.exe") ; WinWaitActive("Untitled - Notepad") ; Open the input file $inputfile = FileOpen("itemcreationmaakdelen.csv",0) ; Check if file opened for reading OK If $inputfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Skip firstline Do $chars = FileRead($inputfile, 1) Until $chars = Chr(13) ; Read in 1 character at a time until the EOF is reached While 1 ; skip cr $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop ; Put ITEM in $component $component = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," Then $component = $component & $chars Until $chars = "," ; Put DESCRIPTION in $description $description = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," Then $description = $description & $chars Until $chars = "," ; Put HPL in $hpl $hpl = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $hpl = $hpl & $chars Until $chars = "," OR $chars = "_" ; Put COMMODITY in $commodity $commodity = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $commodity = $commodity & $chars Until $chars = "," OR $chars = "_" ; Put MFGENG in $mfg_eng $mfg_eng = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $mfg_eng = $mfg_eng & $chars Until $chars = "," OR $chars = "_" ; Put DWGNR in $dwg_nr $dwg_nr = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $dwg_nr = $dwg_nr & $chars Until $chars = "," OR $chars = "_" ; Put DWGREV in $dwg_rev $dwg_rev = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $dwg_rev = $dwg_rev & $chars Until $chars = "," OR $chars = "_" ; Put DWGDATE in $dwg_date $dwg_date = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $dwg_date = $dwg_date & $chars Until $chars = "," OR $chars = "_" ; Put DWGSIZE in $dwg_size $dwg_size = "" Do $chars = FileRead($inputfile, 1) If @error = -1 Then ExitLoop IF $chars <> "," AND $chars <> "_" Then $dwg_size = $dwg_size & $chars Until $chars = "," OR $chars = "_" OR $chars = Chr(13) ; Skip the rest of the line ;Do ; $chars = FileRead($inputfile, 1) ; If @error = -1 Then ExitLoop ;Until $chars = Chr(13) Sleep(600) Send("{CAPSLOCK ON}") Sleep(600) Send($component) Sleep(600) Send("{Enter 3}") Sleep(600) Send("ENG") Sleep(600) Send("{Enter}") Sleep(600) Send("!P") Sleep(600) Send($description) Sleep(600) Send("{Enter}") Sleep(600) Send("!R") Sleep(600) Send("NA") Sleep(600) Send("{Enter}") Sleep(600) Send("{F3 2}") Sleep(600) Send("!P") Sleep(600) Send($hpl) Sleep(600) Send("{Enter 4}") Sleep(600) Send("D") Sleep(600) Send("{Enter}") Sleep(600) Send($commodity) Sleep(600) Send("{Enter}") Sleep(600) Send("{F3 3}") Sleep(600) Send("!I") Sleep(600) Send("!E") Sleep(600) Send("{Enter 3}") Sleep(600) Send($mfg_eng) Sleep(600) Send("{Enter}") Sleep(600) Send($dwg_nr) Sleep(600) Send("{Enter}") Sleep(600) Send($dwg_rev) Sleep(600) Send("{Enter}") Sleep(600) Send($dwg_date) Sleep(600) Send("{Enter}") Sleep(600) Send($dwg_size) Sleep(600) Send("{Enter 2}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") If @error = -1 Then ExitLoop Wend FileClose($inputfile) ; Finished! EXIT Thanks in advance! Siem PS. I've been editing this script from another script. There may be better ways to code this, but I would like to keep this code for uniformity Edited October 10, 2011 by siem123 Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 10, 2011 Share Posted October 10, 2011 Just put the function at the end of your script and then replace your Send comands with this ... Example (before): Send($dwg_date) Example (after): _SendCapital($dwg_date) That's it. By the way, what are you doing with the file. Why do you read it over and over again? You could read it only once and the split the parts you need out of it. If you upload the csv and post the parts you need, I can change the code for you easily. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
siem123 Posted October 10, 2011 Author Share Posted October 10, 2011 It seems that that function is unknown. In AutoIT it doesn't get a color in the code, and when I run the .exe I get a error code: "nknown function name". How can that be, and more important, how can I fix it? As mentioned, I'm editing a existing program. I'm actually a mechanical engineer, trying to make my live a bit easier. For every new drawing we make, we have to create a new item in our ERP, currently we do it manually. The csv file is in the attached zip: itemcreationmaakdelen.zip Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 10, 2011 Share Posted October 10, 2011 Look at post #4 again. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 10, 2011 Share Posted October 10, 2011 Try somethig like this (untested!) expandcollapse popup#include<Array.au3> #include <file.au3> ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "Create items in Glovia", "This script will create items in Glovia. Is Glovia open on the right spot?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "AutoIt", "Then put is there. Bye!") Exit EndIf ; Put Glovia on Top WinActivate("glovia.rad - NL_PILOT.PIV") ; Wait for Glovia to become active WinWaitActive("glovia.rad - NL_PILOT.PIV") ; Open Notepad for testing ; Run("notepad.exe") ; WinWaitActive("Untitled - Notepad") Global $lines_A If Not _FileReadToArray(@ScriptDir & "\itemcreationmaakdelen.csv", $lines_A) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf _ArrayDisplay($lines_A) ; for testing For $i = 2 To UBound($lines_A) - 1 $partsPerLine_A = StringSplit($lines_A[$i], ',', 2) _ArrayDisplay($partsPerLine_A) ; show the parts for testing _insert($partsPerLine_A[0], $partsPerLine_A[1], $partsPerLine_A[2], $partsPerLine_A[3], $partsPerLine_A[4], $partsPerLine_A[5], $partsPerLine_A[6], $partsPerLine_A[7], $partsPerLine_A[8]) Next Func _SendCapital($text, $flag = 0) Send(StringUpper($text), $flag) EndFunc ;==>_SendCapital Exit Func _insert($component, $description, $hpl, $commodity, $mfg_eng, $dwg_nr, $dwg_rev, $dwg_date, $dwg_size) _SendCapital($component) Sleep(600) Send("{Enter 3}") Sleep(600) _SendCapital("ENG") Sleep(600) Send("{Enter}") Sleep(600) _SendCapital("!P") Sleep(600) _SendCapital($description) Sleep(600) Send("{Enter}") Sleep(600) _SendCapital("!R") Sleep(600) _SendCapital("NA") Sleep(600) Send("{Enter}") Sleep(600) Send("{F3 2}") Sleep(600) _SendCapital("!P") Sleep(600) _SendCapital($hpl) Sleep(600) Send("{Enter 4}") Sleep(600) _SendCapital("D") Sleep(600) Send("{Enter}") Sleep(600) _SendCapital($commodity) Sleep(600) Send("{Enter}") Sleep(600) Send("{F3 3}") Sleep(600) _SendCapital("!I") Sleep(600) _SendCapital("!E") Sleep(600) Send("{Enter 3}") Sleep(600) _SendCapital($mfg_eng) Sleep(600) Send("{Enter}") Sleep(600) _SendCapital($dwg_nr) Sleep(600) Send("{Enter}") Sleep(600) _SendCapital($dwg_rev) Sleep(600) Send("{Enter}") Sleep(600) _SendCapital($dwg_date) Sleep(600) Send("{Enter}") Sleep(600) _SendCapital($dwg_size) Sleep(600) Send("{Enter 2}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") Sleep(600) Send("{F3}") EndFunc ;==>_insert Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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