-
Posts
32 -
Joined
-
Last visited
Baritonomarchetto's Achievements
Seeker (1/7)
0
Reputation
-
Hi all, I am trying to let my arduino communicate with autoit for a musical project (a hardware interface for software loop stations like Mobius). My goal is to send autoit some data over serial and then have autoit emulate keyboard presses. I am using CommMG library because I could find the easiest codes for that (I am not a coder in real life). Here is a link to the reference topic i got inspired from: This is the autoit code: #include <CommMG.au3> Global $CMPort = 3 Global $CmBoBaud = 9600 Global $sportSetError = '' Global $CmboDataBits = 8 Global $CmBoParity = "none" Global $CmBoStop = 1 Global $setflow = 2 _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) If @error Then MsgBox(16, "Error!", "Can't connect to Arduino on port - " & $CMPort) Exit EndIf _CommSetRTS(0) _CommSetDTR(0) While 1 receive() Sleep(100) WEnd Func receive() Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc As soon as i run the script, I get the "Error!", "Can't connect to Arduino on port - 3" message. Arduino is on COM 3 (at least this is what arduino IDE tells me). Here is the arduino code int a=0; void setup(){ Serial.begin(9600); } void loop(){ a++; Serial.print(a); delay(3000); } Any idea about the cause? Why they are not connecting to each other? Thanks!!
-
Hi, I have a very simple script here to shut down a process If ProcessExists("p-rog.exe") Then ; Check if the process is running. ProcessClose("p-rog.exe") EndIf Sleep(1000) Exit The problem is that if the process has a systray icon, the icon doesn't disappear until the mouse pointer pass over it... is that a bug or something? Is there a way to avoid this (the program is launched and closed variuos times, so the systray tends to be filled in icons...) ? Thanks!
-
Uh, thank you very much for the help! just a question: why only $P1 in set as Global variable and $P>1 not? EDIT: another Q: will "RunWait" prevent other programs to run while one is running or should i specify: If Not (ProcessExists("P1.exe") Or ProcessExists("P2.exe") or ProcessExists("P3.exe")) Then RunWait("C:\Programs\P1.exe")
-
Hi all, I wrote a little script intended to show up a GUI with a list you can select a program to load from. The problem is that the selected program, once loaded, is heavily slowed down so the script must be "heavy" while running in the background... here is the code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIScrollbars_Ex.au3" #include <GuiListView.au3> #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local $hGUI $hGUI = GUICreate("Select Program To Run", 250, 150,-1,-1,$WS_POPUP+$WS_BORDER) GUISetBkColor(0x3790e8) $listview = GUICtrlCreateListView("Select Program - press 1 to Run", 0, 0, 250,150, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetColumnWidth($listview, 0, 245) GUICtrlSetBkColor(-1,0x3790e8) $P1= GUICtrlCreateListViewItem("Program #1", $listview); ID 4 GUICtrlSetColor (-1, 0xFFFFFF) $P2= GUICtrlCreateListViewItem("Program #2", $listview); ID 5 GUICtrlSetColor (-1, 0xFFFFFF) $P3= GUICtrlCreateListViewItem("Program #3", $listview); ID 6 GUICtrlSetColor (-1, 0xFFFFFF) $win= GUICtrlCreateListViewItem("Exit to Windows", $listview); ID 7 GUICtrlSetColor (-1, 0xFFFFFF) $shutdown= GUICtrlCreateListViewItem("Shut Down PC", $listview); ID 8 GUICtrlSetColor (-1, 0xFFFFFF) GUISetState(@SW_SHOW) ;shows the gui/menu/list While 1 $GUIlistitem = GUICtrlRead($listView); reads the ID of the selected item in the list ;SplashTextOn ( "title", $GUIlistitem) if Not (ProcessExists("P1.exe") Or ProcessExists("P2.exe") Or ProcessExists("P3.exe")) Then If $GUIlistitem==4 And _IsPressed(31) Then ;31 -> Key 1 RunWait("C:/Programs/P1.exe") nocycle() EndIf If $GUIlistitem==5 And _IsPressed(31) Then ;31 -> Key 1 RunWait("C:/Programs/P2.exe") nocycle() EndIf If $GUIlistitem==6 And _IsPressed(31) Then ;31 -> Key 1 RunWait("C:/Programs/P3.exe") nocycle() EndIf If $GUIlistitem==7 And _IsPressed(31) Then ;31 -> Key 1 Exit nocycle() EndIf If $GUIlistitem==8 And _IsPressed(31) Then ;31 -> Key 1 Shutdown(1) nocycle() EndIf Sleep(200) EndIf WEnd Func nocycle() While _IsPressed(31, $hDLL) Sleep(500) WEnd EndFunc DllClose($hDLL) I am not a coder so there should be something of macroscopic i cannot see... If you have some idea on how to improve this "badly-drawn-boy" please tell me Thanks for the help!
-
Thank you all! Following the example of AZJIO i had an "error parsing function call" for a script like: Global $file_ini = @ScriptDir & "inifile.ini" Local $iniexist = FileExists($file_ini) If Not $iniexist Then MsgBox(0, "Notice", "No .ini found. Default options loaded and .ini file is going to be created.", 5) IniWrite($file_ini, "", "", "") ;create an empty file _inidef($file_ini) EndIf Func _inidef($file_ini) $hFile = FileOpen($file_ini, 2) FileWrite($hFile, _ "[section_1]" & @CRLF & _ "var1 = 1" & @CRLF & _ @CRLF) FileClose($hFile) EndFunc what is wrong with it? Thanks!
-
Hi all, I figured out how to, in the case of a missing .ini configuration file, create a new file (section by section, with the use of "IniWriteSection" associated to arrays with the options to be get), but i cannot see how to write efficiently in the ini file comments. i.e., if i have a couple of sections i can write: If $iniexist==0 Then MsgBox(0, "Notice", "No .ini found. Default options loaded and .ini file is going to be created.", 5) Local $sect1 [4][2] = [["var1_1", 1], ["var1_2", 2], ["var1_3", 3], ["var1_4", 4]] Local $sect2 [3][2] = [["var2_1", 5], ["var2_2", 6], ["var2_3", 7]] IniWriteSection($file_ini, "section_1", $sect1, 0) IniWriteSection($file_ini, "section_2", $sect2, 0) EndIf and i will end up with [section_1] var1_1=1 var1_2=2 var1_3=3 var1_4=4 [section_2] var2_1=5 var2_2=6 var2_3=7 but if i have a bunch of text in the middle i want to be reported, like: [section_1] var1_1=1 var1_2=2 var1_3=3 var1_4=4 ;Inferno: Canto I ;Midway upon the journey of our life ; I found myself within a forest dark, ;For the straightforward pathway had been lost. ;Ah me! how hard a thing it is to say ; What was this forest savage, rough, and stern, ; Which in the very thought renews the fear. ;So bitter is it, death is little more; ; But of the good to treat, which there I found, ; Speak will I of the other things I saw there. ;I cannot well repeat how there I entered, ; So full was I of slumber at the moment ; In which I had abandoned the true way. ;But after I had reached a mountain's foot, ; At that point where the valley terminated, ; Which had with consternation pierced my heart, ;Upward I looked, and I beheld its shoulders, ; Vested already with that planet's rays ; Which leadeth others right by every road. ;Then was the fear a little quieted ; That in my heart's lake had endured throughout ; The night, which I had passed so piteously. ;And even as he, who, with distressful breath, ; Forth issued from the sea upon the shore, ; Turns to the water perilous and gazes; ;So did my soul, that still was fleeing onward, ; Turn itself back to re-behold the pass ; Which never yet a living person left. [section_2] var2_1=5 var2_2=6 var2_3=7 ;After my weary body I had rested, ; The way resumed I on the desert slope, ; So that the firm foot ever was the lower. ;And lo! almost where the ascent began, ; A panther light and swift exceedingly, ; Which with a spotted skin was covered o'er! ;And never moved she from before my face, ; Nay, rather did impede so much my way, ; That many times I to return had turned. ;The time was the beginning of the morning, ; And up the sun was mounting with those stars ; That with him were, what time the Love Divine ;At first in motion set those beauteous things; ; So were to me occasion of good hope, ; The variegated skin of that wild beast, ;The hour of time, and the delicious season; ; But not so much, that did not give me fear ; A lion's aspect which appeared to me. How can i create efficiently a full .ini file with all the sections, variables and text? Thanks
-
How to minimize CPU usage
Baritonomarchetto replied to Baritonomarchetto's topic in AutoIt General Help and Support
Thanks -
How to minimize CPU usage
Baritonomarchetto replied to Baritonomarchetto's topic in AutoIt General Help and Support
I want that, while a defined program is active, my button-press related function is triggered... the target program can go unactive then active, and so on, so i suppose there are no better solutions other than set "WinActive" into the "while" loop, which probably is the heaviest part, isn't it?