Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/2018 in all areas

  1. The thing is, if a moderator has asked something, and the op didn't give any answer, other people shouldn't post anything else unless the mod says it's ok. In this case, the mod asked what is this for, so until he gets an answer and gives the ok, no one should reply anymore. Been there, done that.
    2 points
  2. Hi Folks, I recently spent quite some time figuring out how to get AutoIT working with the HLLAPI api on a 5250 emulator. Hopefully, this code snippet will help someone else in the future. If you have no idea what HLLAPI or a 5250 emulator is, you probably don't need this #include <Array.au3> $returncode="" $function=1 $dataString="" $dataLength=0 ; NB: Your 5250 session must be started before this will work $dll = DllOpen("ehlapi32.dll") ; change this to whatever dll your client provides $result = connectSession("A") ; Connect to session "A". Usually displayed on the terminal session window title if $result<>0 Then mb("Connection to open 5250 Session Failed (have you opened a session?)") Exit EndIf $result = getScreen() ; get the entire screen $nice=format80($result) $result = getStatusLine() ; get the status line $nice=$nice & format80($result) setNowait() ; don't wait during status checks, for the system to become available $result=getStatus() ; get the status ; setTimewait() $nice=$nice & @CRLF & "Status: >" & $result & "<" MsgBox(1,"ret:" & $dll,$nice) ; sendReset() setInputFieldText("User", "kangkeng") setInputFieldText("Password","password") setInputFieldText("Menu","Salmon:)<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' />") ; sendCR() $result=waitDone(1000) ; wait for system to come back in one second $loc = findField("user") $loc = getNextUField($loc) $text = getField($loc) ; get the text from a field given the location. mb(">" & $text & "<") if $result>0 then sendReset() ; mb("Wait:" & $result) DllClose($dll) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Begin lots of functions to wrap around the HLLAPI ; Func hllCall() return DllCall($dll, "none", "hllapi", "word*", $function, "str", $dataString, "word*", $dataLength, "word*", $returncode) EndFunc ; wait for system to come back in a couple of milliseconds. 0-OK otherwise status error number returned Func waitDone($milliseconds) $done=99; $begin = TimerInit() while ($done=99) $res = getStatus() if ($res=0) Then $done=0 sleep(100) $dif = TimerDiff($begin) if ($dif > $milliseconds) Then $done=$res WEnd return $done EndFunc ; convience function to find a label and set the entry field after it with a value. PADs blanks to max size of field Func setInputFieldText($partialString,$text) $loc = findField($partialString) $loc = getNextUField($loc) $size = getFieldLength($loc) ;mb($size) setField($loc,StringLeft($text & " ",$size)) EndFunc ; get the length of a field Func getFieldLength($loc) $function=32 $dataString="T " $dataLength=2 $returncode=$loc $res = hllCall() return $res[3] EndFunc ; get the location of the next entry field given a position Func getNextUField($loc) $function=31 $dataString="NU" $dataLength=2 $returncode=$loc $res = hllCall() return $res[3] EndFunc ; Get location of a particular substring in the entire screen Func findField($partialText) ; dump out whole screen first $res = getScreen() ; find the text in the result return StringInStr($res,$partialText) EndFunc ; set a certain field to a value Func setField($pos,$text) $function=33 $dataString=$text $dataLength=StringLen($text) $returncode=$pos return hllCall() EndFunc ; get the text of a field Func getField($pos) $function=34 $dataString="" $dataLength=300 $returncode=$pos $res = hllCall() return $res[2] EndFunc ; get the status of the screen Func getStatus() $function=4 $res = hllCall() return $res[4] EndFunc ; get the wait to no wait. i.e. calls to wait will immediately return if busy. Func setNowait() $function=9 $dataString="NWAIT" $dataLength=StringLen($dataString) return hllCall() EndFunc Func setTimewait() $function=9 $dataString="TWAIT" $dataLength=StringLen($dataString) return hllCall() EndFunc ; connect to a session Func connectSession($session) $function=1 $dataString=$session $res = hllCall() return $res[4] EndFunc ; get the entire screen in a string Func getScreen() $function=5 $res = hllCall() return $res[2] EndFunc ; get the status line Func getStatusLine() $function=13 $dataLength=110 $res = hllCall() return $res[2] EndFunc ; send a reset Func sendReset() return sendText("@R") EndFunc ; send a enter Func sendCR() return sendText("@E") EndFunc ; send text to screen Func sendText($text) $function=3 $dataString=$text $dataLength=StringLen($text) return hllCall() EndFunc ; ; Some generic Utility functions ; Func format80($string) $end="N" $count=0 $answer="" while ($end="N") $answer = $answer & StringMid($string,($count * 80) + 1,80) & @CRLF $count = $count + 1 if $count=25 Then $end="Y" WEnd return $answer EndFunc Func mb($string) ; quick and dirty message box msgbox(1,"a message",$string) EndFunc
    1 point
  3. ripdad

    WSA_NBTCP v1.00 UDF

    WSA_NBTCP.au3 (Windows Sockets API - Non-Blocking Transmission Control Protocol) Version: 1.00 Type: UDF This is an accumulation of WSA code from many sources and modified to suit myself. These functions have been thoroughly tested using a Local Proxy Server, which is about the most strenuous test you can use. Includes my rendition of how a TCPRecv Timeout should work. Also includes a timewait/timeout using Select for TCP Send, which works great for that function. You will need a loop to use _WSA_TCPRecv(). An example will be forthcoming in a second post. Functions: #CURRENT_USER_FUNCTIONS _WSA_Cleanup _WSA_FormatMessage _WSA_GetLastError _WSA_TCPAccept _WSA_TCPCloseSocket _WSA_TCPConnect _WSA_TCPListen _WSA_TCPRecv _WSA_TCPSend #INTERNAL_FUNCTIONS __TimeoutManager __TimeoutReset #EXTRA_FUNCTIONS _WSA_GetAddrInfo _WSA_GetHostByAddr _WSAAsyncGetHostByName _WSAAsyncGetHostByName_Callback _WSA_GetNameInfo Requirements: - AutoIt Versions: 3.3.8.1 thru 3.3.15.0 (32Bit only). - TCPStartup() at beginning of script on startup. - TCPShutDown() and _WSA_Cleanup() on exit. Download UDF: WSA_NBTCP.au3
    1 point
  4. mikell

    Screen Capture a PrtScn

    This works for me #include <ScreenCapture.au3> #Include <Clipboard.au3> Send("{PRINTSCREEN}") _ClipBoard_Open(0) $hBmp = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() MsgBox (0, "$hBmp", $hBmp) _ScreenCapture_SaveImage (@ScriptDir & "\ClipBoard_GetData.jpg", $hBmp)
    1 point
  5. I have run a random number of scripts (each for a random period) - controlled by a master script in an infinite loop - and never encountered any problems.
    1 point
  6. lewisg

    RunWait redirect to file

    Thanks to all, using the link iamtheky's provided and following the example of using many (3) string variables instead of one long string, it's now working as expected. Why it changed to begin with and why it now works, I don't know.....just glad it's solved.
    1 point
  7. You might use a dirty workaround... create a zero-width column 0 and set it at the last column position #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $hGui, $listview, $hImage Local $iLV_EXStyle_NoChecks = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP) $hGui = GUICreate("Listview Test With Icons", 400, 300) $listview = GUICtrlCreateListView("|Col 1|Col 2|Col 3", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SHAREIMAGELISTS)) _GUICtrlListView_SetExtendedListViewStyle($listview, $iLV_EXStyle_NoChecks) GUISetState() ; Create the image list $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUICtrlListView_SetImageList($listview, $hImage, 1) ; Set the order so the first column is moved to the end _GUICtrlListView_SetColumnWidth($listview, 0, 0) _GUICtrlListView_SetColumnOrder($listview, "1|2|3|0") ; Add the items GUICtrlCreateListViewItem("|Item1|Item2|Item3", $listview) GUICtrlCreateListViewItem("|Item4|Item5|Item6", $listview) ; Set an icon for just the first item _GUICtrlListView_SetItemImage($listview, 0, 0, 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main
    1 point
  8. @mLipok Good idea on adding the links to the W3C docs. As far as the IF/THEN/ENDIF question, I would say that it's just a habit of mine to use this format. I suspect that any overhead would be insignificant, but I would be happy to have someone prove me wrong.
    1 point
  9. Really? Correct, as I don't need to explain why this is locked and no further discussion requires. *click* Jos
    1 point
  10. I honestly do not understand this statement, nor why "some autoit scripts" would not finish as they are all run autonomously. @px307, What does hanging mean? do you see their icon's still in the system tray? How exactly do you manage to shell 30 times a script that only have the line "exit 0" in it without the first one being ended? Jos
    1 point
  11. When a Mod asks a pertinent question, you answer it. Attitude will not help your situation.
    1 point
×
×
  • Create New...