Jump to content

KF5WGB

Active Members
  • Posts

    50
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

KF5WGB's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Works like a charm. Thanks KaFu.
  2. Hi everybody, I looked through the forum and some guys, way way back, had the same problem but iI can not find a solution. I used this Function for years without a problem and now it throws an error. The attached pic is from running the compiled .exe file. Running the Func SolarData() itself gives the $oXML^ ERROR . SolarData() Func SolarData() ;If _IsInternetConnected() = True Then Global $oXML = ObjCreate("Microsoft.XMLHTTP") $oXML.Open("GET", "http://www.hamqsl.com/solarxml.php", 0) $oXML.Send ; Find Sunspots $SSCount1 = StringInStr($oXML.responsetext, "<sunspots") $SSCount2 = StringInStr($oXML.responsetext, "</sunspots") $SSlen = $SSCount2 - ($SSCount1 + 10) Global $SS = StringMid($oXML.responsetext, ($SSCount1 + 10), $SSlen) ; Find SolarFlux $SFCount1 = StringInStr($oXML.responsetext, "<solarflux") $SFCount2 = StringInStr($oXML.responsetext, "</solarflux") $FSlen = $SFCount2 - ($SFCount1 + 11) Global $SFI = StringMid($oXML.responsetext, ($SFCount1 + 11), $FSlen) ;Find A index $AiCount1 = StringInStr($oXML.responsetext, "<aindex") $AICount2 = StringInStr($oXML.responsetext, "</aindex") $AIlen = $AICount2 - ($AiCount1 + 8) Global $AI = StringMid($oXML.responsetext, ($AiCount1 + 8), $AIlen) ;Find K index $KICount1 = StringInStr($oXML.responsetext, "<kindex") $KICount2 = StringInStr($oXML.responsetext, "</kindex") $KIlen = $KICount2 - ($KICount1 + 8) Global $KI = StringMid($oXML.responsetext, ($KICount1 + 8), $KIlen) ;~ TrayItemSetText($SolarFlux, "Solar Data: SSN:" & $SS & " SFI:" & $SFI & " A:" & $AI & " K:" & $KI) ;EndIf EndFunc ;==>SolarData C:\Users\KF5WGB\Desktop\nextcloud copy\A2Q+_Dev\solardata.au3" (19) : ==> The requested action with this object has failed.: $oXML.Send $oXML^ ERROR Is this obsolete or did M$ change something on how to create XML objects? Global $oXML = ObjCreate("Microsoft.XMLHTTP") $oXML.Open("GET", "http://www.hamqsl.com/solarxml.php", 0) $oXML.Send Thanks for any advice. 73 de KF5WGB
  3. That worked. I have to remember that one. Maybe it is time to write an UDF (winresize($handle, Vpos, Hpos, @shrinkmode) ) or something like that. Thanks for your input KF5WGB
  4. Hi, When resizing/shrinking an existing GUI, WinMove does it from the bottom up, loosing whats on top. How do I reverse that. In other words, I want the top part of the GUI stay as it is and the bottom part "shrunk". Run my little script and hit F5 (Hide/Show SolarData) and you see what I mean. The bottom with the picture now overlays the top (shrunk up). If you run the script without Internet connection you do not see the pic and you can not resize the GUI. That is what I want it to show when F5 is pressed AND internet connection is available. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <INet.au3> Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon HotKeySet("{F5}", "_HideSolarDasta") Global $Solarwindow = 1, $MainWindow, $nMsg #Region ### START Koda GUI section ### Form=IC-7300 $MainWindow = GUICreate("IC-7300 Time Sync & Memory Keyer", 425, 269, -1, -1, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE)) ;$MainWindow = GUICreate("IC-7300 Time Sync & Memory Keyer", 425, 269, -1, -1, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE)) GUISetBkColor(0xA0A0A4) ;GUISetBkColor(0xFFFFFF) $coded = GUICtrlCreateLabel("Coded by", 242, 88, 96, 28) GUICtrlSetFont(-1, 12, 00, 0, "Comic Sans MS") $KF5WGB = GUICtrlCreateLabel("KF5WGB", 242, 108, 96, 28) GUICtrlSetFont(-1, 12, 200, 0, "Comic Sans MS") GUICtrlSetCursor (-1, 0) GUICtrlSetTip(-1, "Goto KF5WGB's QRZ page") $Transmit1 = GUICtrlCreateButton("TX1", 20, 14, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont($Transmit1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit1, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 1") $Transmit2 = GUICtrlCreateButton("TX2", 99, 14, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit2, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 2") $Transmit3 = GUICtrlCreateButton("TX3", 178, 14, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit3, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 3") $Transmit4 = GUICtrlCreateButton("TX4", 257, 14, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit4, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 4") $Transmit5 = GUICtrlCreateButton("TX5", 21, 56, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit5, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 5") $Transmit6 = GUICtrlCreateButton("TX6", 100, 56, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit6, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 6") $Transmit7 = GUICtrlCreateButton("TX7", 179, 56, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor (-1, 0) ;GUICtrlSetState($Transmit7, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 7") $Transmit8 = GUICtrlCreateButton("TX8", 258, 56, 49, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetCursor ($Transmit8, 0) ;GUICtrlSetState($Transmit8, $Gui_Disable) GUICtrlSetTip(-1, "Transmit recording from slot 8") ;GUICtrlSetCursor (-1, 2) $syncclock = GUICtrlCreateButton("Sync Clock", 326, 14, 73, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetBkColor(-1, 0xB4B4B4) GUICtrlSetTip(-1, "Sync Radio clock with PC clock") GUICtrlSetCursor (-1, 0) $listports = GUICtrlCreateButton("Set COM", 326, 56, 73, 25, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_TOP,$BS_FLAT)) GUICtrlSetBkColor(-1, 0xB4B4B4) GUICtrlSetTip(-1, "Set COM port") GUICtrlSetCursor (-1, 0) ;using GetIP to see if we are connected. If yes, get the picture $dData = _GetIP() If $dData > 0 Then ; internet connection is working ; Display HAMQSL Solardata in IEObject Global $oIE = _IECreateEmbedded() Global $bUpdateTip, $bTurnOff $hIE = GUICtrlCreateObj($oIE,6, 137, 410, 125) _IENavigate($oIE, 'about:blank', 1) _IEDocWriteHTML($oIE, _GetHTML2()) _IEAction($oIE, "refresh") _IELoadWait($oIE) $oDocument = $oIE.document $oDocument.body.scroll = "no" ; --- $oMyIMG = $oDocument.getElementById('IMG1') ; <-- this reference doesn't work in ObjEvent() $oMyIMG = _WebBrowser_JS_ElementGetRef($oIE, $oMyIMG) ; <-- the reference returned by this function will work in ObjEvent() ; You can find this and some other utility functions related to ; the BrowserControl here: https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/ ; set ObjEvent to catch events from the IMG element ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa742802%28v%3dvs.85%29 Global $oEventObject2 = ObjEvent($oMyIMG, "IMGevent_", "HTMLImgEvents2") ; <-- catch directly events fired by the image ; see here for more references: ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/hh801968(v=vs.85) Else $WGP = WinGetPos($MainWindow) WinMove($MainWindow, "", Default, Default, Default, $WGP[3] - 130) EndIf If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error, 8)) $clock = GuiCtrlCreateLabel("00:00:00", 320, 100, 280, 22) GUICtrlSetFont($clock, 14, 100, 1, "Orbitron") $freqreadout = GuiCtrlCreateLabel("00.000.000", 10, 90, 225, 32) GUICtrlSetFont($freqreadout, 14, 100, 1, "Orbitron") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ; do nothing EndSwitch WEnd Func _HideSolarDasta() If $dData > 0 Then If $Solarwindow = 1 Then $Solarwindow = 0 $WGP = WinGetPos($MainWindow) WinMove($MainWindow, "", Default, Default, Default, $WGP[3] - 130) Else $Solarwindow = 1 $WGP = WinGetPos($MainWindow) WinMove($MainWindow, "", Default, Default, Default, $WGP[3] + 130) EndIf EndIf EndFunc Func _GetHTML2() Local $sHTML = _ "<!DOCTYPE HTML>" & @CRLF & _ "<html>" & @CRLF & _ "<head>" & @CRLF & _ '<style type="text/css">' & @CRLF & _ 'html {overflow:hidden;}' & @CRLF & _ '</style>' & @CRLF & _ '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' & @CRLF & _ "<title>solar101pic.php (410×125)</title>" & @CRLF & _ '</head>' & @CRLF & _ '<body>' & @CRLF & _ '' & @CRLF & _ '<body style="margin: 12px; background: #0e0e0e;">' & @CRLF & _ '' & @CRLF & _ ; '<img id="IMG1" style="-webkit-user-select: none;margin: auto;" src="http://www.hamqsl.com/solar101pic.php">' & @CRLF & _ '<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php", style="position: absolute; left:0; top:0; width: 410px; height: 125px">' & @CRLF & _ "</body>" & @CRLF & _ "</html>" Return $sHTML ;'<meta HTTP-Equiv="refresh" CONTENT="10; URL=http://www.hamqsl.com/solar101pic.php">' & @CRLF & _ EndFunc ;==>_GetHTML2 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WebBrowser_JS_ElementGetRef ; Description ...: retrieves a reference of an object by it's ID suitable to be used from AutoIt ; Syntax ........: _WebBrowser_JS_ElementGetRef(Byref $oIE_Server, $oElement) ; Parameters ....: $oIE_Server - a Webbrowser object reference. ; $oElement - a reference to an object element of the web page. ; Return values .: an Object reference to the passed element (retrieved by means of ID) ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Notes .......: the reference to the object retrieved by this function can be successfully passed to the AutoIt function ObjEvent(). ; If you simply use a reference to a javascript object retrieved by any other means, but not by it's ID, it may not work ; in the AutoIt function ObjEvent() (strange but true), so the need to write this function that will force a reference by ID ; to the passed object. There is no need to pass the ID of that object since it's retrieved automatically by the function. ; If the passed object does not have an ID, we create one on the fly for the sole purpose of referring to it and release it ; immediately afterwards in order to leave things as they were. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/ ; Example .......: ; =============================================================================================================================== Func _WebBrowser_JS_ElementGetRef(ByRef $oIE_Server, $oElement) Local $oWindow = $oIE_Server.document.parentwindow ; .JSglobal Local $oElementByIdReference If $oElement.Id = '' Then $oElement.setAttribute('Id', 'DummyId') ; we need an ID (a temporary ID) $oElementByIdReference = Execute('$oWindow.' & $oElement.getAttribute('Id')) ; get element's reference by Id $oElement.setAttribute('Id', '') ; remove the temporary ID (we leave things as we found them) Else $oElementByIdReference = Execute('$oWindow.' & $oElement.getAttribute('Id')) EndIf Return $oElementByIdReference EndFunc ;==>_WebBrowser_JS_ElementGetRef Is it possible to keep the GUI or do I have to create a new one every time I hit the F5 Key? Thanks for any help KF5WGB
  5. That did the trick. Vielen Dank und schönes Wochenende. KF5WGB
  6. Duuuhh. Thanks Musashi. Completely forgot about that one. Now I have this problem. If the picture was downloaded once before , the next one will be from the Cache and not from the website. #include <MsgBoxConstants.au3> if FileExists(@ScriptDir & "\solardata.gif") Then ConsoleWrite("erasing old pic" & @CRLF) FileDelete(@ScriptDir & "\solardata.gif") EndIf InetGet("http://www.hamqsl.com/solar101pic.php","solardata.gif") Any idea how to clear the cache?
  7. Hi @all, The web-address where the image is created is: http://www.hamqsl.com/solar101pic.php One solution was to create an object with IECreateEmbedded() and it works fine...until I added the meta tag refresh. Then the image gets "messed' up. The vertical and horizontal scrollbars show up. It all started here: Now I am thinking, what if I just download the created pic and run a timer for 30 minutes and then re-download the image and refresh the pic in the GUI. I tried the winhttp approach $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://www.hamqsl.com/solar.html", False) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode == 200 then $file = FileOpen("solardata.gif", 2) ; The value of 2 overwrites the file if it already exists FileWrite($file, $oReceived) FileClose($file) EndIf but that does not work with a server side created picture. Is there a way to downlaod that image? Thanks for any advice. KF5WGB
  8. Hi Chimp, Thanks for your input/code and links to MS. Lots of info and reading for me to do. I got one more question. Hey Nine, in case you continue to read this thread. I added this into the $sHTML '<meta http-equiv="refresh" content="600; url=http://www.hamqsl.com/solar101pic.php">' & @CRLF & _ before the <Title> tag. When the time is up, the page reloads but the formatting is gone. Horizontal/ scrollbars and Frame is back. Why is that? Shouldn't '<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php", style="position: absolute; left:0; top:0; width: 410px; height: 125px">' & @CRLF & _ take care of that? Anyway thanks to both of you and happy coding. KF5WGB P.S.: I bet you know that changing content to 10 refreshes faster for testing 😉 The final refresh is more like content="3600",
  9. Hi Nine, Fantastic. This is even better. Thank you so much. Like I said before.. so much to learn about COM, Objects etc. Got a tip where to start? I looked up Volatile in the AutoIt help and see it is experimental. Not really sure what it does and why it is needed to be a part of the function. I know the function does not work without it. I removed it just for the heck of it to see what happens. Again, thank you very much. Have a great rest of the weekend. KF5WGB
  10. Hi Nine, Many thanks for your code. Works just great. I added _IEAction($oIE, "refresh") after _IENavigate($oIE, 'about:blank', 1) _IENavigate($oIE, $HTML, 1) For some reason I got an old IMG displayed when running the script. The refresh got the 'newer' one from the server. I sure have to learn a lot more about the ObjEvent, what events are there, what names, how to set them up and what comes back etc. Guess I find those at Micro$ofts website. To get rid of the frame around the image, maybe download the image and use GUICtrlCreatePic to create a clickable IMG. What do you think. Possible? Thanks again and have a great day KF5WGB
  11. Hi seadoggie01, That is correct. The $HTML points to the picture which is displayed in the Obj. The 'real' link is in the Switch loop    ShellExecute("http://www.hamqsl.com/solar.html") This command is called when you click on the N0NBH button. Now I want to remove the button and make the picture 'activ'. In other words, when you click the picture, the Shellexecute function should be called. I have not figured out (yet) how to make an Obj behave like a button for the Switch .. Case.. function New problem: The Obj creates a 'frame' around the picture and I can not get it without that frame. No matter how small I make the GUICtrlCreateObj($oIE, 10, 10, 435, 158) Even if I make the Obj the same size as the picture or smaller, I still get some 'frame' around it. Can that be removed? Thanks
  12. Hi everybody, The following code is just a part of a bigger GUI but works on itself. For now I use the button 'N0NBH' to launch the coders website. If the designers html-code for the banner is put on a 'normal' website, a click on the picture launches the site. In my GUI the picture is just that..a picture. I want to remove the button and make the picture the 'clickable' link. Is this possible with an Object and how would I get the GUICtrlSetTip working? #include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> $HTML = "http://www.hamqsl.com/solar101pic.php" $SD = GUICreate("Solar data",600, 180) $hamqsl = GUICtrlCreateButton("N0NBH", 465, 30, 100) GUICtrlSetTip($hamqsl, "Click to add Solar-Terrestrial Data to your website!") GUICtrlSetFont(-1, 14, 800, 0, "Arial") GUICtrlSetCursor (-1, 0) $futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's", 460, 70, 150) GUICtrlSetFont(-1, 14, 200, 0, "Arial") $futurebutton2 = GUICtrlCreateLabel("site for more", 460, 90, 100) GUICtrlSetFont(-1, 14, 200, 0, "Arial") $futurebutton3 = GUICtrlCreateLabel("Banners..", 460, 110, 100) GUICtrlSetFont(-1, 14, 200, 0, "Arial") $oIE = ObjCreate("Shell.Explorer.2") GUICtrlCreateObj($oIE, 10, 10, 435, 158) ;GUICtrlSetTip($banner, "Click to add Solar-Terrestrial Data to your website!") ;not working with Obj $oIE.navigate($HTML) $oIE.document.body.scroll = "no" GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg case $GUI_Event_Close ExitLoop Case $hamqsl ShellExecute("http://www.hamqsl.com/solar.html") EndSwitch WEnd GUIDelete($SD) As always thanks for taking a peek at it and advice. Have a great day. KF5WGB
  13. trancexx, Hvala vam, Hvala vam, Hvala vam... Hope I got that right. That was quick and absolutely spot on. Again Hvala vam. I have a lot to learn about those Object things and Arrays. I thought creating objects only works with apps and dll's from Micro$oft. OLEview came in handy to get the functions/procedures from OmniRig. $Rig.SendCustomCommand(Binary("0xFEFE94E0280001FD"),0,"") works now. Thank you so much...Vielen Dank. Have a great weekend. 73 de KF5WGB
  14. Hi Coders, I am a new to Objects. I do not know how to explain it in a short way, so please stick with me.... here it goes... Looooong time ago this was posted: ..and the thread died quickly. I recently installed the program OmniRig.exe (it is for Radio control) , the program in question to read and send data to. I changed some of the script that big_daddy got out of the VB code and it works fine reading data from The OmniRig object. The problem is/was the thread was never finished on how to send data to the object. Well I tried a few different ways without success. I get an "The requested action with this object has failed error", so I contacted the Dev and asked if there is a manual or documentation available. He replied: " There is no documentation, other than the type library included in the exe file. The first step in using OmniRig in custom software is to include its type library in the project, then the programmer can browse and use all methods, properties and events of OmniRig. You can specify either the number of bytes in the reply or the terminating character. Pass 0 and a blank string if no reply is expected. I am not familiar with AutoIt, sorry. The first parameter passed to SendCustomCommand must be a byte array, not a string. I don't know how byte arrays are created in your language. " With OLEView.exe I opened the OmniRige.exe and found: procedure SendCustomCommand(Command: OleVariant; ReplyLength: Integer; ReplyEnd: OleVariant); I created the handle for the OmniRig object: $OmniRigEngine = ObjCreate("OmniRig.OmniRigX") ..and then when a certain button is pressed this function gets called: Func _TXVoiceMemo1() If Not IsObj($OmniRigEngine) Then ;checking if OmniRig is running/loaded SetError(1) Return 0 EndIf $OmniRigEngine.SendCustomCommand("0xFEFE94E0280001FD",0,"") ;<-error: The requested action with this object has failed. ->well, because I send a string. EndFunc Now how do I make a byte Array out of "FEFE94E0280001FD"? It is not $sCommad[1] = "FEFE94E0280001FD",and then $OmniRigEngine.SendCustomCommand($sCommand[1],0,"") , right? I tried and get the failed object error. if you want to play with the code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Betatest\omnirig_interface.Exe #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Project: Omni-RigX Monitor with AutoIt v3 ;Original scritpt: https://www.autoitscript.com/forum/topic/30923-com-obj/?tab=comments#comment-221570 ;Original date: August 14,2006 ;Modified by: KF5WGB ;Date: September 14,2019 ;Credits: big_daddy, Moderator @ www.autoit.com #include <Array.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; declare mode variables Global $PM_CW_U = 8388608 Global $PM_CW_L = 16777216 Global $PM_SSB_U = 33554432 Global $PM_SSB_L = 67108864 Global $PM_DIG_U = 13421772 Global $PM_DIG_L = 268435456 Global $PM_AM = 536870912 Global $PM_FM = 1073741824 Global $PM_RTTY_R = 1342117728 ;other ;more variables Global $oEvent, $Rig, $RigNumber, $OurRigNo, $NewRigNo, $OmniRigEngine, $Frequency_Rig, $Frequency_display, $front, $middle, $right $Form1 = GUICreate("Omni-RigX Monitor", 320, 160, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Button1 = GUICtrlCreateButton("Configure", 24, 105, 75, 25, 0) GUICtrlSetOnEvent(-1, "_Configure") ;$Button2 = GUICtrlCreateButton("Start", 24, 240, 75, 25, 0) ;if you want a start button ;GUICtrlSetOnEvent(-1, "_StartOmniRig") ;position the label and remove the ;'s $Radio1 = GUICtrlCreateRadio("#1", 24, 30, 40, 17) GUICtrlSetState($Radio1, $gui_checked) ;use Rig #1 by default GUICtrlSetOnEvent(-1, "_SelectRig") $TX1 = GUICtrlCreateButton("TX1",90,30,40,20,0) ;create a TX button for future voice keyer (TX 1 - 8 ) GUICtrlSetOnEvent(-1, "_TXVoiceMemo1") ;function to call, sending command to trigger voicekeyer $Radio2 = GUICtrlCreateRadio("#2", 24, 60, 40, 17) GUICtrlSetOnEvent(-1, "_SelectRig") $Label1 = GUICtrlCreateLabel("RX: ", 160, 30, 150, 17) $Label2 = GUICtrlCreateLabel("TX: ", 160, 60, 150, 17) $Label3 = GUICtrlCreateLabel("0.00", 200, 30, 150, 17) $Label4 = GUICtrlCreateLabel("0.00", 200, 60, 150, 17) $Label5 = GUICtrlCreateLabel("Mode", 160, 100, 150, 17) $Label6 = GUICtrlCreateLabel("", 200, 100, 150, 17) $Label7 = GUICtrlCreateLabel("Status", 160, 120, 150, 17) $Label8 = GUICtrlCreateLabel("", 200, 120, 150, 17) $Group1 = GUICtrlCreateGroup("Rig", 10, 10, 300, 140) GUISetState(@SW_SHOW) _StartOmniRig() ;fire up Omnirig if @error Then MsgBox(48, "Error", "Unable to create OmniRig Object." & @CRLF & "OmniRig is not installed.") Exit EndIf While 1 Sleep(100) ;Run program until X is pressed WEnd Func _StartOmniRig() $OmniRigEngine = ObjCreate("OmniRig.OmniRigX") If Not IsObj($OmniRigEngine) Then SetError(1) Return 0 EndIf ;we want OmniRig interface V.1.1 to 1.99 ;as V2.0 will likely be incompatible with 1.x ;consolewrite($OmniRigEngine.InterfaceVersion & @CRLF) If $OmniRigEngine.InterfaceVersion < 101 Then MsgBox(48, "Error", "OmniRig is not installed or has a wrong version number") Exit ElseIf $OmniRigEngine.InterfaceVersion > 299 Then MsgBox(48, "Error", "OmniRig is not installed or has a wrong version number") Exit EndIf $oEvent = ObjEvent($OmniRigEngine, "Evt_") _SelectRig() EndFunc ;==>_StartOmniRig Func _SelectRig($NewRigNo = 1) If Not IsObj($OmniRigEngine) Then SetError(1) Return 0 EndIf If GUICtrlRead($Radio1) = $GUI_CHECKED Then $NewRigNo = 1 ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then $NewRigNo = 2 EndIf $OurRigNo = $NewRigNo Switch $NewRigNo Case 1 $Rig = $OmniRigEngine.Rig1 Case 2 $Rig = $OmniRigEngine.Rig2 EndSwitch _ShowRigStatus() _ShowRigParams() EndFunc ;==>_SelectRig Func _ShowRigStatus() If Not IsObj($Rig) Then SetError(1) Return 0 EndIf ; ;Check if Rig is a IC7300 and toggle TX button ; if $Rig.Rigtype = "IC-7300" Then GUICtrlSetState($TX1, $GUI_Enable) Else GUICtrlSetState($TX1, $GUI_Disable) EndIf GUICtrlSetData($Label8, $Rig.StatusStr) GUICtrlSetData($Group1, $Rig.Rigtype) ; Write Object/Rig Info to console everytime the Rig is switched / just for dev and monitor reasons~~ Consolewrite("Software Version.......................: " & $OmniRigEngine.Softwareversion & @crlf) Consolewrite("Interface Version......................: " & $OmniRigEngine.InterfaceVersion & @CRLF) Consolewrite("Object filename in REG.................: " & ObjName($OmniRigEngine,4) & @crlf) Consolewrite("Object Name............................: " & ObjName($OmniRigEngine,1) & @crlf) Consolewrite("Object Description.....................: " & ObjName($OmniRigEngine,2) & @crlf) Consolewrite("Object Program ID......................: " & ObjName($OmniRigEngine,3) & @crlf) Consolewrite("Module/Program in which the Object runs: " & ObjName($OmniRigEngine,5) & @crlf) Consolewrite("Object CLSID codeclass.................: " & ObjName($OmniRigEngine,6) & @crlf) Consolewrite("Object IID Interface...................: " & ObjName($OmniRigEngine,7) & @crlf) consolewrite("Rig type...............................: " & $rig.RigType & @CRLF) consolewrite("Rig status.............................: " & $rig.StatusStr & @CRLF) consolewrite("Rig Mode...............................: " & $rig.Mode & @CRLF) consolewrite("VFO A..................................: " & $rig.FreqA & @CRLF) consolewrite("VFO B..................................: " & $rig.FreqB & @CRLF & @CRLF) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EndFunc ;==>_ShowRigStatus Func _ShowRigParams() If Not IsObj($Rig) Then SetError(1) Return 0 EndIf $Frequency_Rig = $Rig.GetRxFrequency ; Put the dots in the Freq readout $right = "." & StringRight($Frequency_Rig,3) $Frequency_Rig = StringTrimRight($Frequency_Rig,3) $middle = "." & StringRight($Frequency_Rig,3) $Frequency_Rig = StringTrimRight($Frequency_Rig,3) $front = StringRight($Frequency_Rig,3) $Frequency_display = $front & $middle & $right ; not needed, just for optics GUICtrlSetData($Label3, $Frequency_display) $Frequency_Rig = $Rig.GetTxFrequency ; Put the dots in the Freq readout $right = "." & StringRight($Frequency_Rig,3) $Frequency_Rig = StringTrimRight($Frequency_Rig,3) $middle = "." & StringRight($Frequency_Rig,3) $Frequency_Rig = StringTrimRight($Frequency_Rig,3) $front = StringRight($Frequency_Rig,3) $Frequency_display = $front & $middle & $right ; not needed, just for optics GUICtrlSetData($Label4, $Frequency_display) Switch $Rig.Mode Case $PM_CW_L, $PM_CW_U GUICtrlSetData($Label6, "CW") Case $PM_SSB_L GUICtrlSetData($Label6, "LSB") Case $PM_SSB_U GUICtrlSetData($Label6, "USB") Case $PM_FM GUICtrlSetData($Label6, "FM") Case $PM_AM GUICtrlSetData($Label6, "AM") Case $PM_DIG_U GUICtrlSetData($Label6, "USB DIGITAL") Case $PM_DIG_L GUICtrlSetData($Label6, "LSB DIGITAL") Case Else GUICtrlSetData($Label6, "Other") EndSwitch EndFunc ;==>_ShowRigParams Func _Configure() If Not IsObj($OmniRigEngine) Then SetError(1) Return 0 EndIf $OmniRigEngine.DialogVisible = True EndFunc ;==>_Configure Func Evt_StatusChange($RigNumber) If $RigNumber = $OurRigNo Then _ShowRigStatus() EndFunc ;==>Evt_StatusChange Func Evt_ParamsChange($RigNumber, $Params) If $RigNumber = $OurRigNo Then _ShowRigParams() EndFunc ;==>Evt_ParamsChange func _TXVoiceMemo1() If Not IsObj($Rig) Then SetError(1) Return 0 EndIf #cs NO documentation available from developer. Refers to Library in EXE file. From source code : procedure SendCustomCommand(Command: OleVariant; ReplyLength: Integer; ReplyEnd: OleVariant); Dev said: parameter passed to SendCustomCommand must be a byte array #ce local $sendarray[1] = ["0xFEFE94E0280001FD"] ;$Rig.SendCustomCommand($sendarray[0],0,"") ; does nothing $OmniRigEngine.SendCustomCommand($sendarray[0],0,"") ; (219) : ==> The requested action with this object has failed. ; $OmniRigEngine.SendCustomCommand($sendarray[0],0,"") ; $OmniRigEngine^ ERROR ConsoleWrite("Sending command to: " & $Rig.Rigtype & @crlf & "Command: " & $sendarray[0] & @CRLF) EndFunc Func _Exit() Exit EndFunc ;==>_Exit The program OmniRig is here: OmniRig If you install and run OmniRig for testing this script make sure one Rig is selected as an IC-7300. So what it all comes down to is: How do I create a Byte Array out of FEFE94E0280001FD and pass it on to the $OnmniRigEngine. As always, thanks for any help and advice 73, KF5WGB
  15. OMG, You are right. I forgot all about it. Thanks for pointing this out. I stared at this for 2 days and did not see it. I changed _SendToRadio($bBinData) to $fromradio = _SendToRadio($bBinData) and removed CommGetLine. Then I found that the received data string is longer than the struct created with just the request of $bBinData & "0xFEFE94E004FD". All that was left to do was to increase the size a few bytes. It helps to read the programmers part of the radios amnual 🙂 $bBinData = $bBinData & "0xFEFE94E003FD0000000000000000000000" ;command to request Frequency readout PLUS receive bytes Once that was done I got the complete data back from the Radio: 0xFEFE94E003FDFEFEE094030000375200FD - structs....gotta love 'em A little String magic and the readout looks like this: 52.370.000 MHz Thanks jchd
×
×
  • Create New...